PluginProbe
Elementor Website Builder – more than just a page builder / 3.1.0-beta1
Elementor Website Builder – more than just a page builder v3.1.0-beta1
4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 4.3.0-beta3 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 All 457 releases
elementor / modules / landing-pages / documents / landing-page.php

landing-page.php in Elementor Website Builder – more than just a page builder 3.1.0-beta1, at modules/landing-pages/documents/landing-page.php

97 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Modules\LandingPages\Documents;
3
4 use Elementor\Core\DocumentTypes\Page;
5 use Elementor\Modules\LandingPages\Module;
6 use Elementor\Modules\LandingPages\Module as Landing_Pages_Module;
7 use Elementor\Modules\PageTemplates\Module as PageTemplatesModule;
8 use Elementor\TemplateLibrary\Source_Local;
9
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit; // Exit if accessed directly
12 }
13
14 class Landing_Page extends Page {
15
16 public static function get_properties() {
17 $properties = parent::get_properties();
18
19 $properties['support_kit'] = true;
20 $properties['show_in_library'] = true;
21
22 // This is so Landing Pages don't take over WordPress' native 'page' Post type.
23 unset( $properties['cpt'] );
24
25 return $properties;
26 }
27
28 /**
29 * @access public
30 */
31 public function get_name() {
32 return Module::DOCUMENT_TYPE;
33 }
34
35 /**
36 * @access public
37 * @static
38 */
39 public static function get_title() {
40 return __( 'Landing Page', 'elementor' );
41 }
42
43 public function save( $data ) {
44 // Load a new Landing Page with Canvas as the default page template.
45 if ( empty( $data['settings']['template'] ) ) {
46 $data['settings']['template'] = PageTemplatesModule::TEMPLATE_CANVAS;
47 }
48
49 parent::save( $data );
50 }
51
52 /**
53 * Save Template type.
54 *
55 * Set new/updated document type (Page/landing Page). This method is called whenever a page is saved.
56 *
57 * @since 3.1.0
58 * @access public
59 */
60 public function save_template_type() {
61 $page_data = $this->data_to_be_saved['settings'];
62
63 if ( isset( $page_data['page_type'] ) ) {
64 $post_id = $this->get_id();
65 $page_type_wp_page = parent::get_name();
66
67 // If 'Page' was selected by the user, since the document is currently a Landing Page - change it to a regular page.
68 if ( $page_type_wp_page === $page_data['page_type'] ) {
69 // Remove the association to the library taxonomy as a 'landing-page'.
70 wp_remove_object_terms( $post_id, Module::DOCUMENT_TYPE, Source_Local::TAXONOMY_TYPE_SLUG );
71
72 // Change the Template Type to 'Page'.
73 return $this->update_main_meta( self::TYPE_META_KEY, $page_type_wp_page );
74 }
75 }
76
77 /**
78 * If the selected page is a Landing Page.
79 */
80 // Make sure it is saved as a Landing Page in the Elementor Library Taxonomy.
81 wp_set_object_terms( $this->get_id(), Landing_Pages_Module::DOCUMENT_TYPE, Source_Local::TAXONOMY_TYPE_SLUG );
82
83 // Make sure it is saved as a Landing Page Elementor Template Type Meta.
84 return $this->update_main_meta( self::TYPE_META_KEY, $this->get_name() );
85 }
86
87 protected function get_remote_library_config() {
88 $config = [
89 'type' => 'lp',
90 'default_route' => 'templates/landing-pages',
91 'autoImportSettings' => true,
92 ];
93
94 return array_replace_recursive( parent::get_remote_library_config(), $config );
95 }
96 }
97