Articles of wp dependencies

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: mailto:mmoore5553@gmail.com * 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 ); […]

Is there any sort of theme dependency management?

I’m developing a WordPress theme with a few other individuals and am running into a problem where I add a plugin and then I have tell the other developers about the plugin I installed and the settings I set for the plugin so that the theme works. I was wondering if there’s a way to […]

Should 3rd Parties Use $wp_scripts/$wp_styles->add_data?

Within the WP_Dependencies class exists a method named add_data. This function adds data to scripts/styles that have been enqueued during the WordPress load. A commonly cited use for this function is to add a conditional when adding stylesheets that are targeted at different versions of IE. For example, to target IE8 and lower: function test_wp_print_styles() […]