← All changes
|
modules/atomic-widgets/elements/base/has-element-template.php
+22
-3
4.0.9
→
4.3.2
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 | |
| @@ -78,13 +94,16 @@ | ||
| 78 | 94 | return '<!-- elementor-children-placeholder -->'; |
| 79 | 95 | } |
| 80 | 96 | |
| 81 | 97 | protected function build_base_template_context(): array { |
| 98 | + $settings = $this->get_atomic_settings(); | |
| 99 | + | |
| 82 | 100 | return [ |
| 83 | 101 | 'id' => $this->get_id(), |
| 84 | 102 | 'interaction_id' => $this->get_interaction_id(), |
| 85 | 103 | 'type' => $this->get_name(), |
| 86 | - 'settings' => $this->get_atomic_settings(), | |
| 104 | + 'settings' => $settings, | |
| 105 | + 'tag' => static::get_computed_html_tag( $settings ), | |
| 87 | 106 | 'base_styles' => $this->get_base_styles_dictionary(), |
| 88 | 107 | 'children_placeholder' => $this->get_children_placeholder(), |
| 89 | 108 | ]; |
| 90 | 109 | } |