• Resolved tnchuntic

    (@tnchuntic)


    Hi Jahidul,

    Good day

    The error is cause by the enqueue script and style it should be wrap inside function and triggered by add_action. You will see the error when you enable the WP_DEBUG to TRUE.

    See below code OLD

    wp_enqueue_script('x-jquery-easing', X_PLUGIN_URL.'js/jquery.easing.min.js', array('jquery'));
    wp_enqueue_script('x-jquery-main-scroll-up', X_PLUGIN_URL.'js/jquery.scrollUp.min.js', array('jquery'));
    wp_enqueue_script('x-jquery-active', X_PLUGIN_URL.'js/active.js', array('jquery'));
    wp_enqueue_style( 'wp-color-picker' );
    wp_enqueue_script( 'my-script-handle', plugins_url('js/my-script.js', __FILE__ ), array( 'wp-color-picker' ), false, true );
    
    wp_enqueue_style('x-scroll-plugin-css', X_PLUGIN_URL.'css/custom.css');
    wp_enqueue_style('x-scroll-plugin-fontello-css', X_PLUGIN_URL.'css/fontello.css');

    Change to NEW

    function add_x_scroll_style() {
        if ($GLOBALS['pagenow'] != 'wp-login.php' && !is_admin()) {
            wp_enqueue_style('x-scroll-plugin-css', X_PLUGIN_URL.'css/custom.css');
            wp_enqueue_style('x-scroll-plugin-fontello-css', X_PLUGIN_URL.'css/fontello.css');
        }
    }
    add_action('wp_enqueue_scripts', 'add_x_scroll_style');
    
    function add_x_scroll_script() {
        if ($GLOBALS['pagenow'] != 'wp-login.php' && !is_admin()) {
            wp_enqueue_script('x-jquery-easing', X_PLUGIN_URL.'js/jquery.easing.min.js', array('jquery'));
            wp_enqueue_script('x-jquery-main-scroll-up', X_PLUGIN_URL.'js/jquery.scrollUp.min.js', array('jquery'));
            wp_enqueue_script('x-jquery-active', X_PLUGIN_URL.'js/active.js', array('jquery'));
    
        }
    }
    add_action('wp_enqueue_scripts', 'add_x_scroll_script');
    
    function add_admin_x_scroll_scripts() {
    
        //Register color picker script
        wp_enqueue_style( 'wp-color-picker' );
    
        wp_enqueue_script( 'my-script-handle', plugins_url('js/my-script.js', __FILE__ ), array( 'wp-color-picker' ), false, true );
    }

    add_action(‘admin_enqueue_scripts’, ‘add_admin_x_scroll_scripts’);
    Hope this helps and if your satisfied with the code kindly update your plugin.

    Thanks

    https://www.ads-software.com/plugins/x-scroll-to-top-responsive/

  • The topic ‘WP_ENQUEUE ERRORS & FIXES’ is closed to new replies.