PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.4.9
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.4.9
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 +52 -8 3.1.03.4.9 View file →
@@ -22,9 +22,12 @@
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
28 + add_action( 'templately_builder_header_after', [ $this, 'print_style_tags' ], 0 );
29 + add_action( 'templately_builder_footer_before', [ $this, 'print_style_tags' ], 0 );
27 30 /**
28 31 * Only for Development Mode.
29 32 */
30 33 if ( defined( 'TEMPLATELY_DEV_VIEWS' ) && TEMPLATELY_DEV_VIEWS ) {
@@ -41,9 +44,9 @@
41 44 echo '<small>Footer</small>';
42 45 }
43 46
44 47 public function get_header() {
45 - if(!$this->is_header_footer()){
48 + if(!self::is_header_footer('header')){
46 49 return;
47 50 }
48 51 $this->views->get_header();
49 52
@@ -57,9 +60,9 @@
57 60 ob_get_clean();
58 61 }
59 62
60 63 public function get_footer( $name ) {
61 - if(!$this->is_header_footer()){
64 + if(!self::is_header_footer('footer')){
62 65 return;
63 66 }
64 67 $this->views->get_footer();
65 68
@@ -77,9 +80,9 @@
77 80 locate_template( $templates, true );
78 81 ob_get_clean();
79 82 }
80 83
81 - public function is_header_footer(){
84 + public static function is_header_footer($type = null){
82 85 if(class_exists( 'Elementor\Plugin' )){
83 86 $pid = get_the_ID();
84 87 $post_type = get_post_type($pid);
85 88 $document = Plugin::$instance->documents->get( $pid );
@@ -96,8 +99,15 @@
96 99
97 100 $header = templately()->theme_builder::$conditions_manager->get_templates_by_location( 'header' );
98 101 $footer = templately()->theme_builder::$conditions_manager->get_templates_by_location( 'footer' );
99 102
103 + if($type === 'header'){
104 + return $header;
105 + }
106 + else if($type === 'footer'){
107 + return $footer;
108 + }
109 +
100 110 if(!empty($header) || !empty($footer)){
101 111 return true;
102 112 }
103 113 return false;
@@ -107,15 +117,49 @@
107 117 $post_type = get_post_type($document->get_main_id());
108 118
109 119 if( $post_type === 'templately_library' ){
110 120 $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() );
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 + }
116 128 }
117 129
118 130 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 function print_style_tags() {
148 + try {
149 + $wp_styles = wp_styles();
150 +
151 + if ( is_object( $wp_styles ) && is_array( $wp_styles->queue ?? null ) ) {
152 + foreach ( $wp_styles->queue as $style ) {
153 + if ( is_string( $style ) && ! $wp_styles->query( $style, 'done' ) ) {
154 + $wp_styles->do_item( $style );
155 + }
156 + }
157 + }
158 + } catch ( \Throwable $e ) {
159 + if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
160 + error_log( 'Templately: Error printing styles - ' . $e->getMessage() );
161 + }
162 + }
119 163 }
120 164
121 165 }