| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\LandingPages\AdminMenuItems; |
| 4 |
|
| 5 |
use Elementor\Core\Admin\Menu\Interfaces\Admin_Menu_Item_With_Page; |
| 6 |
use Elementor\Core\Admin\EditorOneMenu\Interfaces\Menu_Item_Interface; |
| 7 |
use Elementor\Modules\EditorOne\Classes\Menu_Config; |
| 8 |
use Elementor\Modules\LandingPages\Module; |
| 9 |
|
| 10 |
if ( ! defined( 'ABSPATH' ) ) { |
| 11 |
exit; |
| 12 |
} |
| 13 |
|
| 14 |
class Editor_One_Landing_Pages_Menu implements Menu_Item_Interface, Admin_Menu_Item_With_Page { |
| 15 |
|
| 16 |
private $module; |
| 17 |
private $menu_item; |
| 18 |
|
| 19 |
public function __construct( Module $module ) { |
| 20 |
$this->module = $module; |
| 21 |
$this->initialize_menu_item(); |
| 22 |
} |
| 23 |
|
| 24 |
private function initialize_menu_item() { |
| 25 |
$menu_args = $this->module->get_menu_args(); |
| 26 |
$slug = $menu_args['menu_slug']; |
| 27 |
$function = $menu_args['function']; |
| 28 |
|
| 29 |
if ( is_callable( $function ) ) { |
| 30 |
$this->menu_item = new Landing_Pages_Empty_View_Menu_Item( $function ); |
| 31 |
} else { |
| 32 |
$this->menu_item = new Landing_Pages_Menu_Item(); |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
public function get_capability(): string { |
| 37 |
return 'manage_options'; |
| 38 |
} |
| 39 |
|
| 40 |
public function get_parent_slug(): string { |
| 41 |
return Menu_Config::ELEMENTOR_MENU_SLUG; |
| 42 |
} |
| 43 |
|
| 44 |
public function is_visible(): bool { |
| 45 |
return true; |
| 46 |
} |
| 47 |
|
| 48 |
public function get_label(): string { |
| 49 |
return esc_html__( 'Landing Pages', 'elementor' ); |
| 50 |
} |
| 51 |
|
| 52 |
public function get_position(): int { |
| 53 |
return 20; |
| 54 |
} |
| 55 |
|
| 56 |
public function get_slug(): string { |
| 57 |
$menu_args = $this->module->get_menu_args(); |
| 58 |
return $menu_args['menu_slug']; |
| 59 |
} |
| 60 |
|
| 61 |
public function get_group_id(): string { |
| 62 |
return Menu_Config::TEMPLATES_GROUP_ID; |
| 63 |
} |
| 64 |
|
| 65 |
public function get_page_title(): string { |
| 66 |
return $this->get_label(); |
| 67 |
} |
| 68 |
|
| 69 |
public function render() { |
| 70 |
if ( $this->menu_item instanceof Admin_Menu_Item_With_Page ) { |
| 71 |
$this->menu_item->render(); |
| 72 |
} else { |
| 73 |
wp_safe_redirect( admin_url( Module::ADMIN_PAGE_SLUG ) ); |
| 74 |
exit; |
| 75 |
} |
| 76 |
} |
| 77 |
} |
| 78 |
|