WordPress.org

Forums

Notice: wp_register_script was called incorrectly (12 posts)

  1. Mihael
    Member
    Posted 4 years ago #

    Please, someone put me out of my misery and let me know what is a most probable reason for this problem:

    As far as I checked (at least 10 times) all my scripts are registered and enqueued as they should be...

    Notice: wp_register_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 my_path/wp-includes/functions.php on line 3587

    Thank you!

  2. James Edmonston
    Member
    Posted 4 years ago #

    Post the source of the file that is causing the errors - will allow us to debug and find the problem.

    Thanks.

  3. Mihael
    Member
    Posted 4 years ago #

    That would be rather difficult since the error does not say... I have a functions.php including a bunch of other custom scripts - as I exclude those, error remains... so they are not the problem :(

  4. James Edmonston
    Member
    Posted 4 years ago #

    Is it a custom theme or a fresh install of WordPress?

  5. Mihael
    Member
    Posted 4 years ago #

    It is my custom "work" and wordpress 3.3.1.
    I was thinking this might be some kind of more obvious error maybe... but it probably isn't... I am most certain that it is my mistake, since almost always is :)

  6. James Edmonston
    Member
    Posted 4 years ago #

    Well if you post the code where you enqueued scripts etc, that'll help.

  7. Mihael
    Member
    Posted 4 years ago #

    That would be to many code to post since I can't even find the origin of the error - we are talking about 40 files... I will have to take some more time and find the error... As I see now, the only thing that could be a problem is that some script is not registered when it should be... I will just have to revisit all my code.

    James, thank you for your effort... I am sorry that we couldn't get anywhere with this one :/

  8. Ryann Micua
    Member
    Posted 4 years ago #

    Hi Michael, i believe it has soemthing to do with the way you are supposed to register/enqueue your scripts.. basically the php notice is saying that you are using wp_register_script incorrectly. read this for more info. http://codex.wordpress.org/Function_Reference/wp_register_script

    you have to hook the register function into either wp_enqueue_scripts, admin_enqueue_scripts, or init.

    so, to use wp_register_script() properly do it like this:

    add_action('wp_enqueue_script','register_my_scripts');
    
    function register_my_scripts(){
    wp_register_script('xxx');
    }
  9. georgeliebau
    Member
    Posted 4 years ago #

    Where in the theme directory's functions.php file does that code go?

    Thanks!

  10. Mihael
    Member
    Posted 4 years ago #

    does not matter really... just put it "here" and "there".. test it.

  11. Ryann Micua
    Member
    Posted 4 years ago #

    basically, just go through all the places where you used wp_register_script() function and hook it to either "wp_enqueue_scripts", "init" or "admin_enqueue_scripts"

  12. sunrayshining
    Member
    Posted 3 years ago #

    Hello... and help! I'm getting same error at http://www.seedmedia.co.za - which occurred after BuddyPress support created a custom.php for the plugin to help with alignment issue.

    Now I'm getting white screen when I try log in.

    Any pointers?

    The buatp.template.custom.php reads:

    <?php
    
    /**
     * BuddyPress - Members Directory
     *
     * @package BuddyPress
     * @subpackage bp-default
     */
    get_header( 'buddypress' ); ?>
    
    	<?php do_action( 'bp_before_directory_members_page' ); ?>
    <div id="page-title">
            	<div id="page-title-inner">
                    <div class="title">
                    <h1>
                        <?php _e( sprintf('%1s Directory',ucfirst( buatp_get_dir_name())), 'buddypress' ); ?>
    
                    </h1>
            </div>
        </div>
    </div>
    	<div id="content">
                <div id="content-left">
                    <div class="maincontent" style="float: none">
    		<div class="padder">
    
    		<?php do_action( 'bp_before_directory_members' ); ?>
    
    		<form action="" method="post" id="members-directory-form" class="dir-form">
                            <?php do_action( 'bp_before_directory_members_content' ); ?>
    
    			<div id="members-dir-search" class="dir-search" role="search">
    
    				<?php bp_directory_members_search_form(); ?>
    
    			</div><!-- #members-dir-search -->
    
    			<div class="item-list-tabs" role="navigation">
    
    <ul>
    					<li class="selected" id="members-all"><a>"><?php printf( __( 'All %1s <span>%2s</span>', 'buddypress' ),ucfirst( buatp_get_dir_name()),  bp_get_total_member_count() ); ?></a>
    
    					<?php if ( is_user_logged_in() && bp_is_active( 'friends' ) && bp_get_total_friend_count( bp_loggedin_user_id() ) ) : ?>
    
    						<li id="members-personal"><a>"><?php printf( __( 'My Friends <span>%s</span>', 'buddypress' ), bp_get_total_friend_count( bp_loggedin_user_id() ) ); ?></a>
    
    					<?php endif; ?>
    
    					<?php do_action( 'bp_members_directory_member_types' ); ?>
    
    </ul>
    			</div><!-- .item-list-tabs -->
    
    			<div class="item-list-tabs" id="subnav" role="navigation">
    
    <ul>
    					<?php do_action( 'bp_members_directory_member_sub_types' ); ?>
    
    					<li id="members-order-select" class="last filter">
    
    						<label for="members-order-by"><?php _e( 'Order By:', 'buddypress' ); ?></label>
    						<select id="members-order-by">
    							<option value="active"><?php _e( 'Last Active', 'buddypress' ); ?></option>
    							<option value="newest"><?php _e( 'Newest Registered', 'buddypress' ); ?></option>
    
    							<?php if ( bp_is_active( 'xprofile' ) ) : ?>
    
    								<option value="alphabetical"><?php _e( 'Alphabetical', 'buddypress' ); ?></option>
    
    							<?php endif; ?>
    
    							<?php do_action( 'bp_members_directory_order_options' ); ?>
    
    						</select>
    
    </ul>
    			</div>
    
    			<div id="members-dir-list" class="members dir-list">
    
    				<?php locate_template( array( 'members/members-loop.php' ), true ); ?>
    
    			</div><!-- #members-dir-list -->
    
    			<?php do_action( 'bp_directory_members_content' ); ?>
    
    			<?php wp_nonce_field( 'directory_members', '_wpnonce-member-filter' ); ?>
    
    			<?php do_action( 'bp_after_directory_members_content' ); ?>
    
    		</form><!-- #members-directory-form -->
    
    		<?php do_action( 'bp_after_directory_members' ); ?>
    
    		</div><!-- .padder -->
                    </div>
                </div>
                <?php get_sidebar( 'buddypress' ); ?>
    	</div><!-- #content -->
    
    	<?php do_action( 'bp_after_directory_members_page' ); ?>
    
    <?php get_footer( 'buddypress' ); ?>

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. Or better still - use the pastebin. As it stands, your code has been permanently damaged/corrupted by the forum's parser.]

Topic Closed

This topic has been closed to new replies.

About this Topic