Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1051723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:58:52+00:00 2026-05-16T16:58:52+00:00

I am writing a plugin for WordPress but I can’t seem to get my

  • 0

I am writing a plugin for WordPress but I can’t seem to get my flag going. It is driving me nuts! Here’s the code without the class wrapper:

static $js_flag;

function init() 
{
    add_shortcode('jw_html5', array(__CLASS__, 'jw_html5_shortcode'));
    add_action('init', array(__CLASS__, 'jw_add_js' ));
}

public function jw_html5_shortcode( $atts, $content = null ) 
{

    self::$js_flag = true;
    $vid = '';

    extract( shortcode_atts( array(
        'src' => '/vids/video.mp4',
        'width' => 480,
        'height' => 320
        ), $atts ) );

    $vid = "<video id='player' src='$src' width='$width' height='$height' type='video/mp4'> </video>";

    return self::$js_flag;
    //return $vid;
}


public function jw_add_js()
{


    if(self::$js_flag)
    {
        wp_register_script('jw_player', plugins_url('scripts/player.php', __FILE__), array('jquery'), '.01', true);
        wp_register_script('jw_player_script', plugins_url('scripts/jquery.jwplayer.js', __FILE__), array('jquery'), '.01', false);
        wp_register_script('jw_playlist', plugins_url('scripts/jquery.playlist.js', __FILE__), array('jquery'), '.01', false);

        wp_enqueue_script('jw_player_script');
        wp_enqueue_script('jw_playlist');
        wp_enqueue_script('jquery');
        wp_enqueue_script('jw_player');
    }   


}

I’ve set the flag in the shortcode function but it’s not passing it to the jw_add_js() function. It’s sort of a bitch to debug in WP. Any advice would be super appreciated.

Update: I found the answer to this after messing around. I had to register my scripts and then store the handles in an array. I then pass the array with wp_print_scripts() method. Hope this will help someone!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T16:58:52+00:00Added an answer on May 16, 2026 at 4:58 pm

    I found the answer to this after messing around. I had to register my scripts and then store the handles in an array. I then pass the array with wp_print_scripts() method. Hope this will help someone!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a WordPress plugin that adds buttons to the tinymce editor in
So i'm writing a plugin for wordpress and one of the pages has information
context: im writing a favicon parser: http://plugins.trac.wordpress.org/browser/wp-favicons/trunk/includes/class-http.php and http://wp.leau.co/2011/03/18/handling-redirects-for-wp-favicons-with-redirects-set-to-0-with-wordpress-wp_remote_get/ I saw : http://www.foxfilm.nl/favicon.ico in
i'm writing a plugin for Eclipse and i would like to attach one of
I'm writing a plugin for FCKeditor that's meant to insert placeholders for dynamic content
I am writing a plugin using the standard authoring pattern for jQuery, using methods
I'm writing a plugin that makes use of the wp_mail function. However I want
I am writing a bunch of PHP classes which will be used to create
i've been searching for two hours looking for this specific questions, but still no
In the course of converting a blog from Blogger to WP and running a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.