| @@ -22,12 +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' ) ); | |
| 27 | 26 | |
| 28 | - add_action( 'templately_builder_header_after', [ self::class, 'print_style_tags' ], 0 ); | |
| 29 | - add_action( 'templately_builder_footer_before', [ self::class, 'print_style_tags' ], 0 ); | |
| 30 | 27 | /** |
| 31 | 28 | * Only for Development Mode. |
| 32 | 29 | */ |
| 33 | 30 | if ( defined( 'TEMPLATELY_DEV_VIEWS' ) && TEMPLATELY_DEV_VIEWS ) { |
| @@ -44,9 +41,9 @@ | ||
| 44 | 41 | echo '<small>Footer</small>'; |
| 45 | 42 | } |
| 46 | 43 | |
| 47 | 44 | public function get_header() { |
| 48 | - if(!self::is_header_footer('header')){ | |
| 45 | + if(!$this->is_header_footer()){ | |
| 49 | 46 | return; |
| 50 | 47 | } |
| 51 | 48 | $this->views->get_header(); |
| 52 | 49 | |
| @@ -60,9 +57,9 @@ | ||
| 60 | 57 | ob_get_clean(); |
| 61 | 58 | } |
| 62 | 59 | |
| 63 | 60 | public function get_footer( $name ) { |
| 64 | - if(!self::is_header_footer('footer')){ | |
| 61 | + if(!$this->is_header_footer()){ | |
| 65 | 62 | return; |
| 66 | 63 | } |
| 67 | 64 | $this->views->get_footer(); |
| 68 | 65 | |
| @@ -80,9 +77,9 @@ | ||
| 80 | 77 | locate_template( $templates, true ); |
| 81 | 78 | ob_get_clean(); |
| 82 | 79 | } |
| 83 | 80 | |
| 84 | - public static function is_header_footer($type = null){ | |
| 81 | + public function is_header_footer(){ | |
| 85 | 82 | if(class_exists( 'Elementor\Plugin' )){ |
| 86 | 83 | $pid = get_the_ID(); |
| 87 | 84 | $post_type = get_post_type($pid); |
| 88 | 85 | $document = Plugin::$instance->documents->get( $pid ); |
| @@ -99,15 +96,8 @@ | ||
| 99 | 96 | |
| 100 | 97 | $header = templately()->theme_builder::$conditions_manager->get_templates_by_location( 'header' ); |
| 101 | 98 | $footer = templately()->theme_builder::$conditions_manager->get_templates_by_location( 'footer' ); |
| 102 | 99 | |
| 103 | - if($type === 'header'){ | |
| 104 | - return $header; | |
| 105 | - } | |
| 106 | - else if($type === 'footer'){ | |
| 107 | - return $footer; | |
| 108 | - } | |
| 109 | - | |
| 110 | 100 | if(!empty($header) || !empty($footer)){ |
| 111 | 101 | return true; |
| 112 | 102 | } |
| 113 | 103 | return false; |
| @@ -117,51 +107,15 @@ | ||
| 117 | 107 | $post_type = get_post_type($document->get_main_id()); |
| 118 | 108 | |
| 119 | 109 | if( $post_type === 'templately_library' ){ |
| 120 | 110 | $template = templately()->theme_builder->get_template( $document->get_main_id() ); |
| 121 | - if($template){ | |
| 122 | - $attributes['data-elementor-type'] = 'templately-' . $template->get_type(); | |
| 123 | - $attributes['data-elementor-id'] = $template->get_main_id(); | |
| 124 | - $attributes['data-elementor-post-type'] = 'templately_library'; | |
| 125 | - $attributes['data-elementor-title'] = $template->get_title(); | |
| 126 | - $attributes['class'] .= ' ' . implode( ' ', get_post_class() ); | |
| 127 | - } | |
| 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(); | |
| 115 | + $attributes['class'] .= ' ' . implode( ' ', get_post_class() ); | |
| 128 | 116 | } |
| 129 | 117 | |
| 130 | 118 | return $attributes; |
| 131 | - } | |
| 132 | - | |
| 133 | - public function set_global_product(){ | |
| 134 | - global $product; | |
| 135 | - | |
| 136 | - if ( class_exists('\WC_Product') && ! $product instanceof \WC_Product ) { | |
| 137 | - $product_id = get_the_ID(); | |
| 138 | - if ( $product_id ) { | |
| 139 | - wc_setup_product_data( $product_id ); | |
| 140 | - } | |
| 141 | - } | |
| 142 | - } | |
| 143 | - | |
| 144 | - /** | |
| 145 | - * Print remaining enqueued styles with error handling. | |
| 146 | - */ | |
| 147 | - public static function print_style_tags() { | |
| 148 | - try { | |
| 149 | - $wp_styles = wp_styles(); | |
| 150 | - // handles dependencies | |
| 151 | - $wp_styles->do_items(); | |
| 152 | - if ( is_object( $wp_styles ) && is_array( $wp_styles->queue ?? null ) ) { | |
| 153 | - foreach ( $wp_styles->queue as $style ) { | |
| 154 | - if ( is_string( $style ) && ! $wp_styles->query( $style, 'done' ) ) { | |
| 155 | - $wp_styles->do_item( $style ); | |
| 156 | - $wp_styles->done[] = $style; | |
| 157 | - } | |
| 158 | - } | |
| 159 | - } | |
| 160 | - } catch ( \Throwable $e ) { | |
| 161 | - if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { | |
| 162 | - error_log( 'Templately: Error printing styles - ' . $e->getMessage() ); | |
| 163 | - } | |
| 164 | - } | |
| 165 | 119 | } |
| 166 | 120 | |
| 167 | 121 | } |