| @@ -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; |
| @@ -13,10 +17,8 @@ | ||
| 13 | 17 | use Elementor\Modules\FloatingButtons\Documents\Floating_Buttons; |
| 14 | 18 | use Elementor\Plugin; |
| 15 | 19 | use Elementor\TemplateLibrary\Source_Local; |
| 16 | 20 | use Elementor\Utils as ElementorUtils; |
| 17 | -use Elementor\Modules\EditorOne\Classes\Menu_Data_Provider; | |
| 18 | -use Elementor\Modules\FloatingButtons\AdminMenuItems\Editor_One_Floating_Elements_Menu; | |
| 19 | 21 | |
| 20 | 22 | if ( ! defined( 'ABSPATH' ) ) { |
| 21 | 23 | exit; // Exit if accessed directly. |
| 22 | 24 | } |
| @@ -57,10 +59,16 @@ | ||
| 57 | 59 | 'Floating_Bars_Var_1', |
| 58 | 60 | ]; |
| 59 | 61 | } |
| 60 | 62 | |
| 61 | - private function register_editor_one_menu( Menu_Data_Provider $menu_data_provider ) { | |
| 62 | - $menu_data_provider->register_menu( new Editor_One_Floating_Elements_Menu() ); | |
| 63 | + private function register_admin_menu_legacy( Admin_Menu_Manager $admin_menu ) { | |
| 64 | + $menu_args = $this->get_contact_menu_args(); | |
| 65 | + $function = $menu_args['function']; | |
| 66 | + if ( is_callable( $function ) ) { | |
| 67 | + $admin_menu->register( $menu_args['menu_slug'], new Floating_Buttons_Empty_View_Menu_Item( $function ) ); | |
| 68 | + } else { | |
| 69 | + $admin_menu->register( $menu_args['menu_slug'], new Floating_Buttons_Menu_Item() ); | |
| 70 | + }; | |
| 63 | 71 | } |
| 64 | 72 | |
| 65 | 73 | public function __construct() { |
| 66 | 74 | parent::__construct(); |
| @@ -92,16 +100,8 @@ | ||
| 92 | 100 | $this->flush_permalinks_on_elementor_version_change(); |
| 93 | 101 | } |
| 94 | 102 | }); |
| 95 | 103 | |
| 96 | - add_filter( 'elementor/editor-one/menu/elementor_post_types', function ( array $elementor_post_types ): array { | |
| 97 | - $elementor_post_types[ static::CPT_FLOATING_BUTTONS ] = [ | |
| 98 | - 'menu_slug' => 'elementor-editor-templates', | |
| 99 | - 'child_slug' => 'edit.php?post_type=e-floating-buttons', | |
| 100 | - ]; | |
| 101 | - return $elementor_post_types; | |
| 102 | - } ); | |
| 103 | - | |
| 104 | 104 | add_action( 'wp_ajax_elementor_send_clicks', [ $this, 'handle_click_tracking' ] ); |
| 105 | 105 | add_action( 'wp_ajax_nopriv_elementor_send_clicks', [ $this, 'handle_click_tracking' ] ); |
| 106 | 106 | |
| 107 | 107 | add_action( 'elementor/frontend/after_register_styles', [ $this, 'register_styles' ] ); |
| @@ -152,11 +152,11 @@ | ||
| 152 | 152 | |
| 153 | 153 | return $is_top_bar_active; |
| 154 | 154 | }, 10, 2 ); |
| 155 | 155 | |
| 156 | - add_action( 'elementor/editor-one/menu/register', function ( Menu_Data_Provider $menu_data_provider ) { | |
| 157 | - $this->register_editor_one_menu( $menu_data_provider ); | |
| 158 | - } ); | |
| 156 | + add_action( 'elementor/admin/menu/register', function( Admin_Menu_Manager $admin_menu ) { | |
| 157 | + $this->register_admin_menu_legacy( $admin_menu ); | |
| 158 | + }, Source_Local::ADMIN_MENU_PRIORITY + 20 ); | |
| 159 | 159 | |
| 160 | 160 | add_action( 'elementor/admin/localize_settings', function ( array $settings ) { |
| 161 | 161 | return $this->admin_localize_settings( $settings ); |
| 162 | 162 | } ); |
| @@ -237,9 +237,9 @@ | ||
| 237 | 237 | if ( ! isset( $posts_to_update[ $post_id ] ) ) { |
| 238 | 238 | $starting_clicks = (int) get_post_meta( $post_id, static::META_CLICK_TRACKING, true ); |
| 239 | 239 | $posts_to_update[ $post_id ] = $starting_clicks ? $starting_clicks : 0; |
| 240 | 240 | } |
| 241 | - ++$posts_to_update[ $post_id ]; | |
| 241 | + $posts_to_update[ $post_id ]++; | |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | foreach ( $posts_to_update as $post_id => $clicks ) { |
| 245 | 245 | if ( self::CPT_FLOATING_BUTTONS !== get_post_type( $post_id ) ) { |
| @@ -392,18 +392,9 @@ | ||
| 392 | 392 | 'labels' => $labels, |
| 393 | 393 | 'public' => true, |
| 394 | 394 | 'show_in_menu' => 'edit.php?post_type=elementor_library&tabs_group=library', |
| 395 | 395 | 'show_in_nav_menus' => false, |
| 396 | - 'capabilities' => [ | |
| 397 | - 'edit_post' => 'manage_options', | |
| 398 | - 'read_post' => 'manage_options', | |
| 399 | - 'delete_post' => 'manage_options', | |
| 400 | - 'edit_posts' => 'manage_options', | |
| 401 | - 'edit_others_posts' => 'manage_options', | |
| 402 | - 'publish_posts' => 'manage_options', | |
| 403 | - 'read_private_posts' => 'manage_options', | |
| 404 | - 'create_posts' => 'manage_options', | |
| 405 | - ], | |
| 396 | + 'capability_type' => 'post', | |
| 406 | 397 | 'taxonomies' => [ Source_Local::TAXONOMY_TYPE_SLUG ], |
| 407 | 398 | 'show_in_rest' => true, |
| 408 | 399 | 'supports' => [ |
| 409 | 400 | 'title', |