WordPress.org

Ready to get started?Download WordPress

Forums

Weird wp_enqueue_script and Cannot modify header information Errors on Live site (14 posts)

  1. theslink2000
    Member
    Posted 1 year ago #

    Hi,

    I've recently moved to set up a live test site for my project and for whatever reason I'm getting errors that don't appear on the local version (XAMPP powered of course).

    Considering the site is still in dev I've never turned off WP_DEBUG so I know it's always been working. I had to modify the memory to 64M to get it to load, but apparently that's not uncommon.

    I had a couple of "Cannot modify header information" errors which were white space after the ?> related issues but when I go to login it'll let me enter a username and password then when I press enter it dies and throws out this:

    Notice: wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or init hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php on line 2758
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-login.php on line 349
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-login.php on line 361
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 697
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 698
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 699
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 700
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 701
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 702
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 705
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 706
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 707
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 708
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 711
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 712
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 713
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 714
    
    Warning: Cannot modify header information - headers already sent by (output started at /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/functions.php:2758) in /home/doctor6/domains/doctorschemist.hostesr.com/public_html/wordpress/wp-includes/pluggable.php on line 881

    The only way I've found to get the live site to load and is to comment out the content of the _doing_it_wrong function between lines 2751 and 2759 of the wp-includes\functions.php file.

    I have no idea why this should be on the live site and not the local!

    Can anyone help please, I've been over all the posts and documentation I can find with no answer.

  2. esmi
    Forum Moderator
    Posted 1 year ago #

    Notice: wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or init hooks.

    That sounds like you're enqueueing your scripts using the wrong hook. Have you reviewed http://codex.wordpress.org/Function_Reference/wp_enqueue_script

  3. theslink2000
    Member
    Posted 1 year ago #

    I've been over it and over it bud and I cannot see anything wrong. Also as I said it works perfectly on local.

    The functions file it mentions is the wordpress one so I haven't touched it. The only place I've enqueued a script in my whole theme is in my functions file and it looks like this:

    add_filter('wp_enqueue_scripts', 'remove_datepicker' );
    function remove_datepicker() {
    wp_dequeue_style( 'date-picker-style' );
    }

    I appreciate the help here :-)

  4. esmi
    Forum Moderator
    Posted 1 year ago #

    add_filter??? You should be using add_action. eg:

    if( !function_exists( 'emporium_enqueue_slider' ) ) :
    function emporium_enqueue_slider() {
         if( !is_front_page() ) return;
    	wp_register_script( 'emporium-eslider' , get_template_directory_uri() . '/library/ebxslider.js', array('jquery'),
        '1.3.2', true );
         wp_enqueue_script('emporium-eslider');
    
    	wp_register_script( 'emporium-eslider-config' , get_template_directory_uri() . '/library/ebxslider-config.js', array('jquery'),
        '1.3.2', true );
         wp_enqueue_script('emporium-eslider-config');
    }
    endif;
    add_action('template_redirect', 'emporium_enqueue_slider');
  5. theslink2000
    Member
    Posted 1 year ago #

    Ok, I changed that but in all fairness I got that code snippet from a plugin dev and I've never really got my head around the difference between add_filter and add_action as a lot of sources say they're basically interchangeable.

    As for the main issue, this changed nothing but I think there may be a wider issue here as whenever I try loading a page that isn't the home page or anything in the dashboard via the live site it jumps to the hosts 404 page, even using the preview page button from the dashboard, and because I couldn't get past login this is the first time I'm seeing this error. So whether that's related or not I don't know but WordPress migration seems to be over complicated to me at the moment.

    All I've done is load the database up then copy the files and redirect the settings from the dashboard, that should be enough surely? Oh my permalink structure works because on the dashboard page's page it shows the slug correctly.

    Am I being dense here and not understanding something?

  6. esmi
    Forum Moderator
    Posted 1 year ago #

    a lot of sources say they're basically interchangeable.

    Noo! They are completely different. Filters are the hooks that WordPress launches to modify text of various types before adding it to the database or sending it to the browser screen. Actions are triggered by specific events that take place in WordPress, such as publishing a post, changing themes, or displaying a page of the admin panel.

  7. theslink2000
    Member
    Posted 1 year ago #

    Fair enough, that actually makes sense lol. As far as I can tell I've got them right throughout by copying examples so I won't worry too much but I will definitely bare that in mind in future.

    Now, as for the rest of this mess I'm at a loss as to what's wrong with my uploaded site sadly.

  8. esmi
    Forum Moderator
    Posted 1 year ago #

    Are you still getting the same errors in your debug log?

  9. theslink2000
    Member
    Posted 1 year ago #

    Yeah, nothing different but only on login / out apart from that it appears normal (obviously ignoring the fact that no pages will load, but I think it's related somehow).

    It all seems to link back to how something is calling the _doing_it_wrong function on line 2758, but I don't see how.

  10. esmi
    Forum Moderator
    Posted 1 year ago #

    No - the line 2758 mention is a red herring. Something in your theme or a plugin is the actual cause of the problem. What happens if you switch to Twenty Eleven?

  11. theslink2000
    Member
    Posted 1 year ago #

    No change upon using TwentyEleven bud. Just out of interest, do you know a simpler, free method of migrating a site? Might be worth a try in case something hasn't gone right in that way perhaps?

  12. esmi
    Forum Moderator
    Posted 1 year ago #

    You should have a look at Moving_WordPress.

  13. theslink2000
    Member
    Posted 1 year ago #

    I'm sure I've followed everything outlined in there. But I'll rebuild to uploaded site this afternoon and report back.

    Cheers bud

  14. theslink2000
    Member
    Posted 1 year ago #

    Ok, I've put the live site elsewhere and I've figured out what was causing this error, just not why.

    The plugin WP Custom Login was to blame. Deactivating this caused the error to vanish and it also explains why it only happened on login/out.

    I've no idea why it does this on live servers and not localhost though...

    If anyone has any insights they'd be most welcome, if not I'll just have to work around using this plugin.

Topic Closed

This topic has been closed to new replies.

About this Topic