使用Functions.php的出列脚本

时间:2015-03-19 作者:Joseph Morris

您好,我正在尝试将在我的队列中找到的脚本“jquery.favorite.js”退出队列。php:

// WP_ENQUEUE_SCRIPTS
static function wp_enqueue_scripts_callback()
{
    global $javo_tso;

    $javo_register_scripts = Array(
        \'oms.min.js\'                                    => \'oms-same-position-script\'
        , \'common.js\'                                   => \'javo-common-script\'
        , \'chosen.jquery.min.js\'                        => \'jQuery-chosen-autocomplete\'
        , \'jquery.javo.msg.js\'                          => \'javoThemes-Message-Plugin\'
        , \'jquery.parallax.min.js\'                      => \'jQuery-Parallax\'
        , \'jquery.favorite.js\'                          => \'jQuery-javo-Favorites\'
        , \'jquery_javo_search.js\'                       => \'jQuery-javo-search\'
        , \'jquery.flexslider-min.js\'                    => \'jQuery-flex-Slider\'
        , \'google.map.infobubble.js\'                    => \'Google-Map-Info-Bubble\'
        , \'pace.min.js\'                                 => \'Pace-Script\'
        , \'single-reviews-modernizr.custom.79639.js\'    => \'single-reviews-modernizr.custom\'
        , \'jquery.magnific-popup.js\'                    => \'jquery-magnific-popup\'
        , \'jquery.easing.min.js\'                        => \'jQuery-Easing\'
        , \'jquery.form.js\'                              => \'jQuery-Ajax-form\'
        , \'sns-link.js\'                                 => \'sns-link\'
        , \'jquery.raty.min.js\'                          => \'jQuery-Rating\'
        , \'jquery.spectrum.js\'                          => \'jQuery-Spectrum\'
        , \'jquery.parallax.min.js\'                      => \'jQuery-parallax\'
        , \'jquery.javo.mail.js\'                         => \'jQuery-javo-Emailer\'
        , \'bootstrap.hover.dropmenu.min.js\'             => \'bootstrap-hover-dropdown\'
        , \'../bootstrap/bootstrap-select.js\'            => \'bootstrap-select-script\'
        , \'bootstrap-tagsinput.min.js\'                  => \'bootstrap-tagsinput-min\'
        , \'javo-footer.js\'                              => \'javo-Footer-script\'
        , \'bootstrap-markdown.js\'                       => \'bootstrap-markdown\'
        , \'bootstrap-markdown.fr.js\'                    => \'bootstrap-markdown-fr\'
        , \'jquery.quicksand.js\'                         => \'jQuery-QuickSnad\'
        , \'jquery.nouislider.min.js\'                    => \'jQuery-nouiSlider\'
        , \'okvideo.min.js\'                              => \'okVideo-Plugin\'
        , \'jquery.slight-submenu.min.js\'                => \'slight-submenu.min-Plugin\'
        , \'jquery.typehead.js\'                          => \'jquery-type-header\'
        , \'jasny-bootstrap.min.js\'                      => \'jasny-bootstrap\'
        , \'single-reviews-slider.js\'                    => \'single-reviews-slider\'
        , \'common-single-item.js\'                       => \'common-single-item\'
        , \'owl.carousel.min.js\'                         => \'owl-carousel-script\'
        , \'jquery.mixitup.min.js\'                       => \'mixitup\'
        , \'smoothscroll.js\'                             => \'smoothscroll\'
        , \'javo-single-property.js\'                     => \'javo-single-property\'

        /* Widget */
        , \'javo-wg-featured-scripts.js\'                 => \'javo-wg-featured-scripts\'
    );
我将此添加到我的函数中。php:

add_action(\'wp_enqueue_scripts\', \'my_remove_scripts\');

function my_remove_scripts(){

    wp_dequeue_script( \'jquery.favorite\' );
    }
然而,它仍然被称为。

我可以从队列中删除。php,但我宁愿通过函数来实现这一点。php。

谢谢

1 个回复
最合适的回答,由SO网友:CodeX 整理而成

只需删除

, \'jquery.favorite.js\' => \'jQuery-javo-Favorites\' 
$javo_register_scripts Array

function wpdocs_dequeue_script() {
    wp_dequeue_script( \'jQuery-javo-Favorites\' );
}
add_action( \'wp_print_scripts\', \'wpdocs_dequeue_script\', 100 );

结束

相关推荐

jquery issue in functions.php

我正在处理的主题中有一个问题,我不知道如何解决它。该主题有几个jquery脚本,需要加载到头部才能工作。如果没有所有这些,主题就失败了。这是我打电话给的人jquery-1.8.2。最小jsjquery-1.6.1。min.jsjquery。放松。1.3。jsjquery-ui-1.8.11。风俗min.jsjquery-ui-1.8.21。风俗最小js现在使用WordPress,我想您可以将jquery排队,然后加载所有版本。我的问题是,当我尝试这样做并删除上面的脚本时,一切都失败了。我将所有脚本放入函数