PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.1.10
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.1.10
3.7.5 3.7.4 3.7.3 3.7.2 1-final 3.7.1 3.7.0 3.6.8 3.6.7 3.6.6 3.6.5 3.6.4 3.6.3 3.6.2 3.6.1 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 All 111 releases
← All changes | includes/Builder/TemplateLoader.php +29 -8 3.0.83.1.10 View file →
@@ -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;
@@ -107,15 +115,28 @@
107 115 $post_type = get_post_type($document->get_main_id());
108 116
109 117 if( $post_type === 'templately_library' ){
110 118 $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();
115 - $attributes['class'] .= ' ' . implode( ' ', get_post_class() );
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 + }
116 126 }
117 127
118 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 + }
119 140 }
120 141
121 142 }