Plugin Directory

Changeset 1728010


Ignore:
Timestamp:
09/11/2017 11:27:23 AM (9 years ago)
Author:
bappa1995
Message:

change shortcode function

Location:
wc-qr-codes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • wc-qr-codes/tags/1.0.5/includes/class-wc-qr-codes-shortcodes.php

    r1727953 r1728010  
    2323
    2424    public static function wc_qr_code($atts) {
     25        global $product;
    2526        $default = array(
    2627            'id' => '',
     
    2829        );
    2930        $atts = shortcode_atts($default, $atts, 'wc_qr_code');
    30         $product = wc_get_product($atts['id']);
     31        $product_obj = wc_get_product($atts['id']) ? wc_get_product($atts['id']) : $product;
    3132        if($atts['title']){
    3233            echo '<h2 class="wc-qr-codes-h2">'.$atts['title'].'</h2>';
    3334        }
    34         if ($product && get_wc_product_qr_code_src($product->get_id())) {
     35        if ($product && get_wc_product_qr_code_src($product_obj->get_id())) {
    3536            echo '<div class="wc-qr-codes-container">';
    36             echo '<img class="wcqrc-qr-code-img" src="' . get_wc_product_qr_code_src($product->get_id()) . '" alt="QR Code" />';
     37            echo '<img class="wcqrc-qr-code-img" src="' . get_wc_product_qr_code_src($product_obj->get_id()) . '" alt="QR Code" />';
    3738            echo '</div>';
    3839        }
  • wc-qr-codes/trunk/includes/class-wc-qr-codes-shortcodes.php

    r1727953 r1728010  
    2323
    2424    public static function wc_qr_code($atts) {
     25        global $product;
    2526        $default = array(
    2627            'id' => '',
     
    2829        );
    2930        $atts = shortcode_atts($default, $atts, 'wc_qr_code');
    30         $product = wc_get_product($atts['id']);
     31        $product_obj = wc_get_product($atts['id']) ? wc_get_product($atts['id']) : $product;
    3132        if($atts['title']){
    3233            echo '<h2 class="wc-qr-codes-h2">'.$atts['title'].'</h2>';
    3334        }
    34         if ($product && get_wc_product_qr_code_src($product->get_id())) {
     35        if ($product && get_wc_product_qr_code_src($product_obj->get_id())) {
    3536            echo '<div class="wc-qr-codes-container">';
    36             echo '<img class="wcqrc-qr-code-img" src="' . get_wc_product_qr_code_src($product->get_id()) . '" alt="QR Code" />';
     37            echo '<img class="wcqrc-qr-code-img" src="' . get_wc_product_qr_code_src($product_obj->get_id()) . '" alt="QR Code" />';
    3738            echo '</div>';
    3839        }
Note: See TracChangeset for help on using the changeset viewer.