PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.3.3
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.3.3
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/Managers/LocationManager.php +19 -13 3.1.13.3.3 View file →
@@ -2,8 +2,9 @@
2 2
3 3 namespace Templately\Builder\Managers;
4 4
5 5 use EbStyleHandler;
6 +use EssentialBlocks\Modules\StyleHandler;
6 7 use Templately\Builder\PageTemplates;
7 8 use Templately\Builder\Source;
8 9 use Templately\Builder\ThemeBuilder;
9 10 use Templately\Builder\Types\BaseTemplate;
@@ -10,8 +11,9 @@
10 11 use Templately\Builder\Types\ThemeTemplate;
11 12 use ElementorPro\Modules\ThemeBuilder\Module;
12 13 use Elementor\Core\Files\CSS\Post as Post_CSS;
13 14 use ElementorPro\Plugin;
15 +use Templately\Builder\TemplateLoader;
14 16
15 17 class LocationManager {
16 18 /**
17 19 * @var array<string, ThemeTemplate>
@@ -30,12 +32,8 @@
30 32
31 33 public function __construct( $builder ) {
32 34 $this->builder = $builder;
33 35
34 - /**
35 - * Don't know yet if we need it or not.
36 - */
37 - $this->set_locations();
38 36
39 37 /**
40 38 * Priority is 13,
41 39 * Because it should be run after elementor & woocommerce
@@ -46,12 +44,15 @@
46 44 * Priority is 7,
47 45 * Because it should run before elementor
48 46 */
49 47 add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_styles' ], 7 );
50 - add_action( 'eb_frontend_assets', [ $this, 'enqueue_template_assets' ], 10, 2 );
48 + add_action( 'wp_enqueue_scripts', [$this, 'enqueue_template_assets'], 8 );
51 49 }
52 50
53 51 private function set_locations() {
52 + if(!empty($this->locations)) {
53 + return;
54 + }
54 55 $this->locations = [
55 56 'header' => [
56 57 'label' => __( 'Header', 'templately' ),
57 58 'multiple' => false
@@ -114,8 +115,11 @@
114 115 $template = $templates_for_location[ $template_id ];
115 116 $page_template = $template->get_meta( '_wp_page_template' );
116 117 $platform = $template->get_platform();
117 118
119 + if( $platform === 'elementor' && !class_exists('Elementor\Plugin') ) {
120 + return $template_path;
121 + }
118 122 if ( ! empty( $platform ) ) {
119 123 $page_template_module->set_platform( $platform );
120 124 }
121 125 $path = $page_template_module->get_template_path( $page_template );
@@ -226,8 +230,13 @@
226 230 return $locations[ $location ] ?? [];
227 231 }
228 232
229 233 public function get_locations(): array {
234 + /**
235 + * Don't know yet if we need it or not.
236 + */
237 + $this->set_locations();
238 +
230 239 $this->register_locations();
231 240
232 241 return $this->locations;
233 242 }
@@ -275,8 +284,10 @@
275 284 $template->print_content();
276 285 $this->did_locations[] = $location;
277 286
278 287 $this->set_is_printed( $location, $template_id );
288 +
289 + do_action("templately_printed_location", $template_id, $location, $template);
279 290 }
280 291
281 292 return true;
282 293 }
@@ -342,11 +353,11 @@
342 353 }
343 354 }
344 355 }
345 356
346 - public function enqueue_template_assets( $path, $url ) {
357 + public function enqueue_template_assets() {
347 358 $using_templately_builder = get_query_var( 'using_templately_template' );
348 - if ( $using_templately_builder && function_exists( 'templately' ) ) {
359 + if ( ($using_templately_builder || TemplateLoader::is_header_footer()) && function_exists( 'templately' ) ) {
349 360 $template_locations = [ 'header', 'footer', 'archive', 'single' ];
350 361 foreach ( $template_locations as $location ) {
351 362 $template = templately()->theme_builder::$conditions_manager->get_templates_by_location( $location );
352 363 if ( empty( $template ) ) {
@@ -354,14 +365,9 @@
354 365 }
355 366 $template = array_pop( $template );
356 367 if ( $template->platform == 'gutenberg' ) {
357 368 $template = is_array( $template ) ? array_pop( $template ) : $template;
358 - if ( ! file_exists( $path . 'eb-style-' . $template->get_main_id() . '.min.css' ) ) {
359 - $st = EbStyleHandler::init();
360 - $post = get_post( $template->get_main_id() );
361 - $st->eb_write_css_from_content( $post, $post->ID, parse_blocks( $post->post_content ) );
362 - }
363 - wp_enqueue_style( 'templately-' . $location . '-' . $template->get_main_id(), $url . 'eb-style-' . $template->get_main_id() . '.min.css', [], substr( md5( microtime( true ) ), 0, 10 ) );
369 + do_action("templately_printed_location", $template->get_main_id(), $location, $template);
364 370 }
365 371 }
366 372 }
367 373 }