PluginProbe
Elementor Website Builder – more than just a page builder / 3.25.3
Elementor Website Builder – more than just a page builder v3.25.3
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 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / modules / home / classes / transformations-manager.php

transformations-manager.php in Elementor Website Builder – more than just a page builder 3.25.3, at modules/home/classes/transformations-manager.php

83 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Modules\Home\Classes;
3
4 use Elementor\Core\Isolation\Wordpress_Adapter;
5 use Elementor\Core\Isolation\Plugin_Status_Adapter;
6 use Elementor\Core\Isolation\Wordpress_Adapter_Interface;
7 use Elementor\Plugin;
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit; // Exit if accessed directly
11 }
12
13 class Transformations_Manager {
14
15 private static $cached_data = [];
16
17 private const TRANSFORMATIONS = [
18 'Create_New_Page_Url',
19 'Filter_Plugins',
20 'Filter_Get_Started_By_License',
21 'Filter_Sidebar_Upgrade_By_License',
22 'Filter_Condition_Introduction_Meta',
23 'Create_Site_Settings_Url',
24 'Filter_Top_Section_By_License',
25 ];
26
27 protected array $home_screen_data;
28
29 protected Wordpress_Adapter_Interface $wordpress_adapter;
30
31 protected Plugin_Status_Adapter $plugin_status_adapter;
32
33 protected array $transformation_classes = [];
34
35 public function __construct( $home_screen_data ) {
36 $container = Plugin::$instance->elementor_container();
37
38 if ( $container->has( Wordpress_Adapter::class ) ) {
39 $this->wordpress_adapter = $container->get( Wordpress_Adapter::class );
40 } else {
41 $this->wordpress_adapter = new Wordpress_Adapter();
42 }
43
44 $this->home_screen_data = $home_screen_data;
45 $this->plugin_status_adapter = new Plugin_Status_Adapter( $this->wordpress_adapter );
46 $this->transformation_classes = $this->get_transformation_classes();
47 }
48
49 public function run_transformations(): array {
50 if ( ! empty( self::$cached_data ) ) {
51 return self::$cached_data;
52 }
53
54 $transformations = self::TRANSFORMATIONS;
55
56 foreach ( $transformations as $transformation_id ) {
57 $this->home_screen_data = $this->transformation_classes[ $transformation_id ]->transform( $this->home_screen_data );
58 }
59
60 self::$cached_data = $this->home_screen_data;
61
62 return $this->home_screen_data;
63 }
64
65 private function get_transformation_classes(): array {
66 $classes = [];
67
68 $transformations = self::TRANSFORMATIONS;
69
70 $arguments = [
71 'wordpress_adapter' => $this->wordpress_adapter,
72 'plugin_status_adapter' => $this->plugin_status_adapter,
73 ];
74
75 foreach ( $transformations as $transformation_id ) {
76 $class_name = '\\Elementor\\Modules\\Home\\Transformations\\' . $transformation_id;
77 $classes[ $transformation_id ] = new $class_name( $arguments );
78 }
79
80 return $classes;
81 }
82 }
83