plugins_url function mixes system path and URL

Short Answer jquery-ui.widget is one of standard scripts already included and registered in WP. You don’t need to register it, just enqueue. In your code what is wrong is the dirname function inside plugin_url. Leave only __FILE__ as second argument of plugins_url Long Answer: More Info jquery-ui.widget is one of standard wordpress scripts so, in … Read more

Where does WordPress register default scripts like jQuery?

WordPress registers jQuery in the wp_default_scripts() function, which is found in wp-includes/script-loader.php. // jQuery $scripts->add( ‘jquery’, false, array( ‘jquery-core’, ‘jquery-migrate’ ), ‘1.11.3’ ); $scripts->add( ‘jquery-core’, ‘/wp-includes/js/jquery/jquery.js’, array(), ‘1.11.3’ ); $scripts->add( ‘jquery-migrate’, “/wp-includes/js/jquery/jquery-migrate$suffix.js”, array(), ‘1.2.1’ );

How to cancel `wp_print_scripts`?

There is a way, but it’s not recommended since there might be some other inline scripts attached to the enqueued scripts. You can hook to the wp_enqueue_scripts action and empty the global $wp_scripts as follows: add_action( ‘wp_enqueue_scripts’, ‘remove_all_scripts’, 1000 ); function remove_all_scripts() { global $wp_scripts; $wp_scripts->queue = array(); } You can then run a loop … Read more

WP .js script file not loading

According to codex, get_stylesheet_directory_uri() does not including a trailing slash. So, you might want to use it in the following way: function wpb_adding_scripts() { wp_register_script(‘my_scripts’, get_stylesheet_directory_uri().’/js/scripts.js’, array(‘jquery’),’1.1′, true); wp_enqueue_script(‘my_scripts’); } add_action( ‘wp_enqueue_scripts’, ‘wpb_adding_scripts’ ); UPDATE If you want to use jQuery in your scripts, you should do it in one of these ways: Use jQuery … Read more

Modernizr check first, then move on to wp_register_script()/wp_enqueue_script

Please check the example of Alex Hempton-Smith, maybe its help you. <?php function urls_of_enqueued_scrips( $handles = array() ) { global $wp_scripts, $wp_styles; foreach ( $wp_scripts->registered as $registered ) $script_urls[ $registered->handle ] = $registered->src; foreach ( $wp_styles->registered as $registered ) $style_urls[ $registered->handle ] = $registered->src; if ( empty( $handles ) ) { $handles = array_merge( $wp_scripts->queue, … 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