I have two Wordpress sites with theme Dyad 2 https://wordpress.com/theme/dyad-2
I need to upgrade from PHP 7.4 to 8.1, but when I try I got four "Deprecated: Non-static" errors. I managed to fix all but this one in class-wp-hook.php:
Deprecated: Non-static method WPCom_Theme_Updater::maybe_nag_for_plugin() should not be called statically in public_html/wp-includes/class-wp-hook.php on line 307
Line 307 is "$value = call_user_func_array( $the_['function'], $args );", and in some context here:
...
...
// Avoid the array_slice() if possible.
if ( 0 == $the_['accepted_args'] ) {
$value = call_user_func( $the_['function'] );
} elseif ( $the_['accepted_args'] >= $num_args ) {
$value = call_user_func_array( $the_['function'], $args );
} else {
$value = call_user_func_array( $the_['function'], array_slice( $args, 0, (int) $the_['accepted_args'] ) );
...
...
The whole code is here (.OLD is the original). Right now I think they are both identical as whatever I tried, I got worse errors and not functioning site. class-wp-hook.php: https://justpaste.it/72r0g class-wp-hook.php.OLD: https://justpaste.it/2tmrn
I'm guessing that it has something to do with the file public_html/wp-content/themes/dyad-2-wpcom/inc/updater.php because it has WPCom_Theme_Updater and maybe_nag_for_plugin() And it was also one of the files that gave most of the "Deprecated: Non-static" errors, so I had to change a lot of "self::" to "(new self)->"
The whole code is here (.OLD is the original). updater.php: https://justpaste.it/4tgpf updater.php.OLD: https://justpaste.it/8kkqc
I have tried to change line 307 and the content of updater.php, but I don't really know what I am doing. I have got some ideas from these links, but cant figure out the right fix: PHP Deprecated: Non-static method should not be called statically https://stackoverflow.com/questions/38469828/calling-non-static-method-with-call-user-func-array-in-php https://stackoverflow.com/questions/19693946/non-static-method-should-not-be-called-statically