WC_GZD_Trusted_Shops_Shortcodes

The WooCommerce Germanized WC GZD Trusted Shops Shortcodes class.

Defined (1)

The class is defined in the following location(s).

/includes/trusted-shops/class-wc-gzd-trusted-shops-shortcodes.php  
  1. class WC_GZD_Trusted_Shops_Shortcodes { 
  2.  
  3. protected static $_instance = null; 
  4.  
  5. public $base = null; 
  6.  
  7. public static function instance( $base ) { 
  8. if ( is_null( self::$_instance ) ) 
  9. self::$_instance = new self( $base ); 
  10. return self::$_instance; 
  11.  
  12. private function __construct( $base ) { 
  13. $this->base = $base; 
  14.  
  15. add_action( 'init', array( $this, 'init' ), 3 ); 
  16.  
  17. public function init() { 
  18.  
  19. // Define shortcodes 
  20. $shortcodes = array( 
  21. 'trusted_shops_rich_snippets'=> array( $this, 'trusted_shops_rich_snippets' ),  
  22. 'trusted_shops_reviews' => array( $this, 'trusted_shops_reviews' ),  
  23. 'trusted_shops_badge' => array( $this, 'trusted_shops_badge' ),  
  24. ); 
  25.  
  26. foreach ( $shortcodes as $shortcode => $function ) { 
  27. add_shortcode( apply_filters( "{$shortcode}_shortcode_tag", $shortcode ), $function ); 
  28.  
  29.  
  30. /** 
  31. * Returns Trusted Shops rich snippet review html 
  32. *  
  33. * @param array $atts  
  34. * @return string  
  35. */ 
  36. public function trusted_shops_rich_snippets( $atts ) { 
  37.  
  38. ob_start(); 
  39. wc_get_template( 'trusted-shops/rich-snippets.php', array( 'rating' => $this->base->get_average_rating(), 'rating_link' => $this->base->get_rating_link() ) ); 
  40. $html = ob_get_clean(); 
  41. return $this->base->is_enabled() ? '<div class="woocommerce woocommerce-gzd">' . $html . '</div>' : ''; 
  42.  
  43.  
  44. /** 
  45. * Returns Trusted Shops reviews graphic 
  46. *  
  47. * @param array $atts  
  48. * @return string  
  49. */ 
  50. public function trusted_shops_reviews( $atts ) { 
  51.  
  52. ob_start(); 
  53. wc_get_template( 'trusted-shops/reviews.php', array( 'rating_link' => $this->base->get_rating_link(), 'widget_attachment' => $this->base->get_review_widget_attachment() ) ); 
  54. $html = ob_get_clean(); 
  55. return $this->base->is_enabled() ? '<div class="woocommerce woocommerce-gzd">' . $html . '</div>' : ''; 
  56.  
  57.  
  58. /** 
  59. * Returns Trusted Shops Badge html 
  60. *  
  61. * @param array $atts  
  62. * @return string  
  63. */ 
  64. public function trusted_shops_badge( $atts ) { 
  65.  
  66. extract( shortcode_atts( array('width' => ''), $atts ) ); 
  67. return $this->base->is_enabled() ? '<a class="trusted-shops-badge" style="' . ( $width ? 'background-size:' . ( $width - 1 ) . 'px auto; width: ' . $width . 'px; height: ' . $width . 'px;' : '' ) . '" href="' . $this->base->get_certificate_link() . '" target="_blank"></a>' : ''; 
  68.  
  69.