← All changes
|
modules/atomic-widgets/elements/base/has-element-template.php
+18
-2
4.0.9
→
4.1.0-beta1
View file →
| @@ -17,8 +17,16 @@ | ||
| 17 | 17 | * @mixin Atomic_Element_Base |
| 18 | 18 | */ |
| 19 | 19 | trait Has_Element_Template { |
| 20 | 20 | |
| 21 | + private static function get_macros_template_key(): string { | |
| 22 | + return 'elementor/macros'; | |
| 23 | + } | |
| 24 | + | |
| 25 | + protected function transform_link_for_render( array $parsed ): array { | |
| 26 | + return $parsed; | |
| 27 | + } | |
| 28 | + | |
| 21 | 29 | public function get_initial_config() { |
| 22 | 30 | $config = parent::get_initial_config(); |
| 23 | 31 | |
| 24 | 32 | $config['support_nesting'] = true; |
| @@ -28,12 +36,18 @@ | ||
| 28 | 36 | |
| 29 | 37 | return $config; |
| 30 | 38 | } |
| 31 | 39 | |
| 40 | + protected function get_shared_templates(): array { | |
| 41 | + return [ | |
| 42 | + self::get_macros_template_key() => __DIR__ . '/_macros.html.twig', | |
| 43 | + ]; | |
| 44 | + } | |
| 45 | + | |
| 32 | 46 | protected function get_templates_contents() { |
| 33 | 47 | return array_map( |
| 34 | 48 | fn ( $path ) => Utils::file_get_contents( $path ), |
| 35 | - $this->get_templates() | |
| 49 | + array_merge( $this->get_shared_templates(), $this->get_templates() ) | |
| 36 | 50 | ); |
| 37 | 51 | } |
| 38 | 52 | |
| 39 | 53 | protected function render() { |
| @@ -39,9 +53,11 @@ | ||
| 39 | 53 | protected function render() { |
| 40 | 54 | try { |
| 41 | 55 | $renderer = Template_Renderer::instance(); |
| 42 | 56 | |
| 43 | - foreach ( $this->get_templates() as $name => $path ) { | |
| 57 | + $all_templates = array_merge( $this->get_shared_templates(), $this->get_templates() ); | |
| 58 | + | |
| 59 | + foreach ( $all_templates as $name => $path ) { | |
| 44 | 60 | if ( $renderer->is_registered( $name ) ) { |
| 45 | 61 | continue; |
| 46 | 62 | } |
| 47 | 63 | |