WC_GZD_Trusted_Shops_Template_Hooks

The WooCommerce Germanized WC GZD Trusted Shops Template Hooks class.

Defined (1)

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

/includes/trusted-shops/class-wc-gzd-trusted-shops-template-hooks.php  
  1. class WC_GZD_Trusted_Shops_Template_Hooks { 
  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.  
  14. $this->base = $base; 
  15.  
  16. // Template actions 
  17. if ( $this->base->is_enabled() ) 
  18. add_action( 'after_setup_theme', array( $this, 'template_hooks' ), 13 ); 
  19.  
  20. if ( $this->base->is_product_reviews_enabled() ) { 
  21. add_filter( 'woocommerce_product_tabs', array( $this, 'remove_review_tab' ), 40, 1 ); 
  22.  
  23. if ( $this->base->is_product_sticker_enabled() ) { 
  24. add_filter( 'woocommerce_product_tabs', array( $this, 'review_tab' ), 50, 1 ); 
  25.  
  26. if ( $this->base->is_product_widget_enabled() ) { 
  27. add_filter( 'woocommerce_gzd_template_name', array( $this, 'set_product_widget_template' ), 50, 1 ); 
  28.  
  29.  
  30. public function template_hooks() { 
  31.  
  32. add_action( 'woocommerce_thankyou', array( $this, 'template_thankyou' ), 10, 1 ); 
  33. add_action( 'wp_footer', array( $this, 'template_trustbadge' ), PHP_INT_MAX ); 
  34.  
  35.  
  36. public function set_product_widget_template( $template ) { 
  37.  
  38. if ( in_array( $template, array( 'single-product/rating.php' ) ) ) 
  39. $template = 'trusted-shops/product-widget.php'; 
  40.  
  41. return $template; 
  42.  
  43.  
  44. public function remove_review_tab( $tabs ) { 
  45.  
  46. if ( isset( $tabs[ 'reviews' ] ) ) 
  47. unset( $tabs[ 'reviews' ] ); 
  48. return $tabs; 
  49.  
  50.  
  51. public function review_tab( $tabs ) { 
  52. $tabs[ 'trusted_shops_reviews' ] = array( 
  53. 'title' => _x( 'Reviews', 'trusted-shops', 'woocommerce-germanized' ),  
  54. 'priority' => 30,  
  55. 'callback' => array( $this, 'template_product_sticker' ),  
  56. ); 
  57. return $tabs; 
  58.  
  59. public function template_product_sticker( $template ) { 
  60. wc_get_template( 'trusted-shops/product-sticker.php' ); 
  61.  
  62. public function template_trustbadge() { 
  63. wc_get_template( 'trusted-shops/trustbadge.php' ); 
  64.  
  65. public function template_thankyou( $order_id ) { 
  66. wc_get_template( 'trusted-shops/thankyou.php', array(  
  67. 'order_id' => $order_id,  
  68. 'gtin_attribute' => $this->base->gtin_attribute,  
  69. 'brand_attribute' => $this->base->brand_attribute,  
  70. 'mpn_attribute' => $this->base->mpn_attribute,  
  71. ) ); 
  72.