| @@ -22,9 +22,8 @@ | ||
| 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' ) ); | |
| 27 | 26 | |
| 28 | 27 | /** |
| 29 | 28 | * Only for Development Mode. |
| 30 | 29 | */ |
| @@ -42,9 +41,9 @@ | ||
| 42 | 41 | echo '<small>Footer</small>'; |
| 43 | 42 | } |
| 44 | 43 | |
| 45 | 44 | public function get_header() { |
| 46 | - if(!self::is_header_footer('header')){ | |
| 45 | + if(!$this->is_header_footer()){ | |
| 47 | 46 | return; |
| 48 | 47 | } |
| 49 | 48 | $this->views->get_header(); |
| 50 | 49 | |
| @@ -58,9 +57,9 @@ | ||
| 58 | 57 | ob_get_clean(); |
| 59 | 58 | } |
| 60 | 59 | |
| 61 | 60 | public function get_footer( $name ) { |
| 62 | - if(!self::is_header_footer('footer')){ | |
| 61 | + if(!$this->is_header_footer()){ | |
| 63 | 62 | return; |
| 64 | 63 | } |
| 65 | 64 | $this->views->get_footer(); |
| 66 | 65 | |
| @@ -78,9 +77,9 @@ | ||
| 78 | 77 | locate_template( $templates, true ); |
| 79 | 78 | ob_get_clean(); |
| 80 | 79 | } |
| 81 | 80 | |
| 82 | - public static function is_header_footer($type = null){ | |
| 81 | + public function is_header_footer(){ | |
| 83 | 82 | if(class_exists( 'Elementor\Plugin' )){ |
| 84 | 83 | $pid = get_the_ID(); |
| 85 | 84 | $post_type = get_post_type($pid); |
| 86 | 85 | $document = Plugin::$instance->documents->get( $pid ); |
| @@ -97,15 +96,8 @@ | ||
| 97 | 96 | |
| 98 | 97 | $header = templately()->theme_builder::$conditions_manager->get_templates_by_location( 'header' ); |
| 99 | 98 | $footer = templately()->theme_builder::$conditions_manager->get_templates_by_location( 'footer' ); |
| 100 | 99 | |
| 101 | - if($type === 'header'){ | |
| 102 | - return $header; | |
| 103 | - } | |
| 104 | - else if($type === 'footer'){ | |
| 105 | - return $footer; | |
| 106 | - } | |
| 107 | - | |
| 108 | 100 | if(!empty($header) || !empty($footer)){ |
| 109 | 101 | return true; |
| 110 | 102 | } |
| 111 | 103 | return false; |
| @@ -114,29 +106,15 @@ | ||
| 114 | 106 | public function wrapper_attributes( $attributes, $document ) { |
| 115 | 107 | $post_type = get_post_type($document->get_main_id()); |
| 116 | 108 | |
| 117 | 109 | if( $post_type === 'templately_library' ){ |
| 118 | - $template = templately()->theme_builder->get_template( $document->get_main_id() ); | |
| 119 | - if($template){ | |
| 120 | - $attributes['data-elementor-type'] = 'templately-' . $template->get_type(); | |
| 121 | - $attributes['data-elementor-id'] = $template->get_main_id(); | |
| 122 | - $attributes['data-elementor-post-type'] = 'templately_library'; | |
| 123 | - $attributes['data-elementor-title'] = $template->get_title(); | |
| 124 | - $attributes['class'] .= ' ' . implode( ' ', get_post_class() ); | |
| 125 | - } | |
| 110 | + $template = templately()->theme_builder->get_template( $document->get_main_id() ); | |
| 111 | + $attributes['data-elementor-type'] = 'templately-' . $template->get_type(); | |
| 112 | + $attributes['data-elementor-id'] = $template->get_main_id(); | |
| 113 | + $attributes['data-elementor-post-type'] = 'templately_library'; | |
| 114 | + $attributes['data-elementor-title'] = $template->get_title(); | |
| 126 | 115 | } |
| 127 | 116 | |
| 128 | 117 | 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 | - } | |
| 140 | 118 | } |
| 141 | 119 | |
| 142 | 120 | } |