1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
<?php namespace Elementor\Core\Settings\Page;
use Elementor\Core\Settings\Base\CSS_Model; use Elementor\Plugin;
if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. }
/** * Elementor page settings model. * * Elementor page settings model handler class is responsible for registering * and managing Elementor page settings models. * * @since 1.6.0 */ class Model extends CSS_Model {
/** * WordPress post object. * * Holds an instance of `WP_Post` containing the post object. * * @since 1.6.0 * @access public * * @var \WP_Post */ private $post;
/** * @var \WP_Post */ private $post_parent;
/** * Model constructor. * * Initializing Elementor page settings model. * * @since 1.6.0 * @access public * * @param array $data Optional. Model data. Default is an empty array. */ public function __construct( array $data = [] ) { $this->post = get_post( $data['id'] );
if ( ! $this->post ) { $this->post = new \WP_Post( (object) [] ); }
if ( wp_is_post_revision( $this->post->ID ) ) { $this->post_parent = get_post( $this->post->post_parent ); } else { $this->post_parent = $this->post; }
parent::__construct( $data ); }
/** * Get model name. * * Retrieve page settings model name. * * @since 1.6.0 * @access public * * @return string Model name. */ public function get_name() { return 'page-settings'; }
/** * Get model unique name. * * Retrieve page settings model unique name. * * @since 1.6.0 * @access public * * @return string Model unique name. */ public function get_unique_name() { return $this->get_name() . '-' . $this->post->ID; }
/** * Get CSS wrapper selector. * * Retrieve the wrapper selector for the page settings model. * * @since 1.6.0 * @access public * * @return string CSS wrapper selector. */ public function get_css_wrapper_selector() { $document = Plugin::$instance->documents->get( $this->post_parent->ID ); return $document->get_css_wrapper_selector(); }
/** * Get panel page settings. * * Retrieve the panel setting for the page settings model. * * @since 1.6.0 * @access public * * @return array { * Panel settings. * * @type string $title The panel title. * } */ public function get_panel_page_settings() { $document = Plugin::$instance->documents->get( $this->post->ID );
return [ 'title' => sprintf( /* translators: %s: Document title. */ esc_html__( '%s Settings', 'elementor' ), $document::get_title() ), ]; }
/** * On export post meta. * * When exporting data, check if the post is not using page template and * exclude it from the exported Elementor data. * * @since 1.6.0 * @access public * * @param array $element_data Element data. * * @return array Element data to be exported. */ public function on_export( $element_data ) { if ( ! empty( $element_data['settings']['template'] ) ) { /** * @var \Elementor\Modules\PageTemplates\Module $page_templates_module */ $page_templates_module = Plugin::$instance->modules_manager->get_modules( 'page-templates' ); $is_elementor_template = ! ! $page_templates_module->get_template_path( $element_data['settings']['template'] );
if ( ! $is_elementor_template ) { unset( $element_data['settings']['template'] ); } }
return $element_data; }
/** * Register model controls. * * Used to add new controls to the page settings model. * * @since 3.1.0 * @access protected */ protected function register_controls() { // Check if it's a real model, or abstract (for example - on import ) if ( $this->post->ID ) { $document = Plugin::$instance->documents->get_doc_or_auto_save( $this->post->ID );
if ( $document ) { $controls = $document->get_controls();
foreach ( $controls as $control_id => $args ) { $this->add_control( $control_id, $args ); } } } } }
|