PluginProbe
Elementor Website Builder – more than just a page builder / 3.4.3
Elementor Website Builder – more than just a page builder v3.4.3
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 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
← All changes | modules/landing-pages/module.php +57 -90 4.1.33.4.3 View file →
@@ -4,13 +4,12 @@
4 4 use Elementor\Core\Base\Module as BaseModule;
5 5 use Elementor\Core\Documents_Manager;
6 6 use Elementor\Core\Experiments\Manager as Experiments_Manager;
7 7 use Elementor\Modules\LandingPages\Documents\Landing_Page;
8 -use Elementor\Modules\LandingPages\AdminMenuItems\Editor_One_Landing_Pages_Menu;
9 8 use Elementor\Modules\LandingPages\Module as Landing_Pages_Module;
10 -use Elementor\Modules\EditorOne\Classes\Menu_Data_Provider;
11 9 use Elementor\Plugin;
12 10 use Elementor\TemplateLibrary\Source_Local;
11 +use Elementor\Utils;
13 12
14 13 if ( ! defined( 'ABSPATH' ) ) {
15 14 exit; // Exit if accessed directly.
16 15 }
@@ -19,11 +18,10 @@
19 18
20 19 const DOCUMENT_TYPE = 'landing-page';
21 20 const CPT = 'e-landing-page';
22 21 const ADMIN_PAGE_SLUG = 'edit.php?post_type=' . self::CPT;
23 - const ACTIVATION_KEY = 'elementor_landing_pages_activation';
24 22
25 - private $has_pages = null;
23 + private $posts;
26 24 private $trashed_posts;
27 25 private $new_lp_url;
28 26 private $permalink_structure;
29 27
@@ -31,55 +29,27 @@
31 29 return 'landing-pages';
32 30 }
33 31
34 32 /**
35 - * Register Experimental Feature
33 + * Get Experimental Data
36 34 *
37 35 * Implementation of this method makes the module an experiment.
38 36 *
39 - * @since 3.28.0
37 + * @since 3.1.0
38 + *
39 + * @return array
40 40 */
41 - private function register_experiment() {
42 - Plugin::$instance->experiments->add_feature( [
41 + public static function get_experimental_data() {
42 + return [
43 43 'name' => 'landing-pages',
44 44 'title' => esc_html__( 'Landing Pages', 'elementor' ),
45 45 'description' => esc_html__( 'Adds a new Elementor content type that allows creating beautiful landing pages instantly in a streamlined workflow.', 'elementor' ),
46 46 'release_status' => Experiments_Manager::RELEASE_STATUS_BETA,
47 47 'default' => Experiments_Manager::STATE_ACTIVE,
48 - 'new_site' => [
49 - 'default_inactive' => true,
50 - 'minimum_installation_version' => '3.22.0',
51 - ],
52 - 'deprecated' => true,
53 - ] );
48 + ];
54 49 }
55 50
56 51 /**
57 - * Should activate landing pages
58 - *
59 - * Checks whether the Landing Pages should be activated.
60 - *
61 - * If the activation key set to `1` in wp_options, the Landing Pages feature should be active. Otherwise not.
62 - * This is a backwards compatibility for websites that had Landing Pages, therefore couldn't be deactivated.
63 - * When deleting posts in Landing Pages CPT, Elementor checks again whether this feature should be activated.
64 - *
65 - * @since 3.31.0
66 - */
67 - private function should_activate_landing_pages() {
68 - if ( '1' === get_option( self::ACTIVATION_KEY ) ) {
69 - return true;
70 - }
71 -
72 - if ( $this->has_landing_pages() ) {
73 - update_option( self::ACTIVATION_KEY, '1' );
74 - return true;
75 - }
76 -
77 - update_option( self::ACTIVATION_KEY, '0' );
78 - return false;
79 - }
80 -
81 - /**
82 52 * Get Trashed Landing Pages Posts
83 53 *
84 54 * Returns the posts property of a WP_Query run for Landing Pages with post_status of 'trash'.
85 55 *
@@ -93,9 +63,8 @@
93 63 }
94 64
95 65 // `'posts_per_page' => 1` is because this is only used as an indicator to whether there are any trashed landing pages.
96 66 $trashed_posts_query = new \WP_Query( [
97 - 'no_found_rows' => true,
98 67 'post_type' => self::CPT,
99 68 'post_status' => 'trash',
100 69 'posts_per_page' => 1,
101 70 'meta_key' => '_elementor_template_type',
@@ -106,15 +75,24 @@
106 75
107 76 return $this->trashed_posts;
108 77 }
109 78
110 - private function has_landing_pages() {
111 - if ( null !== $this->has_pages ) {
112 - return $this->has_pages;
79 + /**
80 + * Get Landing Pages Posts
81 + *
82 + * Returns the posts property of a WP_Query run for posts with the Landing Pages CPT.
83 + *
84 + * @since 3.1.0
85 + *
86 + * @return array posts
87 + */
88 + private function get_landing_page_posts() {
89 + if ( $this->posts ) {
90 + return $this->posts;
113 91 }
114 92
93 + // `'posts_per_page' => 1` is because this is only used as an indicator to whether there are any landing pages.
115 94 $posts_query = new \WP_Query( [
116 - 'no_found_rows' => true,
117 95 'post_type' => self::CPT,
118 96 'post_status' => 'any',
119 97 'posts_per_page' => 1,
120 98 'meta_key' => '_elementor_template_type',
@@ -120,11 +98,11 @@
120 98 'meta_key' => '_elementor_template_type',
121 99 'meta_value' => self::DOCUMENT_TYPE,
122 100 ] );
123 101
124 - $this->has_pages = $posts_query->post_count > 0;
102 + $this->posts = $posts_query->posts;
125 103
126 - return $this->has_pages;
104 + return $this->posts;
127 105 }
128 106
129 107 /**
130 108 * Is Elementor Landing Page.
@@ -133,9 +111,9 @@
133 111 *
134 112 * @since 3.1.0
135 113 * @access public
136 114 *
137 - * @param \WP_Post $post Post Object.
115 + * @param \WP_Post $post Post Object
138 116 *
139 117 * @return bool Whether the post was built with Elementor.
140 118 */
141 119 public function is_elementor_landing_page( $post ) {
@@ -141,25 +119,38 @@
141 119 public function is_elementor_landing_page( $post ) {
142 120 return self::CPT === $post->post_type;
143 121 }
144 122
145 - public function get_menu_args() {
146 - if ( $this->has_landing_pages() ) {
147 - $menu_slug = self::ADMIN_PAGE_SLUG;
148 - $function = null;
123 + /**
124 + * Add Submenu Page
125 + *
126 + * Adds the 'Landing Pages' submenu item to the 'Templates' menu item.
127 + *
128 + * @since 3.1.0
129 + */
130 + private function add_submenu_page() {
131 + $posts = $this->get_landing_page_posts();
132 +
133 + // If there are no Landing Pages, show the "Create Your First Landing Page" page.
134 + // If there are, show the pages table.
135 + if ( ! empty( $posts ) ) {
136 + $landing_page_menu_slug = self::ADMIN_PAGE_SLUG;
137 + $landing_page_menu_callback = null;
149 138 } else {
150 - $menu_slug = self::CPT;
151 - $function = [ $this, 'print_empty_landing_pages_page' ];
139 + $landing_page_menu_slug = self::CPT;
140 + $landing_page_menu_callback = [ $this, 'print_empty_landing_pages_page' ];
152 141 }
153 142
154 - return [
155 - 'menu_slug' => $menu_slug,
156 - 'function' => $function,
157 - ];
158 - }
143 + $landing_pages_title = esc_html__( 'Landing Pages', 'elementor' );
159 144
160 - private function register_editor_one_menu( Menu_Data_Provider $menu_data_provider ): void {
161 - $menu_data_provider->register_menu( new Editor_One_Landing_Pages_Menu( $this ) );
145 + add_submenu_page(
146 + Source_Local::ADMIN_MENU_SLUG,
147 + $landing_pages_title,
148 + $landing_pages_title,
149 + 'manage_options',
150 + $landing_page_menu_slug,
151 + $landing_page_menu_callback
152 + );
162 153 }
163 154
164 155 /**
165 156 * Get 'Add New' Landing Page URL
@@ -202,9 +193,9 @@
202 193 <div class="e-trashed-items">
203 194 <?php
204 195 printf(
205 196 /* translators: %1$s Link open tag, %2$s: Link close tag. */
206 - esc_html__( 'Or view %1$sTrashed Items%2$s', 'elementor' ),
197 + esc_html__( 'Or view %1$sTrashed Items%1$s', 'elementor' ),
207 198 '<a href="' . esc_url( admin_url( 'edit.php?post_status=trash&post_type=' . self::CPT ) ) . '">',
208 199 '</a>'
209 200 );
210 201 ?>
@@ -245,9 +236,9 @@
245 236 'urls' => [
246 237 'addNewLandingPageUrl' => $this->get_add_new_landing_page_url(),
247 238 ],
248 239 'landingPages' => [
249 - 'landingPagesHasPages' => $this->has_landing_pages(),
240 + 'landingPagesHasPages' => [] !== $this->get_landing_page_posts(),
250 241 'isLandingPageAdminEdit' => $this->is_landing_page_admin_edit(),
251 242 ],
252 243 ];
253 244
@@ -311,9 +302,9 @@
311 302 return $post_link;
312 303 }
313 304
314 305 // Any slug prefixes need to be removed from the post link.
315 - return trailingslashit( get_home_url() ) . trailingslashit( $post->post_name );
306 + return get_home_url() . '/' . $post->post_name . '/';
316 307 }
317 308
318 309 /**
319 310 * Adjust Landing Page Query
@@ -407,9 +398,8 @@
407 398 }
408 399
409 400 // Search for a Landing Page with the same name passed as the 'category name'.
410 401 $possible_new_query = new \WP_Query( [
411 - 'no_found_rows' => true,
412 402 'post_type' => self::CPT,
413 403 'name' => $query->query['category_name'],
414 404 ] );
415 405
@@ -421,18 +411,8 @@
421 411 return false;
422 412 }
423 413
424 414 public function __construct() {
425 - if ( ! $this->should_activate_landing_pages() ) {
426 - return;
427 - }
428 -
429 - $this->register_experiment();
430 -
431 - if ( ! Plugin::$instance->experiments->is_feature_active( 'landing-pages' ) ) {
432 - return;
433 - }
434 -
435 415 $this->permalink_structure = get_option( 'permalink_structure' );
436 416
437 417 $this->register_landing_page_cpt();
438 418
@@ -461,20 +441,12 @@
461 441 add_action( 'elementor/documents/register', function( Documents_Manager $documents_manager ) {
462 442 $documents_manager->register_document_type( self::DOCUMENT_TYPE, Landing_Page::get_class_full_name() );
463 443 } );
464 444
465 - add_action( 'elementor/editor-one/menu/register', function ( Menu_Data_Provider $menu_data_provider ) {
466 - $this->register_editor_one_menu( $menu_data_provider );
467 - } );
445 + add_action( 'admin_menu', function() {
446 + $this->add_submenu_page();
447 + }, 30 );
468 448
469 - add_filter( 'elementor/editor-one/menu/elementor_post_types', function ( array $elementor_post_types ): array {
470 - $elementor_post_types[ static::CPT ] = [
471 - 'menu_slug' => 'elementor-editor-templates',
472 - 'child_slug' => 'edit.php?post_type=' . static::CPT,
473 - ];
474 - return $elementor_post_types;
475 - } );
476 -
477 449 // Add the custom 'Add New' link for Landing Pages into Elementor's admin config.
478 450 add_action( 'elementor/admin/localize_settings', function( array $settings ) {
479 451 return $this->admin_localize_settings( $settings );
480 452 } );
@@ -482,13 +454,8 @@
482 454 add_filter( 'elementor/template_library/sources/local/register_taxonomy_cpts', function( array $cpts ) {
483 455 $cpts[] = self::CPT;
484 456
485 457 return $cpts;
486 - } );
487 -
488 - // When deleting posts in Landing Page CPT, force Elementor to check again whether this feature should be activated.
489 - add_action( 'deleted_post_' . self::CPT, function () {
490 - delete_option( self::ACTIVATION_KEY );
491 458 } );
492 459
493 460 // In the Landing Pages Admin Table page - Overwrite Template type column header title.
494 461 add_action( 'manage_' . Landing_Pages_Module::CPT . '_posts_columns', function( $posts_columns ) {