PluginProbe
Elementor Website Builder – more than just a page builder / 4.1.2
Elementor Website Builder – more than just a page builder v4.1.2
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 4.1.2, at modules/home/classes/transformations-manager.php

79 lines 2.1 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\Includes\EditorAssetsAPI;
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly.
10 }
11
12 class Transformations_Manager {
13
14 private static $cached_data = [];
15
16 private const TRANSFORMATIONS = [
17 'Create_New_Page_Url',
18 'Create_Edit_Website_Url',
19 'Filter_Get_Started_By_License',
20 'Filter_Sidebar_Promotion_By_License',
21 'Create_Site_Settings_Url',
22 'Filter_Top_Section_By_License',
23 'Site_Builder_Config',
24 ];
25
26 protected array $home_screen_data;
27
28 protected Wordpress_Adapter $wordpress_adapter;
29
30 protected Plugin_Status_Adapter $plugin_status_adapter;
31
32 protected array $transformation_classes = [];
33
34 public function __construct( $home_screen_data ) {
35 $this->home_screen_data = $home_screen_data;
36 $this->wordpress_adapter = new Wordpress_Adapter();
37 $this->plugin_status_adapter = new Plugin_Status_Adapter( $this->wordpress_adapter );
38 $this->transformation_classes = $this->get_transformation_classes();
39 }
40
41 public function run_transformations(): array {
42 if ( ! EditorAssetsAPI::is_valid_data( $this->home_screen_data ) ) {
43 return [];
44 }
45
46 if ( ! empty( self::$cached_data ) ) {
47 return self::$cached_data;
48 }
49
50 $transformations = self::TRANSFORMATIONS;
51
52 foreach ( $transformations as $transformation_id ) {
53 $this->home_screen_data = $this->transformation_classes[ $transformation_id ]->transform( $this->home_screen_data );
54 }
55
56 self::$cached_data = $this->home_screen_data;
57
58 return $this->home_screen_data;
59 }
60
61 private function get_transformation_classes(): array {
62 $classes = [];
63
64 $transformations = self::TRANSFORMATIONS;
65
66 $arguments = [
67 'wordpress_adapter' => $this->wordpress_adapter,
68 'plugin_status_adapter' => $this->plugin_status_adapter,
69 ];
70
71 foreach ( $transformations as $transformation_id ) {
72 $class_name = '\\Elementor\\Modules\\Home\\Transformations\\' . $transformation_id;
73 $classes[ $transformation_id ] = new $class_name( $arguments );
74 }
75
76 return $classes;
77 }
78 }
79