Не работают скрипты на WordPress (все подключено)

1160
10 декабря 2016, 10:15

Вот пример кода на js (и он не работает) и результат который выдается в браузере в теге head , можно увидеть что все подключается нормально. Не могу понять в чем проблема?

jQuery(document).ready(function () { 
    jQuery(".button-collapse").sideNav({ 
        closeOnClick: false // Closes side-nav on <a> clicks, useful for Angular/Meteor 
    }); 
     
     
    jQuery('.footer').append('qweqweqwe'); 
});
<head> 
    <meta charset="UTF-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no"> 
    <title>Title</title> 
    <link rel="dns-prefetch" href="//fonts.googleapis.com"> 
<link rel="dns-prefetch" href="//s.w.org"> 
		<script type="text/javascript"> 
			window._wpemojiSettings = {"baseUrl":"https:\/\/s.w.org\/images\/core\/emoji\/2\/72x72\/","ext":".png","svgUrl":"https:\/\/s.w.org\/images\/core\/emoji\/2\/svg\/","svgExt":".svg","source":{"concatemoji":"http:\/\/localhost\/wp-includes\/js\/wp-emoji-release.min.js?ver=4.6.1"}}; 
			!function(a,b,c){function d(a){var c,d,e,f,g,h=b.createElement("canvas"),i=h.getContext&&h.getContext("2d"),j=String.fromCharCode;if(!i||!i.fillText)return!1;switch(i.textBaseline="top",i.font="600 32px Arial",a){case"flag":return i.fillText(j(55356,56806,55356,56826),0,0),!(h.toDataURL().length<3e3)&&(i.clearRect(0,0,h.width,h.height),i.fillText(j(55356,57331,65039,8205,55356,57096),0,0),c=h.toDataURL(),i.clearRect(0,0,h.width,h.height),i.fillText(j(55356,57331,55356,57096),0,0),d=h.toDataURL(),c!==d);case"diversity":return i.fillText(j(55356,57221),0,0),e=i.getImageData(16,16,1,1).data,f=e[0]+","+e[1]+","+e[2]+","+e[3],i.fillText(j(55356,57221,55356,57343),0,0),e=i.getImageData(16,16,1,1).data,g=e[0]+","+e[1]+","+e[2]+","+e[3],f!==g;case"simple":return i.fillText(j(55357,56835),0,0),0!==i.getImageData(16,16,1,1).data[0];case"unicode8":return i.fillText(j(55356,57135),0,0),0!==i.getImageData(16,16,1,1).data[0];case"unicode9":return i.fillText(j(55358,56631),0,0),0!==i.getImageData(16,16,1,1).data[0]}return!1}function e(a){var c=b.createElement("script");c.src=a,c.type="text/javascript",b.getElementsByTagName("head")[0].appendChild(c)}var f,g,h,i;for(i=Array("simple","flag","unicode8","diversity","unicode9"),c.supports={everything:!0,everythingExceptFlag:!0},h=0;h<i.length;h++)c.supports[i[h]]=d(i[h]),c.supports.everything=c.supports.everything&&c.supports[i[h]],"flag"!==i[h]&&(c.supports.everythingExceptFlag=c.supports.everythingExceptFlag&&c.supports[i[h]]);c.supports.everythingExceptFlag=c.supports.everythingExceptFlag&&!c.supports.flag,c.DOMReady=!1,c.readyCallback=function(){c.DOMReady=!0},c.supports.everything||(g=function(){c.readyCallback()},b.addEventListener?(b.addEventListener("DOMContentLoaded",g,!1),a.addEventListener("load",g,!1)):(a.attachEvent("onload",g),b.attachEvent("onreadystatechange",function(){"complete"===b.readyState&&c.readyCallback()})),f=c.source||{},f.concatemoji?e(f.concatemoji):f.wpemoji&&f.twemoji&&(e(f.twemoji),e(f.wpemoji)))}(window,document,window._wpemojiSettings); 
		</script><script src="http://localhost/wp-includes/js/wp-emoji-release.min.js?ver=4.6.1" type="text/javascript"></script> 
		<style type="text/css"> 
img.wp-smiley, 
img.emoji { 
	display: inline !important; 
	border: none !important; 
	box-shadow: none !important; 
	height: 1em !important; 
	width: 1em !important; 
	margin: 0 .07em !important; 
	vertical-align: -0.1em !important; 
	background: none !important; 
	padding: 0 !important; 
} 
</style> 
<link rel="stylesheet" id="bs3-css" href="/wp-content/themes/materialblog/style/bootstrap.min.css?ver=4.6.1" type="text/css" media="all"> 
<link rel="stylesheet" id="style-css" href="/wp-content/themes/materialblog/style/style.css?ver=4.6.1" type="text/css" media="all"> 
<link rel="stylesheet" id="about-css" href="/wp-admin/css/about.min.css?ver=4.6.1" type="text/css" media="all"> 
<link rel="stylesheet" id="blog-css" href="/wp-content/themes/materialblog/style/blog.css?ver=4.6.1" type="text/css" media="all"> 
<link rel="stylesheet" id="contact-css" href="/wp-content/themes/materialblog/style/contact.css?ver=4.6.1" type="text/css" media="all"> 
<link rel="stylesheet" id="portfolio-css" href="/wp-content/themes/materialblog/style/portfolio.css?ver=4.6.1" type="text/css" media="all"> 
<link rel="stylesheet" id="matercss-css" href="/wp-content/themes/materialblog/style/materialize.min.css?ver=4.6.1" type="text/css" media="all"> 
<link rel="stylesheet" id="fonts-css" href="https://fonts.googleapis.com/icon?family=Material+Icons&amp;ver=4.6.1" type="text/css" media="all"> 
<script type="text/javascript" src="/wp-includes/js/jquery/jquery.js?ver=1.12.4"></script> 
<script type="text/javascript" src="/wp-includes/js/jquery/jquery-migrate.min.js?ver=1.4.1"></script> 
<script type="text/javascript" src="/wp-content/themes/materialblog/js/bootstrap.min.js?ver=4.6.1"></script> 
<script type="text/javascript" src="/wp-content/themes/materialblog/js/loadport.js?ver=4.6.1"></script> 
<script type="text/javascript" src="/wp-content/themes/materialblog/js/materialize.min.js?ver=4.6.1"></script> 
<script type="text/javascript" src="/wp-content/themes/materialblog/js/myjs.js?ver=4.6.1"></script> 
<script type="text/javascript" src="/wp-content/themes/materialblog/js/portfolio.json?ver=4.6.1"></script> 
<link rel="https://api.w.org/" href="/wp-json/"> 
<link rel="EditURI" type="application/rsd+xml" title="RSD" href="/xmlrpc.php?rsd"> 
<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="/wp-includes/wlwmanifest.xml">  
<meta name="generator" content="WordPress 4.6.1"> 
 
 
    <script id="portfolio" type="text/html"> 
        <div class="col-md-4 col-sm-6 col-xs-12 nop"> 
 
            <div class="content__block content__block-pos z-depth-1"> 
                <img src="${img}" alt="" class="content__img content__img-pos"> 
                <h3 class="content__title content__title-pos">${title}</h3> 
                <p class="content__article content__article-pos">${article}</p> 
                <div class="divider"></div> 
                <button class="content__read waves-effect content__read-pos">Read more</button> 
            </div> 
        </div> 
    </script> 
 
<style>.prepros-reload *, .prepros-reload { -webkit-transition: all .5s; -moz-transition: all .5s; transition: all .5s;}</style></head>

PHP код файла funcions.php Стили и скрипты подключаются в функциях wp_add_style() и wp_add_scripts(). Так же отдельно подключаю jquery в функции jquery_init(). Знак $ поменял везде на jQuery.

<?php
    function wp_add_style(){
        wp_enqueue_style('bs3', get_template_directory_uri().'/style/bootstrap.min.css',[],false,'all');
        wp_enqueue_style('style', get_template_directory_uri().'/style/style.css',['bs3'],false,'all');
        wp_enqueue_style('about', get_template_directory_uri().'/style/about.css',[],false,'all');
        wp_enqueue_style('blog', get_template_directory_uri().'/style/blog.css',[],false,'all');
        wp_enqueue_style('contact', get_template_directory_uri().'/style/contact.css',[],false,'all');
        wp_enqueue_style('portfolio', get_template_directory_uri().'/style/portfolio.css',[],false,'all');
        wp_enqueue_style('matercss', get_template_directory_uri().'/style/materialize.min.css',[],false,'all');
        wp_enqueue_style('fonts', 'https://fonts.googleapis.com/icon?family=Material+Icons',[],false,'all');
    }
    add_action('wp_enqueue_scripts', 'wp_add_style');
    function wp_add_scripts(){
    //    wp_enqueue_script( 'jquery','http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.2.min.js', [],'', false );
        wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', ['jquery'] );
        wp_enqueue_script( 'loadport', get_template_directory_uri() . '/js/loadport.js', ['jquery'] );
        wp_enqueue_script( 'materialize', get_template_directory_uri() . '/js/materialize.min.js', ['jquery'] );
        wp_enqueue_script( 'myjs', get_template_directory_uri() . '/js/myjs.js', ['jquery'] );
        wp_enqueue_script( 'json', get_template_directory_uri() . '/js/portfolio.json', ['jquery'] );
    }
    add_action('wp_enqueue_scripts', 'wp_add_scripts');

    function jquery_init() {
        if (!is_admin()) {
            wp_enqueue_script('jquery');
        }
    }
    add_action('wp_enqueue_scripts', 'jquery_init');
    add_theme_support('post-thumbnails'); // поддержка миниатюр
    //Добавление "Цитаты" для страниц start
    function my_custom_init() {
        add_post_type_support( 'page', 'excerpt' );
    }
    add_action('init', 'my_custom_init'); ?>
    <?php
    //Фильтр от спама
    add_filter('pre_comment_on_post', 'verify_spam');
    function verify_spam($commentdata) {
        $spam_test_field = trim($_POST['comment']);
        if(!empty($spam_test_field)) wp_die('Спаму нет!');
        $comment_content = trim($_POST['real-comment']);
        $_POST['comment'] = $comment_content;
        return $commentdata;
    }?>

Ошибки в Chrome

READ ALSO
Как отправить из js в переменную php

Как отправить из js в переменную php

вот есть скрипт который берет из фото base64 и пихает его в src как сделать что бы base64 отправлялся в переменную php код на этой же странице?

401
Как с помощью XPath достать текст

Как с помощью XPath достать текст

Есть путь к элементу

344
Symfony 1.4 include_component(&hellip;) Как вызвать асинхронно?

Symfony 1.4 include_component(…) Как вызвать асинхронно?

Друзья есть старый проект работающий на symfony 14

237