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