| @@ -2,12 +2,16 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace Elementor\Modules\FloatingButtons; |
| 4 | 4 | |
| 5 | 5 | use Elementor\Controls_Manager; |
| 6 | +use Elementor\Core\Admin\Menu\Admin_Menu_Manager; | |
| 6 | 7 | use Elementor\Core\Base\Document; |
| 7 | 8 | use Elementor\Core\Base\Module as BaseModule; |
| 8 | 9 | use Elementor\Core\Documents_Manager; |
| 10 | +use Elementor\Core\Experiments\Manager; | |
| 9 | 11 | use Elementor\Modules\FloatingButtons\Base\Widget_Floating_Bars_Base; |
| 12 | +use Elementor\Modules\FloatingButtons\AdminMenuItems\Floating_Buttons_Empty_View_Menu_Item; | |
| 13 | +use Elementor\Modules\FloatingButtons\AdminMenuItems\Floating_Buttons_Menu_Item; | |
| 10 | 14 | use Elementor\Modules\FloatingButtons\Base\Widget_Contact_Button_Base; |
| 11 | 15 | use Elementor\Modules\FloatingButtons\Classes\Action\Action_Handler; |
| 12 | 16 | use Elementor\Modules\FloatingButtons\Control\Hover_Animation_Floating_Buttons; |
| 13 | 17 | use Elementor\Modules\FloatingButtons\Documents\Floating_Buttons; |
| @@ -57,12 +61,28 @@ | ||
| 57 | 61 | 'Floating_Bars_Var_1', |
| 58 | 62 | ]; |
| 59 | 63 | } |
| 60 | 64 | |
| 65 | + private function register_admin_menu_legacy( Admin_Menu_Manager $admin_menu ) { | |
| 66 | + if ( ! $this->is_editor_one_active() ) { | |
| 67 | + $menu_args = $this->get_contact_menu_args(); | |
| 68 | + $function = $menu_args['function']; | |
| 69 | + if ( is_callable( $function ) ) { | |
| 70 | + $admin_menu->register( $menu_args['menu_slug'], new Floating_Buttons_Empty_View_Menu_Item( $function ) ); | |
| 71 | + } else { | |
| 72 | + $admin_menu->register( $menu_args['menu_slug'], new Floating_Buttons_Menu_Item() ); | |
| 73 | + } | |
| 74 | + } | |
| 75 | + } | |
| 76 | + | |
| 61 | 77 | private function register_editor_one_menu( Menu_Data_Provider $menu_data_provider ) { |
| 62 | 78 | $menu_data_provider->register_menu( new Editor_One_Floating_Elements_Menu() ); |
| 63 | 79 | } |
| 64 | 80 | |
| 81 | + private function is_editor_one_active(): bool { | |
| 82 | + return (bool) Plugin::instance()->modules_manager->get_modules( 'editor-one' ); | |
| 83 | + } | |
| 84 | + | |
| 65 | 85 | public function __construct() { |
| 66 | 86 | parent::__construct(); |
| 67 | 87 | |
| 68 | 88 | if ( Floating_Buttons::is_creating_floating_buttons_page() || Floating_Buttons::is_editing_existing_floating_buttons_page() ) { |
| @@ -94,10 +114,10 @@ | ||
| 94 | 114 | }); |
| 95 | 115 | |
| 96 | 116 | add_filter( 'elementor/editor-one/menu/elementor_post_types', function ( array $elementor_post_types ): array { |
| 97 | 117 | $elementor_post_types[ static::CPT_FLOATING_BUTTONS ] = [ |
| 98 | - 'menu_slug' => 'elementor-editor-templates', | |
| 99 | - 'child_slug' => 'edit.php?post_type=e-floating-buttons', | |
| 118 | + 'menu_slug' => 'elementor-templates', | |
| 119 | + 'child_slug' => 'floating-elements', | |
| 100 | 120 | ]; |
| 101 | 121 | return $elementor_post_types; |
| 102 | 122 | } ); |
| 103 | 123 | |
| @@ -151,8 +171,12 @@ | ||
| 151 | 171 | } |
| 152 | 172 | |
| 153 | 173 | return $is_top_bar_active; |
| 154 | 174 | }, 10, 2 ); |
| 175 | + | |
| 176 | + add_action( 'elementor/admin/menu/register', function( Admin_Menu_Manager $admin_menu ) { | |
| 177 | + $this->register_admin_menu_legacy( $admin_menu ); | |
| 178 | + }, Source_Local::ADMIN_MENU_PRIORITY + 20 ); | |
| 155 | 179 | |
| 156 | 180 | add_action( 'elementor/editor-one/menu/register', function ( Menu_Data_Provider $menu_data_provider ) { |
| 157 | 181 | $this->register_editor_one_menu( $menu_data_provider ); |
| 158 | 182 | } ); |