Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

WordPress

Boris Kamp
Boris Kamp
16,660 Points

WP Error after moving from MAMP to Live server

I moved a copy of my locally build WP site from MAMP to a live server (I do this once in a while to keep my colleague updated). Normally everything goes perfect but now Wordpress gives me the following error in my <body> I follow this tut for moving from MAMP to Live

WP gives this error:

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'my_scripts_method' not found or invalid function name in /home/mijnawf.nl/public_html/wp-includes/plugin.php on line 505

I did everything I normally do, updated permalinks etc etc, whats wrong?

Line 505 of plugin.php contains this code:

    do {
        foreach ( (array) current($wp_filter[$tag]) as $the_ )
            if ( !is_null($the_['function']) )
                call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); //This is line 505

    } while ( next($wp_filter[$tag]) !== false );

    array_pop($wp_current_filter);

Thanks in advance!

Boris Kamp
Boris Kamp
16,660 Points

It's solved, but please let me know if you have any ideas about my questions below. Thank you very much Andrew! I appreciate it!

2 Answers

Andrew Shook
Andrew Shook
31,709 Points

Boris, do you have a function in your theme's functions.php called my_scripts_method? It looks like you used the add_action or add_filter, and didn't supply the hook. If you have command line access to MAC or server you could run this:

grep -R 'my_scripts_method' /path/to/wordpress/root/folder

This will search all files in all directories of your wordpress site for my_script_method. You might be able to track the problem down from there.

Boris Kamp
Boris Kamp
16,660 Points

I do! but it's strange because I cannot recall myself changing this between the time I had no error and right now. I have this in my functions.php, I honestly have no idea what it's for:

add_action( 'wp_enqueue_scripts', 'my_scripts_method' );

I commented it out for now and the problem disappeared. Do you have any idea what it's for? there is no my_scripts_method function or something.

And why does Wordpress not echo this error in my local test environment in MAMP? any idea?

Andrew Shook
Andrew Shook
31,709 Points

My guess is that the my_scripts_method added javascript or css files to the theme. I'm not 100% sure, I'm not a WP expert, but my premise is this. Some where in WP there is an array called wp_enqueue_scripts. Whenever you use add_action() the name of your function is added to that array. Then this piece of code:

    do {
        foreach ( (array) current($wp_filter[$tag]) as $the_ )
            if ( !is_null($the_['function']) )
                call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); //This is line 505

    } while ( next($wp_filter[$tag]) !== false );

    array_pop($wp_current_filter);

which I assume is part of the do_action function takes the array, loops through it, and executes the added function using this built in PHP function:

 call_user_func_array();

As far as why it worked on your local host and not on you remote host I can't be sure. Maybe you have warning reporting turned off on your local host and not your remote host.

Boris Kamp
Boris Kamp
16,660 Points

Thank you for elaborating Andrew. Now that I have that line commented out I should be missing some inclusions right? Im not seeing anything or so.

Andrew Shook
Andrew Shook
31,709 Points

No you shouldn't be missing anything, that was the problem in the first place. You had this:

add_action( 'wp_enqueue_scripts', 'my_scripts_method' );

But no function call 'my_script_method'. Thats why you were getting a warning.

Boris Kamp
Boris Kamp
16,660 Points

Ok, I understand. Thanks for getting back at me! Great support from you!