Should I use wp_register_style(), wp_enqueue_style, or both?
Should I use wp_register_style(), wp_enqueue_style, or both?
Should I use wp_register_style(), wp_enqueue_style, or both?
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
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
WordPress does not register a script with the handle jquery-ui by default, and it will skip printing the markup for any enqueued script for which it is unable to resolve all dependencies at the time of printing. So unless you or another extension is registering or enqueuing a script with the jquery-ui handle, your script … Read more
Why can’t you check loaded scripts in source code? All the scripts will be listed there, unless you minified them.
Here was the problem. I just didn’t add the <?php wp_footer(); ?> in my footer.php file. so simple but important. I guess woocommerce group should check if wp_footer() doesn’t exists add the scripts in header instead because I have wp_head() set up in my header.php
put these __initLivescore({“c1″:”F0F0F0″,”c2″:”BABCC3″,”c4″:”FFFFFF”,”c5″:”FFFFFF”,”c6″:”C90000″,”affiliate_id”:”0″,”menu”:”1″,”sportFK”:”1″,”odds”:”decimal”,”lang”:”3″,”timezone”:”AUTO”,”selected_tab”:”all”}); code in a js like demo.js file. and then use wp_enqueue_scripts and enqueue this file wp_enqueue_script( ‘script-name1’, ‘http://unibet-affiliate.enetscores.com/xjs/hour/theme/affiliate/361/client’); wp_enqueue_script( ‘script-name2’, plugin_dir_path( __FILE__ ) . ‘/demo.js’, array(), ‘1.0.0’, true );
Well, the add_action() should be add_action( string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1 ) You’ve got the tag and then you have an array. That array should just be a string of ‘admin_theme_style’. That should call the entire function. add_action() Simply try: add_action(‘admin_enqueue_scripts’, ‘admin_theme_style’);
I’m not sure you can use is_page() in the function.php (citation needed!). Instead of enqueuing the the style sheets, you could echo them in the header.php. So, in the header.php you’d want… <?php if ( is_front_page() ) { echo ‘<link rel=”stylesheet” type=”text/css” href=”‘ . get_template_directory_uri() . ‘/css/homepage.css”>’; } else if ( is_page( ‘corsi’ ) ) … Read more
You have to define the dependencies for either styles or scripts when you register them. Or, if you’re avoiding the registration completely, then it’s ok to stuff them into the queueing process. See more on the Codex page. wp_register_style( ‘reset’, get_template_directory_uri().’/reset.css’ ); wp_register_style( ‘style’, get_template_directory_uri().’/style.css’, array( ‘reset’ ) ); wp_enqueue_style( ‘style’ ); Also avoid single … Read more