PHP 8 causes conflict with Product Page only
-
I have a navigation bar on my WooCommerce site that I’ve used for years with no problem. It works fine with PHP 7.4 but if I try switching to PHP 8.0, it displays correctly on every page except Product Pages. I have attached screenshots of what happens. The one with the list of links instead of the navigation bar is PHP 8.0. I have tried looking for conflicts with other plugins by eliminating them and adding back one at a time — it doesn’t matter. I ran a debug routine both with PHP 8.0 and with PHP 7.4 and it turned up this (I’ve deleted the full paths or account names for security reasons and substituted brackets). Does anyone know what’s going wrong and how I could fix it? Note that I am a designer not a coder so I have no idea what the code here actually does, but I do know how to edit a child theme and can copy and paste code into it if you tell me exactly what to do.
PHP 8.0 DEBUG LOG:
Fatal error: Uncaught TypeError: call_user_func_array(): Argument #1 ($callback) must be a valid callback, function “add_text” not found or invalid function name in /includes/class-wp-hook.php:324 Stack trace: #0 /includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #1 /includes/[/plugin.php(517): WP_Hook->do_action(Array) #2 /wp-content/plugins/woocommerce/templates/content-single-product.php(72): do_action(‘woocommerce_aft…’) #3 /wp-includes/template.php(792): require(‘/home/georgegl/…’) #4 /wp-content/plugins/woocommerce/includes/wc-core-functions.php(284): load_template(‘/home/[account name]/…’, false) #5 /wp-content/plugins/woocommerce/templates/single-product.php(37): wc_get_template_part(‘content’, ‘single-product’) #6 /wp-includes/template-loader.php(106): include(‘/home/[account name]/…’) #7 /wp-blog-header.php(19): require_once(‘/home/georgegl/…’) #8 /index.php(17): require(‘/home/[account name]/…’) #9 {main} thrown in /wp-includes/class-wp-hook.php on line 324
PHP 7.4 DEBUG LOG:
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘add_text’ not found or invalid function name in /wp-includes/class-wp-hook.php on line 324
HERE IS THE CLASS-WP-HOOK.PHP CODE. I’VE BOLDED LINES 324 AND 328:
EXCERPT OF LINES 289-354 OF CLASS-WP-HOOK.PHP, WITH LINES 324 AND 348 IN RED
/**
* Calls the callback functions that have been added to a filter hook.
*
* @since 4.7.0
*
* @param mixed $value The value to filter.
* @param array $args Additional parameters to pass to the callback functions.
* This array is expected to include $value at index 0.
* @return mixed The filtered value after all hooked functions are applied to it.
*/
public function apply_filters( $value, $args ) {
if ( ! $this->callbacks ) {
return $value;
}
$nesting_level = $this->nesting_level++;
$this->iterations[ $nesting_level ] = $this->priorities;
$num_args = count( $args );
do {
$this->current_priority[ $nesting_level ] = current( $this->iterations[ $nesting_level ] );
$priority = $this->current_priority[ $nesting_level ];
foreach ( $this->callbacks[ $priority ] as $the_ ) {
if ( ! $this->doing_action ) {
$args[0] = $value;
}
// 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, $the_['accepted_args'] ) );
}
}
} while ( false !== next( $this->iterations[ $nesting_level ] ) );
unset( $this->iterations[ $nesting_level ] );
unset( $this->current_priority[ $nesting_level ] );
--$this->nesting_level;
return $value;
}
/**
* Calls the callback functions that have been added to an action hook.
*
* @since 4.7.0
*
* @param array $args Parameters to pass to the callback functions.
*/
public function do_action( $args ) {
$this->doing_action = true;
$this->apply_filters( '', $args );
// If there are recursive calls to the current action, we haven't finished it until we get to the last one.
if ( ! $this->nesting_level ) {
$this->doing_action = false;
}
}The page I need help with: [log in to see the link]
- You must be logged in to reply to this topic.