Why do WordPress adds the id=”handle-{js|css}” attribute to scripts and stylesheet?

The id attribute was added to the <style> tags in WordPress v4.1 (2014) — see the Trac changesets 29956 and 29958 which both mentioned ticket #30032 (“Add ID attribute to style element from wp_add_inline_style()“): In order to support partial preview refreshes (#27355), it is important for all partials being updated to have an element with … Read more

How to enqueue js script after another specific js script?

That’s part of the default functionality available in wp_enqueue_script/wp_register_script. The third argument, as seen in the official documentation of enqueue/register script, https://developer.wordpress.org/reference/functions/wp_enqueue_script/, https://developer.wordpress.org/reference/functions/wp_register_script/, is the dependencies array. $deps string[] Optional An array of registered script handles this script depends on. Default: array() So lets say you have script with the handle “sliderjs”, using your code … Read more

Trying to use wp_register_script/style and enqueu them from an array – getting an error [duplicate]

As the “Error Message” (which is in fact a “doing it wrong”-message) is telling you, you’re using the wrong hook: Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. Just read about hooks, wrap your code in a callback and then register it properly on one of the … Read more

Orbit Slider and Events Manager Plug-in JavaScript

If you want to enqueue the scripts only on the “Events” page, change the following code to include the conditional tag is_page() function public_enqueue() { //Scripts wp_enqueue_script(‘events-manager’, plugins_url(‘includes/js/events-manager.js’,__FILE__), array(‘jquery’, ‘jquery-ui-core’,’jquery-ui-widget’,’jquery-ui-position’,’jquery-ui-sortable’,’jquery-ui-datepicker’,’jquery-ui-autocomplete’,’jquery-ui-dialog’)); //jQuery will load as dependency //Styles wp_enqueue_style(‘events-manager’, plugins_url(‘includes/css/events_manager.css’,__FILE__)); //main css } Change it to the following: function public_enqueue() { if( is_page(‘events’) ) { //Only load … Read more

WordPress | enqueue_scripts in a child’s theme returns error

The reason being that: get_template_directory_uri() actually returns the parent’s theme url. To fix it, I simply concatenated the remainder of the path. In this case, the code became: // loading menu toggle function | located in the child’s theme folder function menu_toggle_enqueue_script() { wp_enqueue_script( ‘menu-toggle’, get_template_directory_uri(). ‘-child’ . ‘/assets/js/menu.js’); } add_action(‘wp_enqueue_scripts’, ‘menu_toggle_enqueue_script’); I figured out … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)