| @@ -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' ) ) { |
| @@ -141,9 +143,9 @@ | ||
| 141 | 143 | public function is_elementor_landing_page( $post ) { |
| 142 | 144 | return self::CPT === $post->post_type; |
| 143 | 145 | } |
| 144 | 146 | |
| 145 | - public function get_menu_args() { | |
| 147 | + private function get_menu_args() { | |
| 146 | 148 | if ( $this->has_landing_pages() ) { |
| 147 | 149 | $menu_slug = self::ADMIN_PAGE_SLUG; |
| 148 | 150 | $function = null; |
| 149 | 151 | } else { |
| @@ -156,13 +158,41 @@ | ||
| 156 | 158 | 'function' => $function, |
| 157 | 159 | ]; |
| 158 | 160 | } |
| 159 | 161 | |
| 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 ) ); | |
| 162 | + private function register_admin_menu( MainMenu $menu ) { | |
| 163 | + $landing_pages_title = esc_html__( 'Landing Pages', 'elementor' ); | |
| 164 | + | |
| 165 | + $menu_args = array_merge( $this->get_menu_args(), [ | |
| 166 | + 'page_title' => $landing_pages_title, | |
| 167 | + 'menu_title' => $landing_pages_title, | |
| 168 | + 'index' => 20, | |
| 169 | + ] ); | |
| 170 | + | |
| 171 | + $menu->add_submenu( $menu_args ); | |
| 162 | 172 | } |
| 163 | 173 | |
| 164 | 174 | /** |
| 175 | + * Add Submenu Page | |
| 176 | + * | |
| 177 | + * Adds the 'Landing Pages' submenu item to the 'Templates' menu item. | |
| 178 | + * | |
| 179 | + * @since 3.1.0 | |
| 180 | + */ | |
| 181 | + private function register_admin_menu_legacy( Admin_Menu_Manager $admin_menu ) { | |
| 182 | + $menu_args = $this->get_menu_args(); | |
| 183 | + | |
| 184 | + $slug = $menu_args['menu_slug']; | |
| 185 | + $function = $menu_args['function']; | |
| 186 | + | |
| 187 | + if ( is_callable( $function ) ) { | |
| 188 | + $admin_menu->register( $slug, new Landing_Pages_Empty_View_Menu_Item( $function ) ); | |
| 189 | + } else { | |
| 190 | + $admin_menu->register( $slug, new Landing_Pages_Menu_Item() ); | |
| 191 | + } | |
| 192 | + } | |
| 193 | + | |
| 194 | + /** | |
| 165 | 195 | * Get 'Add New' Landing Page URL |
| 166 | 196 | * |
| 167 | 197 | * Retrieves the custom URL for the admin dashboard's 'Add New' button in the Landing Pages admin screen. This URL |
| 168 | 198 | * creates a new Landing Pages and directly opens the Elementor Editor with the Template Library modal open on the |
| @@ -461,19 +491,11 @@ | ||
| 461 | 491 | add_action( 'elementor/documents/register', function( Documents_Manager $documents_manager ) { |
| 462 | 492 | $documents_manager->register_document_type( self::DOCUMENT_TYPE, Landing_Page::get_class_full_name() ); |
| 463 | 493 | } ); |
| 464 | 494 | |
| 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 | - } ); | |
| 468 | - | |
| 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 | - } ); | |
| 495 | + add_action( 'elementor/admin/menu/register', function( Admin_Menu_Manager $admin_menu ) { | |
| 496 | + $this->register_admin_menu_legacy( $admin_menu ); | |
| 497 | + }, Source_Local::ADMIN_MENU_PRIORITY + 20 ); | |
| 476 | 498 | |
| 477 | 499 | // Add the custom 'Add New' link for Landing Pages into Elementor's admin config. |
| 478 | 500 | add_action( 'elementor/admin/localize_settings', function( array $settings ) { |
| 479 | 501 | return $this->admin_localize_settings( $settings ); |