Articles of wp dependencies

How to enqueue default scripts with dependency?

I’m developing a plugin and for that I need jQuery and jQuery datepicker. I’s taught that WordPress already enqueued some scripts, and I found ‘jquery’ and ‘jquery-ui-datepicker’ there. Where the datepicker is said to be dependent to jQuery. In that codex page it’s also mentioned that, we can call a dependent script like the following: […]

Can´t access child theme´s scripts dependencies found in parent

I´ve been struggling with this for nearly a month now and still couldn´t find anything at all on how to do this! Not here, not in Quora, not through many different advanced Google search queries… Here it is: The parent theme has only one script file main.min.js. It contains all the scripts and libraries being […]

How to get list of Scripts in Order of Dependencies

I was writing plugin for combining JS and CSS as three plugins I tried has not worked for me. Dependency problem is where I stopped. It look tough. Then I thought WordPress can itself help. How to get list of files in order of dependencies? Is there any WP method for this? Can I use […]

JavaScript added as link/stylesheet

I am just trying to create a plugin that will add some JS to the header and custom CSs. I have this below but it adds the css wrong and shows as JS. This is first plugin i have attempted. <?php /** * Plugin Name: mmoore5553 Simple Range Slider * Plugin URI: * Description: […]

Check for dependent plugin and if false dont activate plugin

I am creating a plugin for WordPress and this plugin depends on another plugin with a specific version. If I enable my plugin without dependent plugin there are fatal error. Is there a way to check this ? I tried looking at source code but WP do not provide any hook for this. Thanks in […]

RequireJS in custom theme. Working Example

I try to add to my custom wordpress Theme requirejs because I do not want to use wp_enqueue over and over to inject used plugins and on the other side I do not want to mess the DOM from the beginning. I followed a lot of tutorials what I got from google but none of […]

Add a script as a dependency to a registered script

wp_register_script() (see codex) allows you to specify dependencies: scripts that must be loaded before the one being registered is loaded (if it is loaded). But suppose the script is a third-party one (WordPress or another plug-in) so that you are not the one calling wp_register_script(). How can you inject a script as a dependency for […]

How to modify/extend/override a core method?

This is my first post. In advance, thank you for welcoming me… Context When you enqueue style, you can output your css link into conditional comments. global $wp_styles; wp_enqueue_style(“my_styles_ie”); $wp_styles->add_data(“my_styles_ie”, “conditional”, “(lt IE 9) & (!IEMobile)”); It will produce the following code : <!–[if (lt IE 9) & (!IEMobile)]> <link rel=”stylesheet” href=”#” /> <![endif]–> This […]

Identifying the priority of style.css so I can make a small CSS file load last

I have a small bit of hourly-changing css and I want to keep it in a second file (apart from style.css) and load it after my theme’s style.css file. I believe I can make it load before style.css by setting its priority to the style.css minus one (e.g. if the main style.css has a priority […]

Concatenate and minify dependencies for enqueued JavaScript files

I’m loading a JavaScript file using wp_enqueue_script into my theme. However, along with it, I’m loading several jQuery files as well, as dependencies for the enqueued script (which has already been concatenated and minified by Grunt). Here is my code: add_action(‘wp_enqueue_scripts’, function() { wp_enqueue_script( ‘customscripts’, get_template_directory_uri() . ‘/assets/js/main.min.js’, array(‘jquery’, ‘jquery-form’, ‘json2’, ‘jquery-ui-autocomplete’), NULL, true ); […]