Customs widgets


#1

hello all!

I’ve recently updated the theme - fashionistas

I previously used a code in my functions.php - which enabled me to display cookbooks and fashion applications but no longer works since updating.

I’ve tried copying and pasting the code back into functions.php, but it doesn’t work and i’m greeted with the lovely white page of death.

code needed shown below:

<div class="moneyspot-widget" data-widget-id="'.$id.'">
                <script type="text/javascript" language="javascript">
                    !function(d,s,id){
                        var e, p = /^http:/.test(d.location) ? \'http\' : \'https\';
                        if(!d.getElementById(id)) {
                            e     = d.createElement(s);
                            e.id  = id;
                            e.src = p + \'://d27mzdfpkg2pgg.cloudfront.net/js/widget.js\';
                            d.body.appendChild(e);
                        }
                        if(typeof(window.__moneyspot) === \'object\') {
                            if(document.readyState === \'complete\') {
                                window.__moneyspot.init();
                            }
                        }
                    }(document, \'script\', \'moneyspot-script\');
                </script>
                <div class="rs-adblock">
                    <img src="//d2q5ul2d7qoxgj.cloudfront.net/img?v=2.11&ms='.$id.'&aspect" onerror="this.parentNode.innerHTML=\'Turn off your ad blocker to view content\'" />
                    <noscript>'.$enableJs.'</noscript>
                </div>
            </div>';

    return $out;
}
add_shortcode('show_ms_widget', 'ms_show_widget');

function ltk_show_widget($atts) {
    extract(shortcode_atts(array(
        'user_id'    => '0',
        'rows'       => '1',
        'cols'       => '6',
        'show_frame' => 'true',
        'padding'    => '0'
    ), $atts));

    $out = '<div class="ltkwidget-widget" data-rows="'.$rows.'" data-cols="'.$cols.'" data-show-frame="'.$show_frame.'" data-user-id="'.$user_id.'" data-padding="'.$padding.'">
                <script type="text/javascript" language="javascript">
                    !function(d,s,id){
                        var e, p = /^http:/.test(d.location) ? \'http\' : \'https\';
                        if(!d.getElementById(id)) {
                            e     = d.createElement(s);
                            e.id  = id;
                            e.src = p + \'://d27mzdfpkg2pgg.cloudfront.net/js/ltkwidget.js\';
                            d.body.appendChild(e);
                        }
                    }(document, \'script\', \'ltkwidget-script\');
                    if(typeof(window.__ltkwidget) === \'object\'){
                        if (document.readyState === \'complete\') {
                            __ltkwidget.init();
                        }
                    }
                </script>
                <div class="rs-adblock">
                    <img src="//d32uzqjr78xvi4.cloudfront.net/images/search/350.gif" onerror="this.parentNode.innerHTML=\'Turn off your ad blocker to view content\'" />
                    <noscript>Turn on your JavaScript to view content</noscript>
                </div>
            </div>';
    return $out;
}
add_shortcode('show_ltk_widget', 'ltk_show_widget');

function lookbook_show_widget($atts) {
    extract(shortcode_atts(array(
        'id'    => '0',
        'adblock'  => 'Turn off your ad blocker to view content',
        'enableJs' => 'Turn on your JavaScript to view content'
    ), $atts));

    $out = '<div class="lookbook-widget" data-widget-id="'.$id.'">
                <script type="text/javascript" language="javascript">
                    !function(d,s,id){
                        var e, p = /^http:/.test(d.location) ? \'http\' : \'https\';
                        if(!d.getElementById(id)) {
                            e     = d.createElement(s);
                            e.id  = id;
                            e.src = p + \'://d27mzdfpkg2pgg.cloudfront.net/js/lookbook.js\';
                            d.body.appendChild(e);
                        }
                        if(typeof(window.__lookbook) === \'object\') if(d.readyState === \'complete\') {
                            window.__lookbook.init();
                        }
                    }(document, \'script\', \'lookbook-script\');
                </script>
                <div class="rs-adblock">
                    <img src="//d32uzqjr78xvi4.cloudfront.net/images/search/350.gif" style="width:15px;height:15px;" onerror="this.parentNode.innerHTML=\''.$enableJs.'\'" />
                    <noscript>'.$adblock.'</noscript>
                </div>
            </div>';
    return $out;
}
add_shortcode('show_lookbook_widget', 'lookbook_show_widget');

function shopthepost_show_widget($atts) {
    extract(shortcode_atts(array(
        'id'    => '0',
        'adblock'  => 'Turn off your ad blocker to view content',
        'enableJs' => 'Turn on your JavaScript to view content'
    ), $atts));

    $out = '<div class="shopthepost-widget" data-widget-id="'.$id.'">
                <script type="text/javascript" language="javascript">
                    !function(d,s,id){
                        var e, p = /^http:/.test(d.location) ? \'http\' : \'https\';
                        if(!d.getElementById(id)) {
                            e     = d.createElement(s);
                            e.id  = id;
                            e.src = p + \'://d27mzdfpkg2pgg.cloudfront.net/js/shopthepost.js\';
                            d.body.appendChild(e);
                        }
                        if(typeof window.__stp === \'object\') if(d.readyState === \'complete\') {
                            window.__stp.init();
                        }
                    }(document, \'script\', \'shopthepost-script\');
                </script>
                <div class="rs-adblock">
                    <img src="//d32uzqjr78xvi4.cloudfront.net/images/search/350.gif" style="width:15px;height:15px;" onerror="this.parentNode.innerHTML=\''.$enableJs.'\'" />
                    <noscript>'.$adblock.'</noscript>
                </div>
            </div>';
    return $out;
}
add_shortcode('show_shopthepost_widget', 'shopthepost_show_widget');

function boutique_show_widget($atts) {
    extract(shortcode_atts(array(
        'id'    => '0',
        'adblock'  => 'Turn off your ad blocker to view content',
        'enableJs' => 'Turn on your JavaScript to view content'
    ), $atts));

    $out = '<div class="boutique-widget" data-widget-id="'.$id.'">
                <script type="text/javascript" language="javascript">
                    !function(d,s,id){
                        var e, p = /^http:/.test(d.location) ? \'http\' : \'https\';
                        if(!d.getElementById(id)) {
                            e     = d.createElement(s);
                            e.id  = id;
                            e.src = p + \'://d27mzdfpkg2pgg.cloudfront.net/js/boutique.js\';
                            d.body.appendChild(e);
                        }
                        if(typeof window.__boutique === \'object\') if(d.readyState === \'complete\') {
                            window.__boutique.init();
                        }
                    }(document, \'script\', \'boutique-script\');
                </script>
                <div class="rs-adblock">
                    <img src="//d32uzqjr78xvi4.cloudfront.net/images/search/350.gif" style="width:15px;height:15px;" onerror="this.parentNode.innerHTML=\''.$enableJs.'\'" />
                    <noscript>'.$adblock.'</noscript>
                </div>
            </div>';
    return $out;
}
add_shortcode('show_boutique_widget', 'boutique_show_widget');

add_filter('widget_text', 'do_shortcode');
add_filter('the_excerpt', 'do_shortcode');

?>

Please can anyone help me how I can get the custom widget code to work and display my images correctly.

website is: www.youprobablylike.com

Many thanks


#2

Hi

I am sorry to know that you lost the changes on the update, but to avoid that in future I would suggest you to make changes on a Child theme.

I also looked into the site and saw some widgets already and didn’t really see the white screen of death.

The code you have provided is not formatted well so can’t give it a close look but below are my finding from a screening:–

– You need to start the function ms_show_widget before using it as a shortcode, seems you have missed staring the function here where as other shortcodes seem right.

– Please check if these short codes has other dependencies like a third party plugin, or a jquery library and if yes please check for those.

Please let us know if this work

If you are looking for some customizations made for you, you can always tell us about it here https://athemes.com/wordpress-customization/

Thanks