Using wp_enqueue_script in a wordpress plugin

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 );

wp_enqueue_scripts hangs

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

wp_enqueue doesn’t load dependencies

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

Enqueueing Script to footer puts it at the very bottom

You want something like this. // assuming you want to load this only on frontend if ( ! is_admin() ) add_action( ‘wp_enqueue_scripts’, ‘wpse_112876_load_scripts’ ); function wpse_112876_load_scripts() { wp_enqueue_script( ‘my_foundation’, get_template_directory_uri() . ‘/js/foundation.min.js’, null, ‘4.3.3’, true ); wp_enqueue_script( ‘my_foundation_init’, get_template_directory_uri() . ‘/js/foundation_init.js’, array( ‘my_foundation’ ), null, true ); }

css3-mediaqueries-js failing with child theme

The author of css3-mediaqueries-js states the following via https://github.com/livingston/css3-mediaqueries-js: Note: Doesn’t work on @import’ed stylesheets (which you shouldn’t use anyway for performance reasons). Also won’t listen to the media attribute of the `<link>` and `<style>` elements. style.css via my child theme uses @import to bring across the parent theme stylesheet. To overcome the problem, I … Read more

Generating embed code for users to share

Try following code. This will display embed code in the bottom of the page. <?php add_filter(‘the_content’,’my_custom_embed_code’); function my_custom_embed_code( $content ){ global $post; if ( ‘page’ == $post->post_type ) { $embed_code=””; $page_url = esc_url( get_permalink($post->ID ) ) ; $embed_code .= ‘<object data=”https://wordpress.stackexchange.com/questions/160604/.$page_url.” width=”100%” height=”500″><embed src=”https://wordpress.stackexchange.com/questions/160604/.$page_url.” width=”100%” height=”500″></embed> Error: Embedded data could not be displayed. Visit <a … Read more

Loop through arguments of a function

wp_enqueue_script states the parameters type respectively as string – string – array – string – boolean. As you pass an array as the second parameter, the error occurs. Now, comparing your $array data, you can handle it extracting the array or using array key/value. – public function loadScripts() { $themeScripts = iarray( ‘custom’ => array( … Read more