• Resolved ValerioCappelli

    (@valeriocappelli)


    Hi all,
    i have this code in my post:

    <body onload="detectmob()">
    <p><strong>scarica la musica</strong><p>
    <button onclick="detectmob()">Try it</button>
    <div id="textDiv">[sell_downloads columns=4]
    </div>
    </body>

    detectmob function is:

    function detectmob() {
     if( navigator.userAgent.match(/Android/i)
     || navigator.userAgent.match(/webOS/i)
     || navigator.userAgent.match(/iPhone/i)
     || navigator.userAgent.match(/iPad/i)
     || navigator.userAgent.match(/iPod/i)
     || navigator.userAgent.match(/BlackBerry/i)
     || navigator.userAgent.match(/Windows Phone/i)
     ){
    
    var div = document.getElementById("textDiv");
        div.textContent = "[sell_downloads columns=1]";
        return true;
      }
     else {
    
    var div = document.getElementById("textDiv");
        div.textContent = "[sell_downloads columns=4]";
    
        return false;
      }
    }

    But this code print the TEXT “[sell_downloads columns=4]” and not change text in shortcode.

    How i can add different shortcode in javascript code?

    I need this because my responsive theme is so bad!

    Thank you so much for help..

    Valerio

    https://www.ads-software.com/plugins/sell-downloads/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author codepeople

    (@codepeople)

    Hi Valerio,

    The shortcodes are replaced in the server side and not in the browser, so you cannot check the shortcode with javascript. Please, test the following customization:

    1. Open the “/wp-content/plugins/sell-downloads/sell-downloads.php” file with the text editor your choice.

    2. Go to the line of code:

    function load_store_product_list($atts){

    and modify it like follow:

    function load_store_product_list($atts){
    $useragent=$_SERVER['HTTP_USER_AGENT'];
    if ( preg_match( '/android|webos|iphone|ipad|ipod|blackberry|windows phone/i', $useragent ) ) $atts[ 'columns' ] = 1;

    and that’s all
    Best regards.

    Thread Starter ValerioCappelli

    (@valeriocappelli)

    Thank you so much!

    Thread Starter ValerioCappelli

    (@valeriocappelli)

    Emh… i’m sorry but in latest new versione of sell download i not found this row:

    function load_store_product_list($atts){

    Are u sure i can find too in free versione of sell download?

    Thank you again!

    Plugin Author codepeople

    (@codepeople)

    Hi,

    I’m sorry, my fault, the correct function to edit is:

    function load_store($atts){

    and the code would be:

    function load_store($atts){
    $useragent=$_SERVER['HTTP_USER_AGENT'];
    if ( preg_match( '/android|webos|iphone|ipad|ipod|blackberry|windows phone/i', $useragent ) ) $atts[ 'columns' ] = 1;

    Best regards.

    Thread Starter ValerioCappelli

    (@valeriocappelli)

    Find and work!
    The name exactly:

    function load_store($atts, $content, $tag){

    Can you help me with:

    https://www.ads-software.com/support/topic/streaming-audio-on-list-of-element?replies=2

    Thank you!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Shortcode – Javascript’ is closed to new replies.