| @@ -65,14 +65,13 @@ | ||
| 65 | 65 | true |
| 66 | 66 | ); |
| 67 | 67 | |
| 68 | 68 | // This is a core script of WordPress, it is not required to pass the 'ver' argument. |
| 69 | - // We should add dependencies to make sure that 'elementor-admin-bar' is loaded before 'admin-bar'. | |
| 70 | - wp_enqueue_script( | |
| 69 | + wp_enqueue_script( // phpcs:ignore WordPress.WP.EnqueuedResourceParameters | |
| 71 | 70 | 'admin-bar', |
| 72 | 71 | null, |
| 73 | 72 | [ 'elementor-admin-bar' ], |
| 74 | - false, // phpcs:ignore WordPress.WP.EnqueuedResourceParameters | |
| 73 | + false, | |
| 75 | 74 | true |
| 76 | 75 | ); |
| 77 | 76 | |
| 78 | 77 | $this->print_config( 'elementor-admin-bar' ); |
| @@ -90,19 +89,15 @@ | ||
| 90 | 89 | $settings['elementor_edit_page'] = $this->get_edit_button_config(); |
| 91 | 90 | } |
| 92 | 91 | |
| 93 | 92 | /** |
| 94 | - * Admin bar settings in the frontend. | |
| 93 | + * Register admin_bar config to parse later in the frontend and add to the admin bar with JS | |
| 95 | 94 | * |
| 96 | - * Register admin_bar config to parse later in the frontend and add to the admin bar with JS. | |
| 95 | + * @param array $settings the admin_bar config | |
| 97 | 96 | * |
| 98 | 97 | * @since 3.0.0 |
| 99 | - * | |
| 100 | - * @param array $settings the admin_bar config | |
| 101 | 98 | */ |
| 102 | - $settings = apply_filters( 'elementor/frontend/admin_bar/settings', $settings ); | |
| 103 | - | |
| 104 | - return $settings; | |
| 99 | + return apply_filters( 'elementor/frontend/admin_bar/settings', $settings ); | |
| 105 | 100 | } |
| 106 | 101 | |
| 107 | 102 | /** |
| 108 | 103 | * Creates the config for 'Edit with elementor' menu item. |
| @@ -120,9 +115,9 @@ | ||
| 120 | 115 | } |
| 121 | 116 | |
| 122 | 117 | return [ |
| 123 | 118 | 'id' => 'elementor_edit_page', |
| 124 | - 'title' => esc_html__( 'Edit with Elementor', 'elementor' ), | |
| 119 | + 'title' => __( 'Edit with Elementor', 'elementor' ), | |
| 125 | 120 | 'href' => $href, |
| 126 | 121 | 'children' => array_map( function ( $document ) { |
| 127 | 122 | return [ |
| 128 | 123 | 'id' => "elementor_edit_doc_{$document->get_main_id()}", |
| @@ -133,28 +128,8 @@ | ||
| 133 | 128 | }, $this->documents ), |
| 134 | 129 | ]; |
| 135 | 130 | } |
| 136 | 131 | |
| 137 | - public function add_clear_cache_in_admin_bar( $admin_bar_config ): array { | |
| 138 | - if ( current_user_can( 'manage_options' ) ) { | |
| 139 | - $clear_cache_url = add_query_arg( | |
| 140 | - [ | |
| 141 | - '_wpnonce' => wp_create_nonce( 'elementor_site_clear_cache' ), | |
| 142 | - ], | |
| 143 | - admin_url( 'admin-post.php?action=elementor_site_clear_cache' ), | |
| 144 | - ); | |
| 145 | - | |
| 146 | - $admin_bar_config['elementor_edit_page']['children'][] = [ | |
| 147 | - 'id' => 'elementor_site_clear_cache', | |
| 148 | - 'title' => esc_html__( 'Clear Files & Data', 'elementor' ), | |
| 149 | - 'sub_title' => esc_html__( 'Site', 'elementor' ), | |
| 150 | - 'href' => $clear_cache_url, | |
| 151 | - ]; | |
| 152 | - } | |
| 153 | - | |
| 154 | - return $admin_bar_config; | |
| 155 | - } | |
| 156 | - | |
| 157 | 132 | /** |
| 158 | 133 | * Module constructor. |
| 159 | 134 | */ |
| 160 | 135 | public function __construct() { |
| @@ -159,8 +134,6 @@ | ||
| 159 | 134 | */ |
| 160 | 135 | public function __construct() { |
| 161 | 136 | add_action( 'elementor/frontend/before_get_builder_content', [ $this, 'add_document_to_admin_bar' ], 10, 2 ); |
| 162 | 137 | add_action( 'wp_footer', [ $this, 'enqueue_scripts' ], 11 /* after third party scripts */ ); |
| 163 | - | |
| 164 | - add_filter( 'elementor/frontend/admin_bar/settings', [ $this, 'add_clear_cache_in_admin_bar' ], 500 ); | |
| 165 | 138 | } |
| 166 | 139 | } |