• Resolved aliwebdesarrollo

    (@aliwebdesarrollo)


    Hi there, i just found that your plugin shows a warning.

    Aparently you enqueue jquery script not following the WordPress recomendations, and thats creates a warning message if someone remove std jquery script and add a new version in the function.php on every theme.

    I found this making a traceback to see witch plugin was generating this warning.

    Description of the warning

    Unknown wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. Please see Debugging in WordPress for more information. (This message was added in version 3.3.) on line 3012

    This warning i found with Blackbox plugin.

    I paste here the code of the traceback function that i paste into wp-includes/function.php to find what file and function were generation this issue.

    function GetCallingMethodName($g){
        $e = new Exception();
        $trace = $e->getTrace();
        //position 0 would be the line that called this function so we ignore it
        $last_call = $trace[2]; <- i set 2 because 0 is the function GetCalling... 1 is the function that shows the msg and 2 is the one who origin the problem.
        print_r($last_call);
        print("<br>");
    }

    Put that function wherever into wp-includes/function.php and then paste this code just after line 3012

    if(is_admin())
    GetCallingMethodName("");

    This is happening to me because in my theme i do this:

    function an_load_custom_wp_scripts()
    {
    wp_deregister_script('jquery');
    wp_register_script('jquery', get_template_directory_uri().'/js/jquery.min.js', false, '1.10.2', false);
    wp_enqueue_script('jquery');
    }
    add_action('wp_enqueue_scripts', 'an_load_custom_wp_scripts',20);

    http://wordpress.org/plugins/contact-form-manager/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter aliwebdesarrollo

    (@aliwebdesarrollo)

    The solution will be something like this i suppouse, the file i modify is admin/menu.php

    at the line 100 where is asked if is_admin you have to modify and put something like:

    function xyz_cfm_add_admin_scripts()
    	{
    		wp_enqueue_script('jquery');
    
    		wp_register_script( 'xyz_notice_script', plugins_url('contact-form-manager/js/notice.js') );
    		wp_enqueue_script( 'xyz_notice_script' );
    
    		wp_register_script( 'xyz_tooltip_script', plugins_url('contact-form-manager/js/tooltip.js') );
    		wp_enqueue_script( 'xyz_tooltip_script' );
    	}
    
    	add_action("admin_enqueue_scripts","xyz_cfm_add_admin_scripts");

    and if you want jquery too you may have to do this:

    function xyz_cfm_add_scripts()
    {
    		wp_enqueue_script('jquery');
    }
    
    add_action("wp_enqueue_scripts","xyz_cfm_add_scripts");
    Plugin Author f1logic

    (@f1logic)

    thanks for posting this.
    will take care in upgrade.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘jquery wp_enqueue script’ is closed to new replies.