Links a script file to the generated page at the right time according to the script dependencies, if the script has not been already included and if all the dependencies have been registered. You could either link a script with a handle previously registered using the wp_register_script() function, ...

learn more… | top users | synonyms

1
vote
1answer
961 views

Only let plugin add actions to wp_head & wp_footer on single posts

I'm using a a plugin (Comments Evolved) on a recently built site. The issue I'm having is that this plugin globally enqueueing and adding actions to the head and footer of all pages. I'd like to ...
5
votes
8answers
6k views

wp_enqueue_script adding conditional statement not working

This is the code im using in my functions file: add_action('init', 'sort_out_jquery_pngfix_frontend'); function sort_out_jquery_pngfix_frontend() { global $wp_scripts; if(!is_admin()) { ...
0
votes
2answers
15 views

Load stylesheet on custom admin submenu page

I'm trying to load a stylesheet for a particular admin submenu page. The code below is what I came up with after looking up admin_enqueue_scripts in the codex: function my_function($hook) { if ( ...
0
votes
0answers
29 views

Safari only bug: script enqueuing blocks other scripts

Looking for some advice. One page of my blog is an angular app that is loaded via systemjs. It loads fine in Chrome (and firefox) on my computers and Android phone. But Safari is very erratic and ...
1
vote
1answer
27 views

When can you get current page ID and initialize hooks right after?

I'm developing a plugin and need to know on what page user is and then add specific hooks and filters for that page. And my problem is that is_page() and the_ID() doesn't work outside of wp, ...
0
votes
2answers
44 views

Localizing script to pass a value to a javascript function

i'm really getting crazy about this. after hours of trials, i can't get out of this. I'm trying to pass a php variable value to an enqueued jquery script but i can't. here is my code. php : ...
0
votes
2answers
2k views

Deregister scripts on unnecessary pages using remove_action

To all would-be close-voters: This question is not a duplicate, because I need to remove all scripts added by plugin using remove_action. In Very stubborn wp_register_script / add_action vs ...
0
votes
0answers
20 views

How to wp_enqueue_script with html?

I want to wp_enqueue_script multiple javascript with html and css. I place the html code in a page, but it's not working on my side. Only plain text is displayed. Here's the link: ...
2
votes
2answers
2k views

require.js to load javascript

whilst wp_enqueue_script seems to work it's not really elegant. I'm currently making a WP front end which uses MVC (backbone.js) and has literally 30+ seperate Model/View/Collection/Controller scripts ...
0
votes
0answers
12 views

Which are the MediaElement.js scripts to enqueue

I'm loading (paging) posts with ajax, so I want to be able to render videos using MediaElement.js on newly appended content. I already have my script working but is failing if no video posts are ...
0
votes
0answers
12 views

How to list the scripts and styles enqueued for a certain page?

How do I get all the scripts and styles used on a certain WordPress page. I would like to see the following, Name of script/style URL to script/style Version of script/style And if a certain script ...
0
votes
1answer
21 views

Register script in one plugin, and enqueue it in another

I need to register a script in one plugin and enqueue it in another. This is not working the way I expect it would. Am I missing something? Plugin that registers script: add_action( ...
0
votes
1answer
68 views

Enqueueing a script and a style sheet not working

I am trying to enqueue both a child theme style sheet and a child theme script. I need to enqueue the script because I put CDN links in there for Bootstrap. I know my enqueue isn't working correctly ...
0
votes
0answers
20 views

Enqueing Scripts

Perhaps more of a verification question for me... My plugin uses a few JS files which it enqueue's, however I am finding that in some instances of WordPress and some Themes the JS is not working as ...
0
votes
0answers
28 views

After wordpress widget save (ajax call) tinymce editor gone, data not saved

I have made tinymce editor for textarea fields in widgets. I'm enquing scripts: wp_enqueue_script('tinymce', home_url() . '/wp-includes/js/tinymce/tinymce.min.js'); wp_enqueue_script('tiny', ...
1
vote
1answer
71 views

Javascript not working?

2 days ago my javascript was located in my footer folder running correctly, until suddenly it stopped working. I was lazy to do the proper way of enqueueing, so I officially did that to see if it ...
0
votes
1answer
26 views

Enqueue specific script on account creation (and never again)

I'd like to submit a Google Analytics event when a user creates an account. Right now I'm checking for the presence of a 'first_login' user meta value on every page load. If it doesn't exist, the ...
0
votes
1answer
1k views

wp_enqueue_script() not working at all

I'm trying to enqueue JavaScript files using wp_enqueue_script(), but it isn't working at all. Here is my code: function load_css_js() { wp_enqueue_style('gdgt-base', get_template_directory_uri() ...
0
votes
1answer
2k views

Simple Button onClick to trigger jQuery function

I have looked similiar questions but any of it didn't worked I want to trigger jQuery function with onClick button, but it didnt worked. HTML structure : <button class="my-button" ...
3
votes
2answers
1k views

Protocol neutral URLS with wp_enqueue_script (SSL issues)?

How do I use wp_enqueue_script so that I get protocol neutral URLs? Here is how I'm currently using it: <?php wp_enqueue_script('name', get_bloginfo('template_directory'). '/js/name.pack.js'); ...
3
votes
2answers
507 views

Using get_option() in JavaScript

Previously, I used the get_option() function to get an option in PHP, like this: $width = get_option('my_width'); This is inside a shortcode function. Now, I want to have an option in JavaScript. ...
2
votes
1answer
47 views

Is it safe to enqueue a font style without putting http or https?

I have seen a few WordPress sites and tutorials enqueuing fonts like this. Does this work with http and https sites? Is it safe to do this? I see these exact URL's in the source code when testing ...
0
votes
2answers
81 views

Most elegant way to enqueue scripts in function.php with foreach loop

I wonder is there a way of running wp_register_script and enqueue with the help of foreach loop to manage label and dir? For example, function wbs_app_components(){ $scripts_list=array( ...
1
vote
2answers
366 views

Prevent Version URL Parameter (?ver=X.X.X) on Enqueued Styles & Scripts

Use Case I've been experimenting with Chrome's Dev Tools Workspace features. It includes the ability to edit a file directly in Dev Tools and have the saved stylesheet refresh itself (or even compile ...
0
votes
1answer
24 views

How to load script conditionally on custom field in wp_postmeta?

I'm trying to tidy up some of the code that has been doing its job for quite a while. Specifically, I used to load scripts in header.php and I'm trying to move that into functions.php. One of the ...
0
votes
0answers
18 views

Why would javascript files be included in header on one site, but not others?

Why might some javascript files be included in the head section on one site, but in the footer of hundreds of other similar sites? I have several different multisite Wordpress installations on my ...
4
votes
1answer
216 views

Move Wordpress native javascript to bottom of page?

Checking my page in google page speed insights, it complains that there are some javascript that is blocking the rest of the page from loading. The javascript in question is native Wordpress scripts ...
0
votes
2answers
41 views

Use wp_enqueue_scripts from included php file

I've got a realy hair pulling problem here. I've started cleaning up a plugin i've made and sort some of the functions in diffrent files. but i've got a problem with wp_enqueue_scripts. when i ...
0
votes
1answer
29 views

Do I need to register my own created .js and .css files

I have several .js and .css files which I created for my theme. (not a child theme) Styles and scripts are at the moment hard-coded in the head and work as wished. Now I read a lot about register and ...
0
votes
0answers
18 views

jQuery.suggest only suggestion is “0”

I'm trying to get suggestions in a text field with data from a database, inside an admin page. The only suggestion I get, no matter what, is always "0".. why? Relevant code parts the ...
-1
votes
1answer
28 views

WooCommerce not enqueuing its scripts [closed]

I am trying to create a new theme in WordPress powered by WooCommerce. The problem is that WooCommerce for some reason doesn't enqueue its scripts, so the "Add to cart" Ajax feature and sorting drop ...
5
votes
6answers
2k views

How to add stylesheets only to pages with specific shortcode?

I'm running a function on pages where the shortcode [make-me-a-map] is used. It enqueues javascript to the page and makes a map. That part works fine (woot!) but I'm having trouble with adding the ...
0
votes
1answer
22 views

Including Styles and JS files to work ON my plugin interface

Hey WordPress community, I've been having a couple of issues with trying to add a stylesheet and a JavaScript file which run on my plugin interface. So far i have this: ...
0
votes
0answers
27 views

Conflicts with jQuery

I wrote a plugin that works fine, but in one site I get jQuery loaded twice even if I don't enqueue it myself (I guess the theme loads it also). I tried to deregister it and than again enqueue but ...
1
vote
1answer
38 views

How to switch css files according to devices and button click?

I am trying to enqueue a responsive css file if the website is opened on mobile devices. Also I want to switch / enqueue a default or non-responsive css file when a button is clicked. The ...
0
votes
1answer
24 views

early enqueueing javascript file in page template, not in functions.php

Is it at all possible to enqueue javascript file early on page template file? I want to use this way of including scripts to keep my structure clean (so each page template has its own styling and ...
23
votes
7answers
13k views

How do I enqueue styles/scripts on certain /wp-admin pages?

I have two simple functions that load stuff using wp_enqueue_style() and wp_enqueue_script(), something like these: function admin_custom_css() { wp_enqueue_style( 'stylesheet_name', ...
1
vote
1answer
571 views

Move jQuery to the bottom of the page whilst keeping the WordPress jQuery

I wish to move jQuery to the bottom of the page on my theme, to speed up loading times. Previously I was doing this by replacing it with Google's CDN version but I have been told that is a bad thing ...
0
votes
1answer
27 views

wp_enqueue_scripts and CSS

I know wp_enqueue_script has the ability to have a dependency which is great. Now what if I can't give it one? What if all I want is for it to be the last script in the list of generated CSS ...
0
votes
2answers
24 views

dequeue not work

i use a plugin that containing this code and i want to change js location to be located in my template directory instead of plugin without editing the plugin files class jqueryTimelinrLoad { ...
0
votes
0answers
20 views

Wordpress listening on specific port

I am trying to get Wordpress to run on vagrant I have port forwarding for 127.0.0.1:8080 on my host machine. Everything runs just great except plugin scripts are stripping out :8080 from their url ...
0
votes
1answer
27 views

How to disable jQuery tabs when customizing the theme

Regarding this yet unsolved bug, how can I disable jQuery Tabs from the frontend when using the theme customizer?
0
votes
1answer
108 views

Jquery function working in Dev Console but not otherwise [duplicate]

Can someone help me utilize native wordpress jquery to run my function? The only working test i have done is to load an external jquery resouce via the chrome dev console and then add my function to ...
0
votes
2answers
37 views

Deregister scripts from plugin

I have an own class that deregisters all scripts and styles and creates 2 cached files one for scripts and one for styles that is registered in the end. This runs inside theme, my problem is that I ...
0
votes
1answer
22 views

wp_enqueue_script adds only the first script

function banana_scripts() { wp_enqueue_script('grid', get_stylesheet_directory_uri() . '/js/jquery.min.js', null, null); wp_enqueue_script('grid', get_stylesheet_directory_uri() . ...
0
votes
1answer
21 views

Dequeue set-post-thumbnail.min.js

Want to alter the behavior how set-post-thumbnail works (add additional functionality upon successful set post thumbnail). Looking on how to dequeue the stock set-post-thumbnail.min.js script so I can ...
2
votes
1answer
53 views

$wp_styles->registered not giving ALL the styles?

I'm pretty new to Wordpress programming (been using it for a while, but never got into the nitty gritty). So, I'm trying to "minify" some JS/CSS files into common ones. I'm manually joining the files ...
0
votes
1answer
32 views

Enqueueing Scripts and Styles to page template that has html

I built a custom calculator using html5, css3, and jQuery. I have it live and it works well but now someone would like to put my calc on their WP website and we can not figure out how to get it on his ...
0
votes
3answers
567 views

thickbox never gets called (weird behavior)

I have the exact same files (except for wp-config) running on a local server and a test server, and in my functions.php I have this: function len_scripts() { if (!is_admin()): ...
7
votes
2answers
2k views

Enqueue Scripts / Styles when shortcode is present

What is the idea way to register/enqueue scripts and/or styles for use in plugins? I recently made a plugin simple plugin to add the user avatar/gravatar with a shortcode. I have different style ...