Using multiple versions of jQuery while still calling it like WP likes

I have two JS plugins inside my plugin. One uses jQuery 1.7.1 and the other 1.9.1. I need to have each of them use different version. This is how things are at the moment: Plugin php file: wp_register_script(‘jq-1.9.1-js’, ‘https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js’); wp_enqueue_script(‘jq-1.9.1-js’); wp_register_script(‘jq-1.7.1-js’, ‘https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js’); wp_enqueue_script(‘jq-1.7.1-js’); Plugin JS file: var $j = jQuery.noConflict(); $j(document).ready(function() { // plugin 1 … Read more

Enque Typekit Fonts – Not Found

I’m trying to enqueue a typekit on my WP site in a function using code below: /** * TypeKit Fonts * * @since Theme 1.0 */ function theme_typekit() { wp_enqueue_script( ‘theme_typekit’, ‘//use.typekit.net/xxxxxxx.js’); } add_action( ‘wp_enqueue_scripts’, ‘theme_typekit’ ); function theme_typekit_inline() { if ( wp_script_is( ‘theme_typekit’, ‘done’ ) ) { ?> <script type=”text/javascript”>try{Typekit.load();}catch(e){}</script> <?php } } add_action( … Read more

Is it mandatory to enqueue any kind of Javsacript?

I am dynamically generating in a page some Javascript code depending on many conditions, however this happens in the middle of the page. As I have read that as a general rule it’s better to enqueue scripts, I was wondering if this rule applies also to page-specific scripts. For instance: $var_js = “<script type=”text/javascript”>// <![CDATA … Read more

Can’t move jQuery to footer

Below two methods did not help me. My jQuery is always on the head section. What can be the reason? Method 1: (adding below code to function.php) if (!is_admin()) add_action(“wp_enqueue_scripts”, “my_jquery_enqueue”, 11); function my_jquery_enqueue() { wp_deregister_script(‘jquery’); wp_enqueue_script( ‘jquery’, ‘https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js’,array(),’1.9.0′,true); } this one works when I change ‘jquery’, to some other string as first parameter in … Read more

Adding custom fonts (local) to WordPress?

I have this code: @font-face { font-family: ‘Miller Banner Light’; src: url(‘fonts/Miller-Banner-Light-01.eot’); /* IE9 Compat Modes */ src: url(‘fonts/Miller-Banner-Light-01.eot?#iefix’) format(’embedded-opentype’), /* IE6-IE8 */ url(‘fonts/Miller-Banner-Light-01.woff’) format(‘woff’), /* Pretty Modern Browsers */ url(‘fonts/Miller-Banner-Light-01.ttf’) format(‘truetype’) /* Safari, Android, iOS */ } Which in theory allows to add these fonts to my theme, unfortunately, simply creating the fonts folder … Read more

How can I make sure my JS script gets executed first, among other scripts?

I have this script that cuts down my menu and adds a “+” dropdown if there are too many menu items in an attempt to prettify long menus, as such: Without the script running: Which I call in functions.php with: function _s_scripts() { wp_enqueue_script( ‘main’, get_template_directory_uri() . ‘/js/main_res.js’, array( ‘jquery’ ), ”, false ); } … Read more

Relative path instead of absolute for wp_enqueue_script

When you enqueue scripts or styles with the following: function themeslug_enqueue_style() { wp_enqueue_style( ‘core’, ‘/style.css’, false ); } add_action( ‘wp_enqueue_scripts’, ‘themeslug_enqueue_style’ ); You get the following: <link rel=”stylesheet” id=’core-css’ href=”http://localhost:8080/wordpress/style.css?ver=4.9.4″ type=”text/css” media=”all” /> Note that it appends the site url to the beginning, in this case http://localhost:8080. I’m trying to remove this so that it’s … Read more

enqueue hover function

I am trying to enqueue a hover function in my functios.php of my child theme, so that when hovering over a title, a div with a text will be visible. The code I am using is this: <?php add_action( ‘wp_enqueue_scripts’, ‘home_game’, 20); function home_game(){ ?> <script> let title1 = document.getElementById(“home-title1”); title1.addEventListener(‘mouseover’, mouseOver); title1.addEventListener(‘mouseout’, mouseOut); function … Read more

Is it possible to enqueue a script from a widget method (of extended WP_Widget object)?

I am creating a widget plugin that a user could potentially use multiple iterations of the widget multiple times on a single widget-area / multiple widget-areas on a single page. Because of its functionality there will be differing widget-level variables that I will need to individually pass from PHP to JavaScript to take action on … Read more