PluginProbe
Elementor Website Builder – more than just a page builder / 3.0.6
Elementor Website Builder – more than just a page builder v3.0.6
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
← All changes | modules/page-templates/module.php +36 -44 4.0.83.0.6 View file →
@@ -4,15 +4,16 @@
4 4 use Elementor\Controls_Manager;
5 5 use Elementor\Core\Base\Document;
6 6 use Elementor\Core\Base\Module as BaseModule;
7 7 use Elementor\Core\Kits\Documents\Kit;
8 +use Elementor\DB;
8 9 use Elementor\Plugin;
9 10 use Elementor\Utils;
10 -use Elementor\Core\DocumentTypes\PageBase;
11 +use Elementor\Core\DocumentTypes\PageBase as PageBase;
11 12 use Elementor\Modules\Library\Documents\Page as LibraryPageDocument;
12 13
13 14 if ( ! defined( 'ABSPATH' ) ) {
14 - exit; // Exit if accessed directly.
15 + exit; // Exit if accessed directly
15 16 }
16 17
17 18 /**
18 19 * Elementor page templates module.
@@ -24,13 +25,8 @@
24 25 */
25 26 class Module extends BaseModule {
26 27
27 28 /**
28 - * The of the theme.
29 - */
30 - const TEMPLATE_THEME = 'elementor_theme';
31 -
32 - /**
33 29 * Elementor Canvas template name.
34 30 */
35 31 const TEMPLATE_CANVAS = 'elementor_canvas';
36 32
@@ -82,14 +78,12 @@
82 78 public function template_include( $template ) {
83 79 if ( is_singular() ) {
84 80 $document = Plugin::$instance->documents->get_doc_for_frontend( get_the_ID() );
85 81
86 - if ( $document && $document::get_property( 'support_wp_page_templates' ) ) {
87 - $page_template = $document->get_meta( '_wp_page_template' );
82 + if ( $document ) {
83 + $template_path = $this->get_template_path( $document->get_meta( '_wp_page_template' ) );
88 84
89 - $template_path = $this->get_template_path( $page_template );
90 -
91 - if ( self::TEMPLATE_THEME !== $page_template && ! $template_path && $document->is_built_with_elementor() ) {
85 + if ( ! $template_path && $document->is_built_with_elementor() ) {
92 86 $kit_default_template = Plugin::$instance->kits_manager->get_current_settings( 'default_page_template' );
93 87 $template_path = $this->get_template_path( $kit_default_template );
94 88 }
95 89
@@ -133,11 +127,13 @@
133 127 * @since 2.0.0
134 128 * @access public
135 129 * @static
136 130 *
137 - * @param array $page_templates Array of page templates. Keys are filenames, checks are translated names.
131 + * @param array $page_templates Array of page templates. Keys are filenames,
132 + * checks are translated names.
133 + *
138 134 * @param \WP_Theme $wp_theme
139 - * @param \WP_Post $post
135 + * @param \WP_Post $post
140 136 *
141 137 * @return array Page templates.
142 138 */
143 139 public function add_page_templates( $page_templates, $wp_theme, $post ) {
@@ -151,11 +147,10 @@
151 147 }
152 148 }
153 149
154 150 $page_templates = [
155 - self::TEMPLATE_CANVAS => esc_html__( 'Elementor Canvas', 'elementor' ),
156 - self::TEMPLATE_HEADER_FOOTER => esc_html__( 'Elementor Full Width', 'elementor' ),
157 - self::TEMPLATE_THEME => esc_html__( 'Theme', 'elementor' ),
151 + self::TEMPLATE_CANVAS => _x( 'Elementor Canvas', 'Page Template', 'elementor' ),
152 + self::TEMPLATE_HEADER_FOOTER => _x( 'Elementor Full Width', 'Page Template', 'elementor' ),
158 153 ] + $page_templates;
159 154
160 155 return $page_templates;
161 156 }
@@ -243,12 +238,9 @@
243 238 *
244 239 * @param Document $document The document instance.
245 240 */
246 241 public function action_register_template_control( $document ) {
247 - if (
248 - ( $document instanceof PageBase || $document instanceof LibraryPageDocument ) &&
249 - $document::get_property( 'support_page_layout' )
250 - ) {
242 + if ( $document instanceof PageBase || $document instanceof LibraryPageDocument ) {
251 243 $this->register_template_control( $document );
252 244 }
253 245 }
254 246
@@ -285,19 +277,17 @@
285 277
286 278 $document->end_injection();
287 279 }
288 280
289 - /**
290 - * The $options variable is an array of $control_options to overwrite the default.
291 - */
281 + // The $options variable is an array of $control_options to overwrite the default
292 282 public function add_template_controls( Document $document, $control_id, $control_options ) {
293 283 // Default Control Options
294 284 $default_control_options = [
295 - 'label' => esc_html__( 'Page Layout', 'elementor' ),
285 + 'label' => __( 'Page Layout', 'elementor' ),
296 286 'type' => Controls_Manager::SELECT,
297 287 'default' => 'default',
298 288 'options' => [
299 - 'default' => esc_html__( 'Default', 'elementor' ),
289 + 'default' => __( 'Default', 'elementor' ),
300 290 ],
301 291 ];
302 292
303 293 $control_options = array_replace_recursive( $default_control_options, $control_options );
@@ -310,9 +300,9 @@
310 300 $document->add_control(
311 301 $control_id . '_default_description',
312 302 [
313 303 'type' => Controls_Manager::RAW_HTML,
314 - 'raw' => '<b>' . esc_html__( 'The default page template as defined in Elementor Panel → Hamburger Menu → Site Settings.', 'elementor' ) . '</b>',
304 + 'raw' => '<b>' . __( 'Default Page Template from your theme', 'elementor' ) . '</b>',
315 305 'content_classes' => 'elementor-descriptor',
316 306 'condition' => [
317 307 $control_id => 'default',
318 308 ],
@@ -319,24 +309,12 @@
319 309 ]
320 310 );
321 311
322 312 $document->add_control(
323 - $control_id . '_theme_description',
324 - [
325 - 'type' => Controls_Manager::RAW_HTML,
326 - 'raw' => '<b>' . esc_html__( 'Default Page Template from your theme.', 'elementor' ) . '</b>',
327 - 'content_classes' => 'elementor-descriptor',
328 - 'condition' => [
329 - $control_id => self::TEMPLATE_THEME,
330 - ],
331 - ]
332 - );
333 -
334 - $document->add_control(
335 313 $control_id . '_canvas_description',
336 314 [
337 315 'type' => Controls_Manager::RAW_HTML,
338 - 'raw' => '<b>' . esc_html__( 'No header, no footer, just Elementor', 'elementor' ) . '</b>',
316 + 'raw' => '<b>' . __( 'No header, no footer, just Elementor', 'elementor' ) . '</b>',
339 317 'content_classes' => 'elementor-descriptor',
340 318 'condition' => [
341 319 $control_id => self::TEMPLATE_CANVAS,
342 320 ],
@@ -346,9 +324,9 @@
346 324 $document->add_control(
347 325 $control_id . '_header_footer_description',
348 326 [
349 327 'type' => Controls_Manager::RAW_HTML,
350 - 'raw' => '<b>' . esc_html__( 'This template includes the header, full-width content and footer', 'elementor' ) . '</b>',
328 + 'raw' => '<b>' . __( 'This template includes the header, full-width content and footer', 'elementor' ) . '</b>',
351 329 'content_classes' => 'elementor-descriptor',
352 330 'condition' => [
353 331 $control_id => self::TEMPLATE_HEADER_FOOTER,
354 332 ],
@@ -359,9 +337,9 @@
359 337 $document->add_control(
360 338 'reload_preview_description',
361 339 [
362 340 'type' => Controls_Manager::RAW_HTML,
363 - 'raw' => esc_html__( 'Changes will be reflected in the preview only after the page reloads.', 'elementor' ),
341 + 'raw' => __( 'Changes will be reflected in the preview only after the page reloads.', 'elementor' ),
364 342 'content_classes' => 'elementor-descriptor',
365 343 ]
366 344 );
367 345 }
@@ -392,18 +370,32 @@
392 370 $ajax = Plugin::$instance->common->get_component( 'ajax' );
393 371
394 372 $ajax_data = $ajax->get_current_action_data();
395 373
396 - $is_autosave_action = $ajax_data && 'save_builder' === $ajax_data['action'] && Document::STATUS_AUTOSAVE === $ajax_data['data']['status'];
374 + $is_autosave_action = $ajax_data && 'save_builder' === $ajax_data['action'] && DB::STATUS_AUTOSAVE === $ajax_data['data']['status'];
397 375
398 376 // Don't allow WP to update the parent page template.
399 377 // (during `wp_update_post` from page-settings or save_plain_text).
400 - if ( $is_autosave_action && ! wp_is_post_autosave( $object_id ) && Document::STATUS_DRAFT !== get_post_status( $object_id ) ) {
378 + if ( $is_autosave_action && ! wp_is_post_autosave( $object_id ) && DB::STATUS_DRAFT !== get_post_status( $object_id ) ) {
401 379 $check = false;
402 380 }
403 381 }
404 382
405 383 return $check;
384 + }
385 +
386 + /**
387 + * Support `wp_body_open` action, available since WordPress 5.2.
388 + *
389 + * @since 2.7.0
390 + * @access public
391 + */
392 + public static function body_open() {
393 + if ( function_exists( 'wp_body_open' ) ) {
394 + wp_body_open();
395 + } else {
396 + do_action( 'wp_body_open' );
397 + }
406 398 }
407 399
408 400 /**
409 401 * Page templates module constructor.