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 very small wordpress plugin but I seem to be having
I'm writing a wordpress plugin but I can not set the page template manually
thanks for reading! Here's what I'm up to. I'm writing a WordPress plugin that
I'm writing a plugin but I have a problem. When Wordpress is displaying posts
Here's my problem: I'm writing a WordPress plugin that helps budding CSS authors see
I'm writing a wordpress widget plugin. It should output some html code which should
I am writing wordpress plugin. This plugin will create widgets based upon response of
I am writing a WordPress plugin that uses WP_HTTP for making an API call.
I am writing a wordpress plugin and want to add a meta_box for all
I am writing a wordpress plugin that redirects the user. for some reason, wp_redirect

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.