PluginProbe
Elementor Website Builder – more than just a page builder / 4.1.0-beta1
Elementor Website Builder – more than just a page builder v4.1.0-beta1
4.3.3 4.3.2 4.3.1 4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 All 456 releases
← All changes | modules/atomic-widgets/elements/base/has-template.php +18 -2 4.0.9 → 4.1.0-beta1 View file →
@@ -13,8 +13,12 @@
13 13 * @mixin Has_Atomic_Base
14 14 */
15 15 trait Has_Template {
16 16
17 + private static function get_macros_template_key(): string {
18 + return 'elementor/macros';
19 + }
20 +
17 21 public function get_initial_config() {
18 22 $config = parent::get_initial_config();
19 23
20 24 $config['twig_main_template'] = $this->get_main_template();
@@ -21,13 +25,25 @@
21 25 $config['twig_templates'] = $this->get_templates_contents();
22 26 return $config;
23 27 }
24 28
29 + protected function transform_link_for_render( array $parsed ): array {
30 + return $parsed;
31 + }
32 +
33 + protected function get_shared_templates(): array {
34 + return [
35 + self::get_macros_template_key() => __DIR__ . '/_macros.html.twig',
36 + ];
37 + }
38 +
25 39 protected function render() {
26 40 try {
27 41 $renderer = Template_Renderer::instance();
28 42
29 - foreach ( $this->get_templates() as $name => $path ) {
43 + $all_templates = array_merge( $this->get_shared_templates(), $this->get_templates() );
44 +
45 + foreach ( $all_templates as $name => $path ) {
30 46 if ( $renderer->is_registered( $name ) ) {
31 47 continue;
32 48 }
33 49
@@ -53,9 +69,9 @@
53 69
54 70 protected function get_templates_contents() {
55 71 return array_map(
56 72 fn ( $path ) => Utils::file_get_contents( $path ),
57 - $this->get_templates()
73 + array_merge( $this->get_shared_templates(), $this->get_templates() )
58 74 );
59 75 }
60 76
61 77 protected function get_main_template() {