Best spot for wp_register_script() and wp_register_style()

Scripts and styles can be registered on the wp_loaded hook and then later enqueued using wp_enqueue_scripts. Once the scripts and styles have been registered, they can be enqueued later using just the handles that they were originally registered with. // Register scripts/styles. They can be optionally enqueued later on. add_action( ‘wp_loaded’, ‘wpse_register_scripts’ ); function wpse_register_scripts() … Read more

How can I load script and style in specific page in the back-end?

So simple I will explain it step by step: First, use the $hook variable that is WordPress default like this: function the_themescripts($hook) { echo $hook; } add_action( ‘admin_enqueue_scripts’, ‘dr_theme_options_style_scripts’ ); Now go to custom page in your admin WP Dashboard and at the top you will see something like toplevel_page_your_theme_page_slug if it does not visible … Read more

Enqueue script on specific WooCommerce template

You need to delay the firing of your code, otherwise your conditionals will evaluate false (the request won’t have been parsed yet). Use the action wp_enqueue_scripts: function wpse_182357_enqueue_scripts() { // Your code } add_action( ‘wp_enqueue_scripts’, ‘wpse_182357_enqueue_scripts’ ); Update: Missed the root of the problem – is_page_template() only works for pages. Rather than checking if the … Read more

Add last modified time as version to css and js

You could use add_query_arg() but then you’d have to parse the uri everytime, I’d rather create a wrapper function for wp_enqueue_script/style: function my_enqueuer($my_handle, $relpath, $type=”script”, $my_deps=array()) { $uri = get_theme_file_uri($relpath); $vsn = filemtime(get_theme_file_path($relpath)); if($type == ‘script’) wp_enqueue_script($my_handle, $uri, $my_deps, $vsn); else if($type == ‘style’) wp_enqueue_style($my_handle, $uri, $my_deps, $vsn); } Add this in your functions file … Read more

Enqueued scripts and styles loading in WordPress Dashboard as well

The “init” action runs both on frontend page loads, and on backend page loads. Try hooking these to the “wp_enqueue_scripts” action instead. I believe it does not run on admin page loads. Example Code: (By OP) function wpse54388_scripts_styles() { wp_enqueue_style( … ); wp_enqueue_script( … ); } add_action( ‘wp_enqueue_scripts’, ‘wpse54388_scripts_styles’ );

How to remove some external js files from source?

You can use wp_dequeue_script to achieve this assuming they are using wp_enqueue_script to add the scripts in the first place. Learn more about enquene and dequeue: https://developer.wordpress.org/reference/functions/wp_enqueue_script/ https://codex.wordpress.org/Function_Reference/wp_dequeue_script function dequeue_script() { wp_dequeue_script( ‘http://buhehe.de/wp-content/themes/heatt/js/small-menu.js?ver=4.9.1’ ); wp_dequeue_script( ‘http://buhehe.de/wp-includes/js/wp-embed.min.js?ver=4.9.1’ ); } add_action( ‘wp_print_scripts’, ‘dequeue_script’, 100 );

Enqueue scripts to footer

Like this:- function dequeue_my_scripts() { wp_dequeue_script(‘dgx_donate_paypalstd_script’); wp_dequeue_script(‘next-handle-script’); wp_dequeue_script(‘next-handle-script-2’); /* and so on*/ } add_action( ‘wp_print_scripts’, ‘dequeue_my_scripts’, 11 ); function enqueue_scripts_to_footer() { wp_enqueue_script(‘dgx_donate_paypalstd_script’); wp_enqueue_script(‘next-handle-script’); wp_enqueue_script(‘next-handle-script-2’); /* and so on */ } add_action( ‘wp_footer’, ‘enqueue_scripts_to_footer’ ); What’s wrong in this implementation? EDIT: I would also like to notify you that this is the correct implementation of what … Read more

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