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
← All changes | modules/landing-pages/documents/landing-page.php +40 -50 4.2.0-dev2 → 3.1.0-beta1 View file →
@@ -1,42 +1,36 @@
1 1 <?php
2 2 namespace Elementor\Modules\LandingPages\Documents;
3 3
4 -use Elementor\Core\DocumentTypes\PageBase;
4 +use Elementor\Core\DocumentTypes\Page;
5 +use Elementor\Modules\LandingPages\Module;
5 6 use Elementor\Modules\LandingPages\Module as Landing_Pages_Module;
6 -use Elementor\Modules\Library\Traits\Library;
7 -use Elementor\Modules\PageTemplates\Module as Page_Templates_Module;
8 -use Elementor\Plugin;
7 +use Elementor\Modules\PageTemplates\Module as PageTemplatesModule;
9 8 use Elementor\TemplateLibrary\Source_Local;
10 9
11 10 if ( ! defined( 'ABSPATH' ) ) {
12 - exit; // Exit if accessed directly.
11 + exit; // Exit if accessed directly
13 12 }
14 13
15 -class Landing_Page extends PageBase {
14 +class Landing_Page extends Page {
16 15
17 - // Library Document Trait
18 - use Library;
19 -
20 16 public static function get_properties() {
21 17 $properties = parent::get_properties();
22 18
23 19 $properties['support_kit'] = true;
24 20 $properties['show_in_library'] = true;
25 - $properties['cpt'] = [ Landing_Pages_Module::CPT ];
26 21
22 + // This is so Landing Pages don't take over WordPress' native 'page' Post type.
23 + unset( $properties['cpt'] );
24 +
27 25 return $properties;
28 26 }
29 27
30 - public static function get_type() {
31 - return Landing_Pages_Module::DOCUMENT_TYPE;
32 - }
33 -
34 28 /**
35 29 * @access public
36 30 */
37 31 public function get_name() {
38 - return Landing_Pages_Module::DOCUMENT_TYPE;
32 + return Module::DOCUMENT_TYPE;
39 33 }
40 34
41 35 /**
42 36 * @access public
@@ -42,57 +36,53 @@
42 36 * @access public
43 37 * @static
44 38 */
45 39 public static function get_title() {
46 - return esc_html__( 'Landing Page', 'elementor' );
40 + return __( 'Landing Page', 'elementor' );
47 41 }
48 42
49 - /**
50 - * @access public
51 - * @static
52 - */
53 - public static function get_plural_title() {
54 - return esc_html__( 'Landing Pages', 'elementor' );
55 - }
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 + }
56 48
57 - public static function get_create_url() {
58 - return parent::get_create_url() . '#library';
49 + parent::save( $data );
59 50 }
60 51
61 52 /**
62 - * Save Document.
53 + * Save Template type.
63 54 *
64 - * Save an Elementor document.
55 + * Set new/updated document type (Page/landing Page). This method is called whenever a page is saved.
65 56 *
66 57 * @since 3.1.0
67 58 * @access public
68 - *
69 - * @param $data
70 - *
71 - * @return bool
72 59 */
73 - public function save( $data ) {
74 - // This is for the first time a Landing Page is created. It is done in order to load a new Landing Page with
75 - // 'Canvas' as the default page template.
76 - if ( empty( $data['settings']['template'] ) ) {
77 - $data['settings']['template'] = Page_Templates_Module::TEMPLATE_CANVAS;
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 + }
78 75 }
79 76
80 - return parent::save( $data );
81 - }
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 82
83 - /**
84 - * Admin Columns Content
85 - *
86 - * @since 3.1.0
87 - *
88 - * @param $column_name
89 - * @access public
90 - */
91 - public function admin_columns_content( $column_name ) {
92 - if ( 'elementor_library_type' === $column_name ) {
93 - $this->print_admin_column_type();
94 - }
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() );
95 85 }
96 86
97 87 protected function get_remote_library_config() {
98 88 $config = [