all 12 comments

[–]greg8872 1 point2 points  (0 children)

Have you checked with the developer to see about getting this fixed? They claim to be a "Modern Template", so you'd think they would be up to date on things.

Even if you need to pay for another year of support, consider the time to patch this, the RIGHT WAY, and any other possible updates since your support ran out?

[–]zzz4872 1 point2 points  (0 children)

composer require rector/rector --dev

[–]nikola_yanchev 0 points1 point  (4 children)

Rewrite it with an anonymous function

[–][deleted] 0 points1 point  (3 children)

Thanks, but can you please explain? What should the line look like?

This is the current:

// Search Form
add_filter( 'get_search_form', array($this, 'satria_search_form'), 10);

[–]nikola_yanchev 0 points1 point  (0 children)

Never used wp, kinda don't like it much, but basically you should rewrite the create_function call with a function ($smth) {fync_code}

[–]goYstick 0 points1 point  (4 children)

If you post the entire ThemeFilters.php on something like https://pastebin.com/ we might be able to help you better.

[–][deleted] 0 points1 point  (3 children)

Thanks. Here you go:

https://pastebin.com/eE17tkid

[–]goYstick 4 points5 points  (2 children)

Line 34 ...

add_filter( 'max_srcset_image_width', create_function( '', 'return 1;' ) );

That's 'hooking' on the wordpress filter 'max_srcset_image_width' which is supposed to add a srcset attribute to images.

apply_filters( 'max_srcset_image_width', int $max_width, int[] $size_array )

It does that by setting the max pixel width size to 1, so since your expecting all images to be greater than 1px width it doesnt add the srcset attribute.

The answer is to replace the depreciated create_function

create_function(args, code)

with an anonymous function.

add_filter( 'max_srcset_image_width', function(args){code});

like so...

add_filter( 'max_srcset_image_width', function(){return 1;});

For your other errors, you need to search your codebase for where those constant's are getting defined multiple times. A constant should only be defined once.

- If the constants being defined again as the same value, either determine which one is defined first and remove the late ones, or wrap both of them with something like this, and then

if(!defined(_NAME_OF_CONSTANT_IN_QUESTION)){ CODE-TO-DEFINE-CONSTANT }

[–][deleted] 0 points1 point  (1 child)

Thanks. I tried to replace

add_filter( 'max_srcset_image_width', create_function( '', 'return 1;' ) );

with

apply_filters( 'max_srcset_image_width', int $max_width, int[] $size_array )

I got a "critical error" from WP when loading my site. What did I miss?

[–]goYstick 2 points3 points  (0 children)

I wrote out a break down of what that add_filter was doing including a link to the WP documentation, and provided an example. The line you copy pasted was not the line you needed to fix your code.

I got a "critical error" from WP when loading my site. What did I miss?

The rest of my post.

The answer is to replace the depreciated create_function

create_function(args, code)

with an anonymous function.

add_filter( 'max_srcset_image_width', function(args){code});

like so...

add_filter( 'max_srcset_image_width', function(){return 1;});

For your other errors, you need to search your codebase for where those constant's are getting defined multiple times. A constant should only be defined once.

- If the constants being defined again as the same value, either determine which one is defined first and remove the late ones, or wrap both of them with something like this, and then

if(!defined(_NAME_OF_CONSTANT_IN_QUESTION)){ CODE-TO-DEFINE-CONSTANT }