| @@ -22,8 +22,9 @@ | ||
| 22 | 22 | |
| 23 | 23 | add_action( 'get_header', [ $this, 'get_header' ], 0 ); |
| 24 | 24 | add_action( 'get_footer', [ $this, 'get_footer' ], 0 ); |
| 25 | 25 | add_action( 'elementor/document/wrapper_attributes', [ $this, 'wrapper_attributes' ], 10, 2 ); |
| 26 | + add_action( 'template_redirect', array( $this, 'set_global_product' ) ); | |
| 26 | 27 | |
| 27 | 28 | /** |
| 28 | 29 | * Only for Development Mode. |
| 29 | 30 | */ |
| @@ -41,9 +42,9 @@ | ||
| 41 | 42 | echo '<small>Footer</small>'; |
| 42 | 43 | } |
| 43 | 44 | |
| 44 | 45 | public function get_header() { |
| 45 | - if(!$this->is_header_footer()){ | |
| 46 | + if(!self::is_header_footer('header')){ | |
| 46 | 47 | return; |
| 47 | 48 | } |
| 48 | 49 | $this->views->get_header(); |
| 49 | 50 | |
| @@ -57,9 +58,9 @@ | ||
| 57 | 58 | ob_get_clean(); |
| 58 | 59 | } |
| 59 | 60 | |
| 60 | 61 | public function get_footer( $name ) { |
| 61 | - if(!$this->is_header_footer()){ | |
| 62 | + if(!self::is_header_footer('footer')){ | |
| 62 | 63 | return; |
| 63 | 64 | } |
| 64 | 65 | $this->views->get_footer(); |
| 65 | 66 | |
| @@ -77,9 +78,9 @@ | ||
| 77 | 78 | locate_template( $templates, true ); |
| 78 | 79 | ob_get_clean(); |
| 79 | 80 | } |
| 80 | 81 | |
| 81 | - public function is_header_footer(){ | |
| 82 | + public static function is_header_footer($type = null){ | |
| 82 | 83 | if(class_exists( 'Elementor\Plugin' )){ |
| 83 | 84 | $pid = get_the_ID(); |
| 84 | 85 | $post_type = get_post_type($pid); |
| 85 | 86 | $document = Plugin::$instance->documents->get( $pid ); |
| @@ -96,8 +97,15 @@ | ||
| 96 | 97 | |
| 97 | 98 | $header = templately()->theme_builder::$conditions_manager->get_templates_by_location( 'header' ); |
| 98 | 99 | $footer = templately()->theme_builder::$conditions_manager->get_templates_by_location( 'footer' ); |
| 99 | 100 | |
| 101 | + if($type === 'header'){ | |
| 102 | + return $header; | |
| 103 | + } | |
| 104 | + else if($type === 'footer'){ | |
| 105 | + return $footer; | |
| 106 | + } | |
| 107 | + | |
| 100 | 108 | if(!empty($header) || !empty($footer)){ |
| 101 | 109 | return true; |
| 102 | 110 | } |
| 103 | 111 | return false; |
| @@ -117,7 +125,18 @@ | ||
| 117 | 125 | } |
| 118 | 126 | } |
| 119 | 127 | |
| 120 | 128 | return $attributes; |
| 129 | + } | |
| 130 | + | |
| 131 | + public function set_global_product(){ | |
| 132 | + global $product; | |
| 133 | + | |
| 134 | + if ( class_exists('\WC_Product') && ! $product instanceof \WC_Product ) { | |
| 135 | + $product_id = get_the_ID(); | |
| 136 | + if ( $product_id ) { | |
| 137 | + wc_setup_product_data( $product_id ); | |
| 138 | + } | |
| 139 | + } | |
| 121 | 140 | } |
| 122 | 141 | |
| 123 | 142 | } |