| @@ -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> |
| @@ -46,9 +48,9 @@ | ||
| 46 | 48 | * Priority is 7, |
| 47 | 49 | * Because it should run before elementor |
| 48 | 50 | */ |
| 49 | 51 | add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_styles' ], 7 ); |
| 50 | - add_action( 'eb_frontend_assets', [ $this, 'enqueue_template_assets' ], 10, 2 ); | |
| 52 | + add_action( 'wp_enqueue_scripts', [$this, 'enqueue_template_assets'], 8 ); | |
| 51 | 53 | } |
| 52 | 54 | |
| 53 | 55 | private function set_locations() { |
| 54 | 56 | $this->locations = [ |
| @@ -342,11 +344,11 @@ | ||
| 342 | 344 | } |
| 343 | 345 | } |
| 344 | 346 | } |
| 345 | 347 | |
| 346 | - public function enqueue_template_assets( $path, $url ) { | |
| 348 | + public function enqueue_template_assets() { | |
| 347 | 349 | $using_templately_builder = get_query_var( 'using_templately_template' ); |
| 348 | - if ( $using_templately_builder && function_exists( 'templately' ) ) { | |
| 350 | + if ( ($using_templately_builder || TemplateLoader::is_header_footer()) && function_exists( 'templately' ) ) { | |
| 349 | 351 | $template_locations = [ 'header', 'footer', 'archive', 'single' ]; |
| 350 | 352 | foreach ( $template_locations as $location ) { |
| 351 | 353 | $template = templately()->theme_builder::$conditions_manager->get_templates_by_location( $location ); |
| 352 | 354 | if ( empty( $template ) ) { |
| @@ -354,14 +356,9 @@ | ||
| 354 | 356 | } |
| 355 | 357 | $template = array_pop( $template ); |
| 356 | 358 | if ( $template->platform == 'gutenberg' ) { |
| 357 | 359 | $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 ) ); | |
| 360 | + do_action("templately_printed_location", $template->get_main_id(), $location, $template); | |
| 364 | 361 | } |
| 365 | 362 | } |
| 366 | 363 | } |
| 367 | 364 | } |