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

How to enqueue a style using wp_enqueue_scripts()?

The second parameter of wp_enqueue_style() is an optional path.You are passing an empty array, which will enqueue nothing. get_template_directory_uri() retrieves the current theme’s root URI, which you can use in wp_enqueue_style(): add_action(‘wp_enqueue_scripts’,’homepage’); function homepage(){ if ( is_page_template(‘page-home.php’) ) { wp_enqueue_style(‘home-css’, get_template_directory_uri() . ‘/css/flags.min.css’, ‘1.0.0’, true ); } } I mentioned “Optional”, since there is also … Read more

Passing arguments to my function with do_action and add_action is not working

You are doing the do_action before the action is add, try moving it: $name = “link”; add_shortcode($name, ‘aa_link_shortcode’); function shorcode_resources($var1) { global $post; $shortcode_found = false; if (has_shortcode($post->post_content, $var1)) { $shortcode_found = true; } if ($shortcode_found) { wp_enqueue_style(‘core’, ABS_URL . ‘/shortcode/css/flipbox.css’, false); wp_enqueue_script(‘my-js’, ABS_URL . ‘/shortcode/js/flipbox(‘ . $var1 . ‘).js’, false); } } //first we … Read more

Enqueue script dinamically

There’s a fundamental misunderstanding of what AJAX does. You cannot enqueue scripts directly from the PHP called from the javascript. You need to print something that can be used by the javascript making the AJAX call. You can then use javascript to add that file to the DOM. functions.php //* Enqueue Ajax call on wp_enqueue_scripts … Read more

wp_enqueue_script add integrity parameter

You will have to generate your own tag after the script is enqueued. Below, it’s looking for the fontawesome handle (the one you’re using to enqueue the script) before returning the custom tag. add_filter( ‘script_loader_tag’, ‘my_scripts_modifier’, 10, 3 ); function my_scripts_modifier( $tag, $handle, $src ) { if ( ‘fontawesome’ === $handle ) { return ‘<script … 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

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