• Resolved jaspervdv

    (@jaspervdv)


    Hello,

    I got the following warning when I visit my home page on mobile: Warning: call_user_func_array() expects parameter 1 to be a valid callback, function ‘child_enqueue_styles’ not found or invalid function name in /home/customer/www/drone-optiek.nl/public_html/wp-includes/class-wp-hook.php on line 307.

    I have no experience with the theme editor and I don’t use it. Still this error appeared. I recently re-installed the Astra Child Theme and updated some plugins. I deactivated all the plugins but that did nothing.

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 61 total)
  • Hello,
    I think the (non-existent) function “child_enqueue_styles” is hooked to some filter hook, try searching in all your files for “child_enqueue_styles” if there is something like this:
    “add_filter(“some_wp_hook”, “child_enqueue_styles”)”
    Try to comment that out, if you don’t know how to comment something out please post a little snippet of the code

    If you have ssh access search for “child_enqueue_styles” in /home/customer/www like this: grep -R “child_enqueue_styles”

    If you don’t have ssh access try searching in the function.php file of wordpress and your themes

    Thread Starter jaspervdv

    (@jaspervdv)

    Hello Benni,

    Thanks for your response. When I go to my theme editor > Astra child > functions.php I see the following code:

    function child_enqueue_styles() {
    
    	wp_enqueue_style( 'astra-child-theme-css', get_stylesheet_directory_uri() . '/style.css', array('astra-theme-css'), CHILD_THEME_ASTRA_CHILD_VERSION, 'all' );
    
    }
    add_action( 'wp_enqueue_scripts', 'child_enqueue_styles', 15 );

    It has probably something to do with this part, but I am not sure and I dont know how to fix it. I got a screenshot but I can’t add it to this post. I tried deleting this code, but the error kept showing up.

    • This reply was modified 3 years, 7 months ago by jaspervdv.

    Hi,
    I am not sure if this is really the line that causes this problem,
    try to temporarily delete only the last line that you posted please.
    add_action( ‘wp_enqueue_scripts’, ‘child_enqueue_styles’, 15 );

    Thread Starter jaspervdv

    (@jaspervdv)

    Just tried it, but without succes. The error should disappear immediately after the problem is solved, right?

    Yes it should disappear immediately.
    I think this line is not the right one i think the problem should start with add_filter(
    try searching for that.
    Do you have a child theme?

    Thread Starter jaspervdv

    (@jaspervdv)

    The normal Astra theme is active now, but I also got the Astra Child Theme installed. I can select the Astra theme and the Astra child theme in the theme editor.

    Is there a quick way to search for the filter or do I have to manually look into all the files?

    If you have access to ssh his should do it otherwise you would have to search it:
    grep -R “child_enqueue_styles”

    Can you deactivate the Child Theme? Try that before manually searching

    Thread Starter jaspervdv

    (@jaspervdv)

    I now deleted the Astra child theme, so I only use the parent theme. No luck yet unfortunately.Using ssh or grep -r is too advacned for me, as I have no experience with the theme editor. That’s why it is so weird this error suddenly shows up.

    Please enable debugging mode and send me the debug log,

    search for this line:
    define( ‘WP_DEBUG’, false);

    and replace it with this:

    define( ‘WP_DEBUG_DISPLAY’, true ); #keep Displaying Errors on site for remote maintenance, SET TO FALSE IF NOONE NEEDS TO SEE THE ERRORS
    define( ‘WP_DEBUG_LOG’, true ); #log errors in /wp-content/debug.log

    you can just paste those lines, everything after # is a comment and is not treated by php

    Thread Starter jaspervdv

    (@jaspervdv)

    I found this on line 303 to 310 in /home/customer/www/drone-optiek.nl/public_html/wp-includes/class-wp-hook.php:

    // 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'] ) );
    				}

    This is line 307: $value = call_user_func_array( $the_[‘function’], $args );

    I just found the define( ‘WP_DEBUG’, false); in the file wp-config-sample.php.

    • This reply was modified 3 years, 7 months ago by jaspervdv.
    • This reply was modified 3 years, 7 months ago by jaspervdv.

    somewhere in the wp-config.php should be that line, if it is not there just add the code that I posted

    Thread Starter jaspervdv

    (@jaspervdv)

    I added the code in the wp-config.php. But it didn’t help. I changed define( ‘WP_DEBUG’, false); in the wp-config-sample.php to define( ‘WP_DEBUG’, true); but that also didnt help. The error still shows up 🙁

    yes, the error will still show but this should give us more detailed error messages, please turn WP_DEBUG_LOG to true like this:
    define( ‘WP_DEBUG_LOG’, true );
    and then send me the debug log in /wp-content/debug.log

    Thread Starter jaspervdv

    (@jaspervdv)

    I can’t find a file named debug.log. The only thing I found is this: wp-admin/includes/class-wp-debug-data.php.

    okay, do you have ssh access? if yes just type: grep -R “child_enqueue_styles”
    and send the whole output to me

Viewing 15 replies - 1 through 15 (of 61 total)

The topic ‘warning: call_user_func_array() expects parameter 1 to be a valid callback, func’ is closed to new replies.