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 7645243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:53:30+00:00 2026-05-31T09:53:30+00:00

I have a fairly simple problem for someone familiar with js. I quite like

  • 0

I have a fairly simple problem for someone familiar with js. I quite like the style of the audio player from: http://wpaudio.com/

I’ve taken this and have it mostly extracted to a rails project, however it turns out that the WordPress plugin creates a variable _wpaudio within php as follows:

## WPaudio style, jQuery, SWFObject
function wpaHead(){
    global $wpa_options;
    # Put all styles into the _wpaudio settings object
    $style = '';
    foreach ( $wpa_options as $key => $value ) {
        $exploded = explode('_', $key, 3);
        if ( $exploded[1] == 'style' ) {
            $style .= $exploded[2] . ":'$value',";
        }
    }
    $style = trim( $style, ',' );
    $style = '{' . $style . '}';
    # Common JS
    $wpa_pref_link_mp3 = ($wpa_options['wpa_pref_link_mp3']) ? 'true' : 'false';
    $head = "<script type='text/javascript'>/* <![CDATA[ */ var _wpaudio = {url: '" . WPAUDIO_URL . "', enc: {}, convert_mp3_links: $wpa_pref_link_mp3, style: $style}; /* ]]> */</script>";
    echo $head;
}

Obviously nearly ALL of that code is not pertinent, however it’s simply to illustrate that the _wpaudio var is created there. I don’t really care to have the paths built, etc. I simply want to be able to manipulate the script such that the var is created within the js file. I’ve tried a few different ways, but I’m so uninitiated in javascript that my attempts have been futile thus far.

Here’s the javascript which fails on load in the console with the Can't find variable: _wpaudio error:
https://gist.github.com/fd208d327484306d65a9

How do I modify the script so that it properly creates the _wpaudio at initialization?

  • 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-31T09:53:31+00:00Added an answer on May 31, 2026 at 9:53 am

    If you run a search for _wpaudio across the files of the wpaudio plugin folder, you will find this, at line 150 of wpaudio.php (yup, the one that appears in the snippet you provide):

    $head = "<script type='text/javascript'>/* <![CDATA[ */ var _wpaudio = {url: "[[path/to/wpaudio-mp3-player]]", enc: {}, convert_mp3_links: [[true|false]], style: {[[style]]} }; /* ]]> */</script>";
    

    This tells you that you are supposed to insert this script snippet somewhere in your html page. The $head means that the plugin will add it in the head part of the document (<head>…</head>). That could be as good a place as any. In any case, a _wpaudio variable should exist before the plugin is initialized, that script snippet should be inserted before you load wpaudio.js.

    <script type='text/javascript'> 
    /* <![CDATA[ */ 
      var _wpaudio = {
       url: "[[path/to/wpaudio-mp3-player]]", 
       enc: {}, 
       convert_mp3_links: [[true|false]], 
       style: {[[style formatting as a json object, empty object should work]]} }; 
     /* ]]> */
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am learning LINQ and this seems like a fairly simple problem. I have
I have a fairly simple problem. I am getting real-number input like 6.03 ,
I have a fairly simple web2py form with a few validators like, IS_FLOAT_IN_RANGE(...) on
I have a fairly simple cell in a table with an inline style: <td
I have a fairly simple Linq query (simplified code): dim x = From Product
I have a fairly simple math operation I'd like to perform on a array.
I have fairly simple problem but I can not think of the simple solution.
I have a fairly simple problem. I'm trying to make a function that accepts
I have a fairly simple problem. I have a select dropdown with values 1
I have a fairly simple regex problem for a little personal experiment that I

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.