How to enable enqueue_script to work with a logged in user?

Additionally, apart from the “where” of your wp_enqueue_script() function (i.e. theme, plugin, etc.), the “when” is also important, in terms of WP’s Action Reference hooks, and the order in which they’re fired. There are 2 distinct script-related hooks, wp_enqueue_scripts and admin_enqueue_scripts, which allow for separation of scripts and styles depending on which view the user … Read more

What are the advantages of using wp_enqueue_script()

How about API? Let’s Check this example. $id = ‘plugin-id’; $syffix = ( ( defined( ‘SCRIPT_DEBUG’ ) && SCRIPT_DEBUG ) ? ” : ‘.min’ ); $script_url = plugins_url( ‘js/’ .$id . $suffix . ‘.js’, __FILE__ ); $dependencies = array( ‘jquery’, ‘underscore’ ); wp_register_script( $id, $script_url, $dependencies, $version, true ); wp_localize_script( $id, ‘pluginJSL10nData’, array( ‘home’ => … Read more

wp_enqueue_scripts hook is not being called

Your code is correct, though I would not add the callback if the function name has already been used. If someone else has used the name you don’t know what you might be adding. if(!function_exists(‘bi_frontend_scripts’)) { function bi_frontend_scripts() { wp_enqueue_script(‘jquery’); // I originally wanted to do: wp_enqueue_script(‘jQuery.bxSlider’, get_bloginfo(‘template_url’).’/scripts/jquery.bxslider/jquery.bxslider.min.js’, array(‘jquery’)); } add_action(‘wp_enqueue_scripts’, ‘bi_frontend_scripts’); } I also … Read more

is_page() function doesnt working

The init hook is too early — WordPress hasn’t yet identified the queried object (post, category, etc.); hence the is_page() doesn’t work there: add_action(‘init’, ‘register_script’); So for conditional tags/functions like is_page(), is_single(), etc. to work (i.e. return the proper result), you should use wp or a later hook: add_action(‘wp’, ‘whatever_function’); But for registering/enqueueing scripts and … Read more

wp_ajax() question.. not using wp_enqueue_script?

Ok, firstly let me just break it down a little, so you understand the purpose of these functions. wp_enqueue_script() Description: A safe way of adding javascripts to a WordPress generated page. Basically, include the script if it hasn’t already been included, and load the one that WordPress ships. wp_localize_script() Description: Localizes a script, but only … Read more

Adding wp_enqueue_media(); causes problem

There’s not enough information to really determine what is happening, but the best course of action is to make sure your code is only added to the options page, so it can’t interfere with anything on the edit page. You can use get_current_screen for that, like this: add_action( ‘current_screen’, ‘wpse113256_this_screen’ ); function wpse113256_this_screen() { $current_screen … Read more

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