Support » Plugin: iThemes Security (formerly Better WP Security) » jQuery error after removing from head

  • Hi

    My website is giving the following error:

    Notice: Undefined index: jquery in C:\domains\domain.com\wwwroot\wp-content\plugins\better-wp-security\core\modules\tweaks\class-itsec-tweaks.php on line 242
    
    Notice: Trying to get property of non-object in C:\domains\domain.com\wwwroot\wp-content\plugins\better-wp-security\core\modules\tweaks\class-itsec-tweaks.php on line 242

    This is because I’ll manually removed jQuery from my head using the following:

    function removejQuery() {
    		wp_deregister_script('jquery');
    	}
    	if ( !is_admin() )
    		add_action('wp_enqueue_scripts', 'removejQuery');

    I’ve added jQuery in a minified file in the footer of my website. Unfortunately I’ll still get the error when WP_DEBUG is set to true. How can I fix this?

    https://wordpress.org/plugins/better-wp-security/

Viewing 2 replies - 1 through 2 (of 2 total)
  • @ronnyrook

    I’ve added jQuery in a minified file in the footer of my website.

    How exactly did you do this ?

    dwinden

    @ronnyrook

    The iTSec plugin has the ‘jquery’ script handle hardcoded.
    So the iTSec plugin assumes there is always a script registered with a handle named ‘jquery’.

    When you move jQuery from the head section to the footer, just make sure the jQuery script is registered with the same handle ‘jquery’.

    For example:

    add_action( 'wp_enqueue_scripts', 'jquery_to_footer' );
    
    function jquery_to_footer() {
    
    	if ( ! is_admin() ) {
    		wp_deregister_script( 'jquery' );
    		wp_deregister_script( 'jquery-migrate' );
    
    		wp_register_script( 'jquery-migrate', '/wp-includes/js/jquery/jquery-migrate.js', array( 'jquery' ), '1.2.1', true );
    		wp_register_script( 'jquery', '/wp-includes/js/jquery/jquery.js', false, '1.11.3', true );
    
    		wp_enqueue_script( 'jquery-migrate' );
    	}
    
    }

    If the above info answers your question please mark this topic as ‘resolved’.

    dwinden

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘jQuery error after removing from head’ is closed to new replies.