PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.8.0
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.8.0
3.8.0 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 All 112 releases
templately / modules / theme-builder / Factory / TemplateFactory.php

TemplateFactory.php in Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! 3.8.0, at modules/theme-builder/Factory/TemplateFactory.php

35 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Templately\Modules\ThemeBuilder\Factory;
4
5 use Elementor\Core\Base\Document;
6 use Templately\Modules\ThemeBuilder\Source;
7
8 class TemplateFactory {
9 protected $platform;
10 protected $template_manager;
11
12 public function __construct( $platform = 'elementor' ) {
13 $this->platform = $platform;
14 $this->template_manager = templately()->theme_builder::$templates_manager;
15 }
16
17 public function create( $type, $data, $meta = [] ) {
18 $data = wp_parse_args( $data );
19
20 $meta = wp_parse_args( $meta, [
21 Source::PLATFORM_META_KEY => $this->platform,
22 Source::TYPE_META_KEY => $type,
23 ] );
24
25 // Guard against Elementor not being loaded: referencing the Document constant
26 // on a missing class is an UNCATCHABLE "Class not found" fatal, which aborted
27 // the whole import here rather than anywhere it could be reported.
28 if ( $this->platform === 'elementor' && class_exists( Document::class ) ) {
29 $meta[ Document::BUILT_WITH_ELEMENTOR_META_KEY ] = 'builder';
30 }
31
32 return $this->template_manager->create( $type, $data, $meta );
33 }
34 }
35