Questions tagged [wp-enqueue-script]

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, or provide this function with all the parameters necessary to link a script. This is the recommended method of linking JavaScript to a WordPress generated page.

Filter by
Sorted by
Tagged with
0
votes
0answers
9 views

customize_controls_enqueue_scripts doesn't fire from within my plugin

I have a plugin that builds a Class which handles injecting Customizer features. Within it I am inserting: Customizer Panel > Section > Settings/Controls The controls I am I am injecting a Select ...
0
votes
1answer
34 views

PHP Notice: wp_enqueue_script was called incorrectly. Scripts and styles should not be registered

Can someone help me fix this error? PHP Notice: wp_enqueue_script was called incorrectly. Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, ...
0
votes
0answers
20 views

Adding External Gmap JS to WordPress

I had some working javascript code that I wanted to move out of the template file and put into a .js file. I moved the code into a front.js file, where some pre-existing javascript lives. Now I'm ...
0
votes
1answer
9 views

How do I dequeue js/css at the last possible moment?

I'm trying to dequeue the font-awesome stylesheet included with the ninja forms plugin (because I manually include the latest FA via a CDN). I did this: add_action('wp_enqueue_scripts', function () {...
0
votes
1answer
19 views

Is there a loading priority for login_enqueue_scripts?

I'm using this function to load my plugins (custom-logo-and-login) Javascript file in the footer of the login.php page, but the file loads right before the wp-includes main jQuery library: add_action(...
0
votes
1answer
30 views

Media library not working with wp_editor() on the front end

Very related: Add Media has stopped working in the front end since 4.5 update I want to run the wp_editor() function to load the classic WordPress editor on the Front-End. I need to do this out of ...
0
votes
1answer
20 views

How can I properly enqueue wp-hooks without issues?

I want to provide the package @wordpress/hooks which currently resides in the core at wp-includes/js/hooks.js but I'm having a hard time finding exactly how / where it is enqueued so that I can copy ...
0
votes
1answer
131 views

Wordpress core jquery version file not loaded?

I try to put a simple <textarea> with an emoji picker (https://github.com/mervick/emojionearea) in my wordpress site (with buddypress installed, actually I put this in buddypress messages). The ...
0
votes
1answer
223 views

Enqueue custom font file with rel=“preload”

I'm using a custom font on my WP site. It is now included with @font-face css attribute. But I'm wondering if there is any way to wp_enqueue this file with the attribute rel="preload" and may be some ...
1
vote
2answers
46 views

Deregistering a script in Wordpress seems impossible

I tried everything. I even removed all content in functions.php and created a whole new file with just this: function wpdocs_dequeue_script() { if (is_singular()) { wp_dequeue_script( 'gdrts-...
0
votes
0answers
42 views

Why can I not deregister my style and script on custom post type?

I have a website where I have a custom post type with some single pages attached to it. Problem: I can't deregister the scripts and styles on my custom post type single pages. This is my code: ...
0
votes
1answer
23 views

Load JS file only in specific template

is_page is working fine as it detects the slug. However, is_page_template function isn't and so I tried global $template too but that's not working either. How can I resolve this issue? I want to ...
0
votes
1answer
59 views

How to remove all enqueued assets from the active theme?

https://gelwp.com/articles/removing-all-enqueued-and-default-css-scripts-in-wordpress/ has code that removes all the enqueued styles including those that may be coming from other plugins besides the ...
0
votes
3answers
37 views

Enqueue All Stylesheets Found In a Theme Folder

Is there a built-in Wordpress function that will allow you to enqueue all stylesheets for a particular theme? I have a directory structure that looks like: -my-custom-theme -css -header....
0
votes
1answer
21 views

enqueue script with get_shortcode_regex

I try to optimize a bit and i want to load some shortcodes only if they are found in global $post Unfortunately its not working, the script is not loaded when i open a page which contains the ...
0
votes
1answer
36 views

Plugin add_action and add_menu_page

I am using this code to make menu for my plugin. This works well. My question is: what is the difference between including some php page and enqueue some scripts/styles in foo_admin_enqueue_scripts ...
0
votes
2answers
27 views

Enqueue sripts and styles only if function is called

I'm using a function to display a gallery and I need to load its JS/CSS only if the gallery function is called. Both functions are in the custom plugin. I have now the first function to enqueue ...
0
votes
2answers
82 views

Enqueue Script in custom plugin before other

I've got a conflict with another plugin which is blocking the JS in my custom plugin with the hook: add_action('wp_enqueue_scripts', '<FOREIGN-PLUGIN>'); Is there a way to enqueue my JS before ...
0
votes
1answer
29 views

How Do I Enqueue a Script into 2 different Footers on the Same Site?

I have two different footers being used on a WordPress site. One is the standard footer.phpthe other is for the contact and legal pages and is footer-contact.php Calling them on the relevant page is ...
0
votes
2answers
25 views

Unable to dequeue a plugin script. I think I've tried everything

EDIT - SOLUTION GIVEN IN COMMENTS The problem was that I was initially hooking in at wp_enqueue_scripts so I wanted a high priority to make sure my dequeue was happening after the plugin's enqueue. ...
0
votes
0answers
34 views

Load script and styles using an array of resources

I want to simplify the scripts and the stylesheet loading in my wordpress plugin. I have this code style now, but I want to implement a best solution, this to encache the function readbility. Is there ...
0
votes
1answer
33 views

Unable to defer loading of jquery

I have two render blocking JS from wordpress core. jquery.js and jquery-migrate.min.js. Following this answer on WPSE I was able to add `defer="defer"' to the script tag that calls for jquery-migrate ...
1
vote
1answer
26 views

How to remove style and js from theme and add your own style and js where shortcode is used?

I making a small plugin for wordpress and that works through a shortcode. is it possible that the page that uses my shortcode has only my js and style rather than having theme style and js as well. I ...
0
votes
1answer
14 views

How do I ensure I can loop through every enqueued script and CSS?

I'm on a bit of an efficiency drive. To this end, I would like to check all the scripts and CSS that get enqueued on my multisite setup. I plan to check that they are offloaded to public CDNs if ...
3
votes
1answer
50 views

enqueuing React script and hooking its target div fails to load script

I am getting a silent failure on the below code as I try to enqueue a static React.js script and hook its injecting div into the admin_footer. I see the page and my test echo plus the url of the ...
0
votes
0answers
21 views

Importing the style and scripts in the plugin doesn't work as well as in the theme

I import the same styles and scripts in the plugin and they don't work fully. The same styles and scripts if I import in the template it works great. this is the code to import add_filter( '...
1
vote
1answer
26 views

Register vendor JS/CSS only on pages that require them?

I have some JS \ CSS that is used within selected pages on my site for various UI functions, for example an image slider. This image slider is only used on a few pages inside the site and loading it ...
0
votes
0answers
21 views

Dequeue Parent Theme File and Enqueue Child's

Not being able to achieve this simple thing for some reason Parent Theme Code (File: css_js_include.php) if( 'estate_property' == get_post_type() || 'estate_agent' == get_post_type() || ...
0
votes
1answer
31 views

My scripts-bundle.js file is getting sent to the browser as a stylesheet css file. Help!

I'm new to WordPress custom theme development. I am using a child theme for OceanWP. I have a webpack setup to hot-reload my files but my js scripts are not getting sent to my WordPress site instead ...
0
votes
1answer
16 views

How do I get rid of my inclusion race-condition on wp_enqueue_script

I'm trying not to be a lazy dev. Thus I want to only include my js files where they are needed. As the js is needed everywhere where my shortcode is used I tried to do what was answered here. i.e.: ...
0
votes
1answer
23 views

Changing URL of scripts, scripts outside theme folder?

Is it possible to have css and js scripts outside of template directory? If it is possible, how can I achieve it? Basically, instead of having: http://example.com/wp-content/themes/mytheme/assets/...
0
votes
0answers
37 views

Why does my wp_enqueue_script() only insert the script for logged in users

I've got a really simple enqueue in my functions.php file. The weird thing is that it only actually inserts the script if I'm logged in. I've tried wiping out everything else in the functions.php but ...
1
vote
1answer
92 views

React JSX in Wordpress Plugin Development

I was able to get React working in my custom Wordpress Plugin but I forgot how I got it working. What I'm trying to do is use a react component I have in NPM and use it as a Wordpress plugin. I used ...
0
votes
1answer
97 views

Dequeue Scripts and Style for Mobile not working?

I've followed a few tutorials on Dequeueing and Deregistering scripts and styles for WP - trying to optimise my site speed. Initially I could dequeue and deregister, until I added a condition for ...
0
votes
0answers
27 views

Override parent theme deregister

I have a parent theme that deregisters a script, in my case jquery. It does it like this: function parent_enqueue_scripts() { wp_deregister_script( 'jquery' ); [...] } However, in my child ...
0
votes
2answers
137 views

functions.php - inject inline css from file

I would like to read from a .css file and inject it as an inline style in wp_head. it's possible? i've tried this "Add inline css to theme" solution but it doesn't do what I expect because I expect ...
0
votes
0answers
25 views

Scripts don't enqueue after removing plugin

Using the Ultimate Member plugin. My custom scripts are loading in my child-theme as follows: function some_theme_enqueue_styles() { wp_enqueue_style( 'parent-style', get_template_directory_uri() ...
0
votes
0answers
41 views

Enqueue registered dependencies only when necessary

I'm developing plugin where I want to load my dependency JS libraries only when the setting is enabled. The most correct way is to register all the scripts and styles I have and then enqueue my main ...
0
votes
2answers
66 views

How to execute Javascript on a Wordpress page?

I'm trying to get some Javascript to run on one of my pages. But nothing I do seems to work. I ran the code in a sandbox and it is functional. I tried: - Inserting and HTML builder element and ...
1
vote
3answers
281 views

How to dequeue / deregister any theme styles and scripts

Is it possible to some how make my plugin dequeue / deregister any styles and any scripts from what ever theme activated. so it doesn't matter what theme will be installed the styles and scripts of ...
1
vote
1answer
122 views

wp_localize_script not working on ajax response

When a file is uploaded to my page I make an ajax call to add an entry in a database. I then want to send a string back to the client using wp_localize_script but when I try to access it I just get an ...
0
votes
1answer
25 views

Append php file to footer

I have javascript in my php file. and I want to load it in footer. Is any method for that?
1
vote
2answers
29 views

Exclude JS file from 404 error page

I have a custom tracking system in place which works with an include of a .js file in the footer of each page. Unfortunately some high traffic sites are including images from my site which are ...
1
vote
0answers
39 views

Stop WordPress editor embedding links

There are several posts about this, - but I suspect that it has changed after Gutenberg, since I can't get either of the methods to work. I'm trying to stop WordPress embedding links, when written ...
0
votes
0answers
30 views

How to avoid conflict if a plugin already have included open library?

I am trying to use the swiper the library. https://idangero.us/swiper/get-started/ But the Elementor plugin is already added that : https://github.com/elementor/elementor/tree/master/assets/lib/...
0
votes
0answers
172 views

jQuery UI with touchpunch not fully working on touch devices

I'm currently trying to get the jQuery UI sortable function working on my Android phone (touch). Sadly, the touch event don't works on my phone. I've tried everything. jQuery("#details-inner")....
0
votes
1answer
42 views

wp_enqueue_script add integrity parameter

I'm adding fontawesome script to my site, and I didn't found a proper way to add the fontawesome's integrity parameter (integrity="sha384-DJ25uNYET2XCl5ZF++...
0
votes
0answers
24 views

Scripts and stylesheets failing to load in Chrome IOS (and only Chrome IOS)

My script and stylesheet files have been failing to load in Chrome IOS, and only Chrome IOS. I changing the value of $ver in wp_register_script from a string with a value ("1.0.17") to an empty string,...
1
vote
2answers
236 views

is_page() function doesnt working

I'm trying to add these custom CSS and JS (written inside a custom plugin) only add to a specific page. this is my code <?php function randomAlphaNumeric($length) { $pool = array_merge(...
0
votes
1answer
27 views

AJAX call of function containing javascript which is not loaded (Plugin development)

I have written a plugin which has a usermanagement page in the backend. This page loads userdata from the database by an AJAX call. The data returned from this function does contain HTML with class ...