PluginProbe
Elementor Website Builder – more than just a page builder / 3.10.0-dev1
Elementor Website Builder – more than just a page builder v3.10.0-dev1
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/landing-pages/module.php +57 -69 4.2.33.10.0-dev1 View file →
@@ -1,14 +1,16 @@
1 1 <?php
2 2 namespace Elementor\Modules\LandingPages;
3 3
4 +use Elementor\Core\Admin\Menu\Admin_Menu_Manager;
5 +use Elementor\Core\Admin\Menu\Main as MainMenu;
4 6 use Elementor\Core\Base\Module as BaseModule;
5 7 use Elementor\Core\Documents_Manager;
6 8 use Elementor\Core\Experiments\Manager as Experiments_Manager;
7 9 use Elementor\Modules\LandingPages\Documents\Landing_Page;
8 -use Elementor\Modules\LandingPages\AdminMenuItems\Editor_One_Landing_Pages_Menu;
10 +use Elementor\Modules\LandingPages\AdminMenuItems\Landing_Pages_Menu_Item;
11 +use Elementor\Modules\LandingPages\AdminMenuItems\Landing_Pages_Empty_View_Menu_Item;
9 12 use Elementor\Modules\LandingPages\Module as Landing_Pages_Module;
10 -use Elementor\Modules\EditorOne\Classes\Menu_Data_Provider;
11 13 use Elementor\Plugin;
12 14 use Elementor\TemplateLibrary\Source_Local;
13 15
14 16 if ( ! defined( 'ABSPATH' ) ) {
@@ -19,9 +21,8 @@
19 21
20 22 const DOCUMENT_TYPE = 'landing-page';
21 23 const CPT = 'e-landing-page';
22 24 const ADMIN_PAGE_SLUG = 'edit.php?post_type=' . self::CPT;
23 - const ACTIVATION_KEY = 'elementor_landing_pages_activation';
24 25
25 26 private $has_pages = null;
26 27 private $trashed_posts;
27 28 private $new_lp_url;
@@ -31,55 +32,31 @@
31 32 return 'landing-pages';
32 33 }
33 34
34 35 /**
35 - * Register Experimental Feature
36 + * Get Experimental Data
36 37 *
37 38 * Implementation of this method makes the module an experiment.
38 39 *
39 - * @since 3.28.0
40 + * @since 3.1.0
41 + *
42 + * @return array
40 43 */
41 - private function register_experiment() {
42 - Plugin::$instance->experiments->add_feature( [
44 + public static function get_experimental_data() {
45 + return [
43 46 'name' => 'landing-pages',
44 47 'title' => esc_html__( 'Landing Pages', 'elementor' ),
45 48 'description' => esc_html__( 'Adds a new Elementor content type that allows creating beautiful landing pages instantly in a streamlined workflow.', 'elementor' ),
46 - 'release_status' => Experiments_Manager::RELEASE_STATUS_BETA,
49 + 'release_status' => Experiments_Manager::RELEASE_STATUS_STABLE,
47 50 'default' => Experiments_Manager::STATE_ACTIVE,
48 51 'new_site' => [
49 - 'default_inactive' => true,
50 - 'minimum_installation_version' => '3.22.0',
52 + 'default_active' => true,
53 + 'minimum_installation_version' => '3.1.0-beta',
51 54 ],
52 - 'deprecated' => true,
53 - ] );
55 + ];
54 56 }
55 57
56 58 /**
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 59 * Get Trashed Landing Pages Posts
83 60 *
84 61 * Returns the posts property of a WP_Query run for Landing Pages with post_status of 'trash'.
85 62 *
@@ -133,9 +110,9 @@
133 110 *
134 111 * @since 3.1.0
135 112 * @access public
136 113 *
137 - * @param \WP_Post $post Post Object.
114 + * @param \WP_Post $post Post Object
138 115 *
139 116 * @return bool Whether the post was built with Elementor.
140 117 */
141 118 public function is_elementor_landing_page( $post ) {
@@ -141,9 +118,9 @@
141 118 public function is_elementor_landing_page( $post ) {
142 119 return self::CPT === $post->post_type;
143 120 }
144 121
145 - public function get_menu_args() {
122 + private function get_menu_args() {
146 123 if ( $this->has_landing_pages() ) {
147 124 $menu_slug = self::ADMIN_PAGE_SLUG;
148 125 $function = null;
149 126 } else {
@@ -156,13 +133,41 @@
156 133 'function' => $function,
157 134 ];
158 135 }
159 136
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 ) );
137 + private function register_admin_menu( MainMenu $menu ) {
138 + $landing_pages_title = esc_html__( 'Landing Pages', 'elementor' );
139 +
140 + $menu_args = array_merge( $this->get_menu_args(), [
141 + 'page_title' => $landing_pages_title,
142 + 'menu_title' => $landing_pages_title,
143 + 'index' => 20,
144 + ] );
145 +
146 + $menu->add_submenu( $menu_args );
162 147 }
163 148
164 149 /**
150 + * Add Submenu Page
151 + *
152 + * Adds the 'Landing Pages' submenu item to the 'Templates' menu item.
153 + *
154 + * @since 3.1.0
155 + */
156 + private function register_admin_menu_legacy( Admin_Menu_Manager $admin_menu ) {
157 + $menu_args = $this->get_menu_args();
158 +
159 + $slug = $menu_args['menu_slug'];
160 + $function = $menu_args['function'];
161 +
162 + if ( is_callable( $function ) ) {
163 + $admin_menu->register( $slug, new Landing_Pages_Empty_View_Menu_Item( $function ) );
164 + } else {
165 + $admin_menu->register( $slug, new Landing_Pages_Menu_Item() );
166 + }
167 + }
168 +
169 + /**
165 170 * Get 'Add New' Landing Page URL
166 171 *
167 172 * Retrieves the custom URL for the admin dashboard's 'Add New' button in the Landing Pages admin screen. This URL
168 173 * creates a new Landing Pages and directly opens the Elementor Editor with the Template Library modal open on the
@@ -202,9 +207,9 @@
202 207 <div class="e-trashed-items">
203 208 <?php
204 209 printf(
205 210 /* translators: %1$s Link open tag, %2$s: Link close tag. */
206 - esc_html__( 'Or view %1$sTrashed Items%2$s', 'elementor' ),
211 + esc_html__( 'Or view %1$sTrashed Items%1$s', 'elementor' ),
207 212 '<a href="' . esc_url( admin_url( 'edit.php?post_status=trash&post_type=' . self::CPT ) ) . '">',
208 213 '</a>'
209 214 );
210 215 ?>
@@ -311,9 +316,9 @@
311 316 return $post_link;
312 317 }
313 318
314 319 // Any slug prefixes need to be removed from the post link.
315 - return trailingslashit( get_home_url() ) . trailingslashit( $post->post_name );
320 + return get_home_url() . '/' . $post->post_name . '/';
316 321 }
317 322
318 323 /**
319 324 * Adjust Landing Page Query
@@ -421,18 +426,8 @@
421 426 return false;
422 427 }
423 428
424 429 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 430 $this->permalink_structure = get_option( 'permalink_structure' );
436 431
437 432 $this->register_landing_page_cpt();
438 433
@@ -461,20 +456,18 @@
461 456 add_action( 'elementor/documents/register', function( Documents_Manager $documents_manager ) {
462 457 $documents_manager->register_document_type( self::DOCUMENT_TYPE, Landing_Page::get_class_full_name() );
463 458 } );
464 459
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 - } );
460 + if ( Plugin::$instance->experiments->is_feature_active( 'admin_menu_rearrangement' ) ) {
461 + add_action( 'elementor/admin/menu_registered/elementor', function( MainMenu $menu ) {
462 + $this->register_admin_menu( $menu );
463 + } );
464 + } else {
465 + add_action( 'elementor/admin/menu/register', function( Admin_Menu_Manager $admin_menu ) {
466 + $this->register_admin_menu_legacy( $admin_menu );
467 + }, Source_Local::ADMIN_MENU_PRIORITY + 20 );
468 + }
468 469
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 470 // Add the custom 'Add New' link for Landing Pages into Elementor's admin config.
478 471 add_action( 'elementor/admin/localize_settings', function( array $settings ) {
479 472 return $this->admin_localize_settings( $settings );
480 473 } );
@@ -482,13 +475,8 @@
482 475 add_filter( 'elementor/template_library/sources/local/register_taxonomy_cpts', function( array $cpts ) {
483 476 $cpts[] = self::CPT;
484 477
485 478 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 479 } );
492 480
493 481 // In the Landing Pages Admin Table page - Overwrite Template type column header title.
494 482 add_action( 'manage_' . Landing_Pages_Module::CPT . '_posts_columns', function( $posts_columns ) {