0
 function my_scripts_method() {
            wp_deregister_script( 'jquery' );
            wp_register_script( 'jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js');
            wp_enqueue_script( 'jquery' );
        }

        add_action( 'wp_enqueue_scripts', 'my_scripts_method' );

        function my_scripts(){
            wp_enqueue_script( 'easingjs', '//cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js', array('jquery'), true, null );

            wp_enqueue_script( 'freelancerjs', get_template_directory_uri() . '/js/freelancer.js', array('easingjs'), true, null );
        }

        add_action('wp_enqueue_scripts', 'my_scripts');

Скрипт 'freelancerjs' зависит от 'easingjs', при явном объявлении в футере все хорошо работает, но через правильное объявление в function.php, 'easingjs' не срабатывает и соответственно не работает. jQuery объявлен и с другими скриптами корректно работает, а easing отваливается, консоль молчит, не помогает даже вынос easing в отдельный файл.

код frelancerjs:

// Freelancer Theme JavaScript

(function($) {
    "use strict";

 // Start of use strict

    // jQuery for page scrolling feature - requires jQuery Easing plugin
    $('.page-scroll a').bind('click', function(event) {
        var $anchor = $(this);
        $('html, body').stop().animate({
            scrollTop: ($($anchor.attr('href')).offset().top - 50)
        }, 1250, 'easeInOutExpo');
        event.preventDefault();
    });

    // Highlight the top nav as scrolling occurs
    $('body').scrollspy({
        target: '.navbar-fixed-top',
        offset: 51
    });

    // Closes the Responsive Menu on Menu Item Click
    $('.navbar-collapse ul li a').click(function(){ 
            $('.navbar-toggle:visible').click();
    });

    // Offset for Main Navigation
    $('#mainNav').affix({
        offset: {
            top: 100
        }
    })

    // Floating label headings for the contact form
    $(function() {
        $("body").on("input propertychange", ".floating-label-form-group", function(e) {
            $(this).toggleClass("floating-label-form-group-with-value", !!$(e.target).val());
        }).on("focus", ".floating-label-form-group", function() {
            $(this).addClass("floating-label-form-group-with-focus");
        }).on("blur", ".floating-label-form-group", function() {
            $(this).removeClass("floating-label-form-group-with-focus");
        });
    });

})(jQuery); // End of use strict
$(document).ready(function() {
    $(".portfolio-grid").each(function(i) {
        $(this).find(".portfolio-link").attr("href", "#portfolioModal_" + i);
        $(this).find(".portfolio-modal").attr("id", "portfolioModal_" + i );
    });

});

код easing стандартный (ссылка не минифицированной версии): http://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.js

Заранее спасибо

2
  • Два последних параметра в wp_enqueue_script заданы странно. Их смысл: (номер версии или false) и (в футере или нет). Непонятно, как WP на такое отреагирует. Поставьте false, true. Т.е. третий = false, четвертый = true. 23 июн 2017 в 12:28
  • даже при правильной расстановке не цепляются скрипты, в инспекторе их просто нет. 23 июн 2017 в 16:42

0

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Посмотрите другие вопросы с метками или задайте свой вопрос.