| @@ -1,8 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Elementor; |
| 3 | 3 | |
| 4 | -use Elementor\Core\Editor\Editor; | |
| 4 | +use Elementor\Core\Admin\Menu\Admin_Menu_Manager; | |
| 5 | +use Elementor\Includes\Settings\AdminMenuItems\Admin_Menu_Item; | |
| 6 | +use Elementor\Includes\Settings\AdminMenuItems\Get_Help_Menu_Item; | |
| 7 | +use Elementor\Includes\Settings\AdminMenuItems\Getting_Started_Menu_Item; | |
| 8 | +use Elementor\Modules\Promotions\Module as Promotions_Module; | |
| 5 | 9 | use Elementor\TemplateLibrary\Source_Local; |
| 6 | 10 | |
| 7 | 11 | if ( ! defined( 'ABSPATH' ) ) { |
| 8 | 12 | exit; // Exit if accessed directly. |
| @@ -52,8 +56,10 @@ | ||
| 52 | 56 | * Settings page advanced tab slug. |
| 53 | 57 | */ |
| 54 | 58 | const TAB_ADVANCED = 'advanced'; |
| 55 | 59 | |
| 60 | + const ADMIN_MENU_PRIORITY = 10; | |
| 61 | + | |
| 56 | 62 | /** |
| 57 | 63 | * Register admin menu. |
| 58 | 64 | * |
| 59 | 65 | * Add new Elementor Settings admin menu. |
| @@ -120,71 +126,8 @@ | ||
| 120 | 126 | return $elementor_menu_order; |
| 121 | 127 | } |
| 122 | 128 | |
| 123 | 129 | /** |
| 124 | - * Register Elementor Pro sub-menu. | |
| 125 | - * | |
| 126 | - * Add new Elementor Pro sub-menu under the main Elementor menu. | |
| 127 | - * | |
| 128 | - * Fired by `admin_menu` action. | |
| 129 | - * | |
| 130 | - * @since 1.0.0 | |
| 131 | - * @access public | |
| 132 | - */ | |
| 133 | - public function register_pro_menu() { | |
| 134 | - add_submenu_page( | |
| 135 | - self::PAGE_ID, | |
| 136 | - esc_html__( 'Submissions', 'elementor' ), | |
| 137 | - esc_html__( 'Submissions', 'elementor' ), | |
| 138 | - 'manage_options', | |
| 139 | - 'e-form-submissions', | |
| 140 | - function() { | |
| 141 | - $this->elementor_form_submissions(); | |
| 142 | - } | |
| 143 | - ); | |
| 144 | - | |
| 145 | - add_submenu_page( | |
| 146 | - self::PAGE_ID, | |
| 147 | - esc_html__( 'Custom Fonts', 'elementor' ), | |
| 148 | - esc_html__( 'Custom Fonts', 'elementor' ), | |
| 149 | - 'manage_options', | |
| 150 | - 'elementor_custom_fonts', | |
| 151 | - [ $this, 'elementor_custom_fonts' ] | |
| 152 | - ); | |
| 153 | - | |
| 154 | - add_submenu_page( | |
| 155 | - self::PAGE_ID, | |
| 156 | - esc_html__( 'Custom Icons', 'elementor' ), | |
| 157 | - esc_html__( 'Custom Icons', 'elementor' ), | |
| 158 | - 'manage_options', | |
| 159 | - 'elementor_custom_icons', | |
| 160 | - [ $this, 'elementor_custom_icons' ] | |
| 161 | - ); | |
| 162 | - | |
| 163 | - add_submenu_page( | |
| 164 | - self::PAGE_ID, | |
| 165 | - __( 'Custom Code', 'elementor' ), | |
| 166 | - __( 'Custom Code', 'elementor' ), | |
| 167 | - 'manage_options', | |
| 168 | - 'elementor_custom_custom_code', | |
| 169 | - function() { | |
| 170 | - $this->elementor_custom_code(); | |
| 171 | - } | |
| 172 | - ); | |
| 173 | - | |
| 174 | - add_submenu_page( | |
| 175 | - self::PAGE_ID, | |
| 176 | - '', | |
| 177 | - '<span class="dashicons dashicons-star-filled" style="font-size: 17px"></span> ' . esc_html__( 'Upgrade', 'elementor' ), | |
| 178 | - 'manage_options', | |
| 179 | - 'go_elementor_pro', | |
| 180 | - [ $this, 'handle_external_redirects' ] | |
| 181 | - ); | |
| 182 | - | |
| 183 | - add_submenu_page( Source_Local::ADMIN_MENU_SLUG, esc_html__( 'Popups', 'elementor' ), esc_html__( 'Popups', 'elementor' ), 'manage_options', 'popup_templates', [ $this, 'elementor_popups' ] ); | |
| 184 | - } | |
| 185 | - | |
| 186 | - /** | |
| 187 | 130 | * Register Elementor knowledge base sub-menu. |
| 188 | 131 | * |
| 189 | 132 | * Add new Elementor knowledge base sub-menu under the main Elementor menu. |
| 190 | 133 | * |
| @@ -190,28 +133,13 @@ | ||
| 190 | 133 | * |
| 191 | 134 | * Fired by `admin_menu` action. |
| 192 | 135 | * |
| 193 | 136 | * @since 2.0.3 |
| 194 | - * @access public | |
| 137 | + * @access private | |
| 195 | 138 | */ |
| 196 | - public function register_knowledge_base_menu() { | |
| 197 | - add_submenu_page( | |
| 198 | - self::PAGE_ID, | |
| 199 | - '', | |
| 200 | - __( 'Getting Started', 'elementor' ), | |
| 201 | - 'manage_options', | |
| 202 | - 'elementor-getting-started', | |
| 203 | - [ $this, 'elementor_getting_started' ] | |
| 204 | - ); | |
| 205 | - | |
| 206 | - add_submenu_page( | |
| 207 | - self::PAGE_ID, | |
| 208 | - '', | |
| 209 | - esc_html__( 'Get Help', 'elementor' ), | |
| 210 | - 'manage_options', | |
| 211 | - 'go_knowledge_base_site', | |
| 212 | - [ $this, 'handle_external_redirects' ] | |
| 213 | - ); | |
| 139 | + private function register_knowledge_base_menu( Admin_Menu_Manager $admin_menu ) { | |
| 140 | + $admin_menu->register( 'elementor-getting-started', new Getting_Started_Menu_Item() ); | |
| 141 | + $admin_menu->register( 'go_knowledge_base_site', new Get_Help_Menu_Item() ); | |
| 214 | 142 | } |
| 215 | 143 | |
| 216 | 144 | /** |
| 217 | 145 | * Go Elementor Pro. |
| @@ -227,160 +155,15 @@ | ||
| 227 | 155 | if ( empty( $_GET['page'] ) ) { |
| 228 | 156 | return; |
| 229 | 157 | } |
| 230 | 158 | |
| 231 | - if ( 'go_elementor_pro' === $_GET['page'] ) { | |
| 232 | - wp_redirect( 'https://go.elementor.com/pro-admin-menu/' ); | |
| 233 | - die; | |
| 234 | - } | |
| 235 | - | |
| 236 | 159 | if ( 'go_knowledge_base_site' === $_GET['page'] ) { |
| 237 | - wp_redirect( 'https://go.elementor.com/docs-admin-menu/' ); | |
| 160 | + wp_redirect( Get_Help_Menu_Item::URL ); | |
| 238 | 161 | die; |
| 239 | 162 | } |
| 240 | 163 | } |
| 241 | 164 | |
| 242 | 165 | /** |
| 243 | - * Display settings page. | |
| 244 | - * | |
| 245 | - * Output the content for the getting started page. | |
| 246 | - * | |
| 247 | - * @since 2.2.0 | |
| 248 | - * @access public | |
| 249 | - */ | |
| 250 | - public function elementor_getting_started() { | |
| 251 | - if ( User::is_current_user_can_edit_post_type( 'page' ) ) { | |
| 252 | - $create_new_label = esc_html__( 'Create Your First Page', 'elementor' ); | |
| 253 | - $create_new_cpt = 'page'; | |
| 254 | - } elseif ( User::is_current_user_can_edit_post_type( 'post' ) ) { | |
| 255 | - $create_new_label = esc_html__( 'Create Your First Post', 'elementor' ); | |
| 256 | - $create_new_cpt = 'post'; | |
| 257 | - } | |
| 258 | - | |
| 259 | - ?> | |
| 260 | - <div class="wrap"> | |
| 261 | - <div class="e-getting-started"> | |
| 262 | - <div class="e-getting-started__box postbox"> | |
| 263 | - <div class="e-getting-started__header"> | |
| 264 | - <div class="e-getting-started__title"> | |
| 265 | - <div class="e-logo-wrapper"> | |
| 266 | - <i class="eicon-elementor"></i> | |
| 267 | - </div> | |
| 268 | - <?php echo esc_html__( 'Getting Started', 'elementor' ); ?> | |
| 269 | - </div> | |
| 270 | - <a class="e-getting-started__skip" href="<?php echo esc_url( admin_url() ); ?>"> | |
| 271 | - <i class="eicon-close" aria-hidden="true" title="<?php esc_attr_e( 'Skip', 'elementor' ); ?>"></i> | |
| 272 | - <span class="elementor-screen-only"><?php echo esc_html__( 'Skip', 'elementor' ); ?></span> | |
| 273 | - </a> | |
| 274 | - </div> | |
| 275 | - <div class="e-getting-started__content"> | |
| 276 | - <div class="e-getting-started__content--narrow"> | |
| 277 | - <h2><?php echo esc_html__( 'Welcome to Elementor', 'elementor' ); ?></h2> | |
| 278 | - <p><?php echo esc_html__( 'Get introduced to Elementor by watching our "Getting Started" video series. It will guide you through the steps needed to create your website. Then click to create your first page.', 'elementor' ); ?></p> | |
| 279 | - </div> | |
| 280 | - | |
| 281 | - <div class="e-getting-started__video"> | |
| 282 | - <iframe width="620" height="350" src="https://www.youtube-nocookie.com/embed/videoseries?v=icTcREd1tAg&list=PLZyp9H25CboE6dhe7MnUxUdp4zU7OsNSe&index=1" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> | |
| 283 | - </div> | |
| 284 | - | |
| 285 | - <div class="e-getting-started__actions e-getting-started__content--narrow"> | |
| 286 | - <?php if ( ! empty( $create_new_cpt ) ) : ?> | |
| 287 | - <a href="<?php echo esc_url( Plugin::$instance->documents->get_create_new_post_url( $create_new_cpt ) ); ?>" class="button button-primary button-hero"><?php echo esc_html( $create_new_label ); ?></a> | |
| 288 | - <?php endif; ?> | |
| 289 | - | |
| 290 | - <a href="https://go.elementor.com/getting-started/" target="_blank" class="button button-secondary button-hero"><?php echo esc_html__( 'Watch the Full Guide', 'elementor' ); ?></a> | |
| 291 | - </div> | |
| 292 | - </div> | |
| 293 | - </div> | |
| 294 | - </div> | |
| 295 | - </div><!-- /.wrap --> | |
| 296 | - <?php | |
| 297 | - } | |
| 298 | - | |
| 299 | - /** | |
| 300 | - * Display settings page. | |
| 301 | - * | |
| 302 | - * Output the content for the custom fonts page. | |
| 303 | - * | |
| 304 | - * @since 2.0.0 | |
| 305 | - * @access public | |
| 306 | - */ | |
| 307 | - public function elementor_custom_fonts() { | |
| 308 | - ?> | |
| 309 | - <div class="wrap"> | |
| 310 | - <div class="elementor-blank_state"> | |
| 311 | - <?php // PHPCS - No need to escape an SVG image from the Elementor assets/images folder. ?> | |
| 312 | - <img src="<?php echo ELEMENTOR_ASSETS_URL . 'images/go-pro-wp-dashboard.svg'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>" /> | |
| 313 | - <h2><?php echo esc_html__( 'Add Your Custom Fonts', 'elementor' ); ?></h2> | |
| 314 | - <p><?php echo esc_html__( 'Custom Fonts allows you to add your self-hosted fonts and use them on your Elementor projects to create a unique brand language.', 'elementor' ); ?></p> | |
| 315 | - <a class="elementor-button elementor-button-default elementor-button-go-pro" target="_blank" href="https://go.elementor.com/go-pro-custom-fonts/"><?php echo esc_html__( 'Upgrade Now', 'elementor' ); ?></a> | |
| 316 | - </div> | |
| 317 | - </div><!-- /.wrap --> | |
| 318 | - <?php | |
| 319 | - } | |
| 320 | - | |
| 321 | - /** | |
| 322 | - * Display settings page. | |
| 323 | - * | |
| 324 | - * Output the content for the custom icons page. | |
| 325 | - * | |
| 326 | - * @since 2.8.0 | |
| 327 | - * @access public | |
| 328 | - */ | |
| 329 | - public function elementor_custom_icons() { | |
| 330 | - ?> | |
| 331 | - <div class="wrap"> | |
| 332 | - <div class="elementor-blank_state"> | |
| 333 | - <img src="<?php Utils::print_unescaped_internal_string( ELEMENTOR_ASSETS_URL . 'images/go-pro-wp-dashboard.svg' ); ?>" /> | |
| 334 | - <h2><?php echo esc_html__( 'Add Your Custom Icons', 'elementor' ); ?></h2> | |
| 335 | - <p><?php echo esc_html__( 'Don\'t rely solely on the FontAwesome icons everyone else is using! Differentiate your website and your style with custom icons you can upload from your favorite icons source.', 'elementor' ); ?></p> | |
| 336 | - <a class="elementor-button elementor-button-default elementor-button-go-pro" target="_blank" href="https://go.elementor.com/go-pro-custom-icons/"><?php echo esc_html__( 'Upgrade Now', 'elementor' ); ?></a> | |
| 337 | - </div> | |
| 338 | - </div><!-- /.wrap --> | |
| 339 | - <?php | |
| 340 | - } | |
| 341 | - | |
| 342 | - /** | |
| 343 | - * Display settings page. | |
| 344 | - * | |
| 345 | - * Output the content for the Popups page. | |
| 346 | - * | |
| 347 | - * @since 2.4.0 | |
| 348 | - * @access public | |
| 349 | - */ | |
| 350 | - public function elementor_popups() { | |
| 351 | - ?> | |
| 352 | - <div class="wrap"> | |
| 353 | - <div class="elementor-blank_state"> | |
| 354 | - <img src="<?php Utils::print_unescaped_internal_string( ELEMENTOR_ASSETS_URL . 'images/go-pro-wp-dashboard.svg' ); ?>" /> | |
| 355 | - <h2><?php echo esc_html__( 'Get Popup Builder', 'elementor' ); ?></h2> | |
| 356 | - <p><?php echo esc_html__( 'Popup Builder lets you take advantage of all the amazing features in Elementor, so you can build beautiful & highly converting popups. Go pro and start designing your popups today.', 'elementor' ); ?></p> | |
| 357 | - <a class="elementor-button elementor-button-default elementor-button-go-pro" target="_blank" href="https://go.elementor.com/go-pro-popup-builder/"><?php echo esc_html__( 'Upgrade Now', 'elementor' ); ?></a> | |
| 358 | - </div> | |
| 359 | - </div><!-- /.wrap --> | |
| 360 | - <?php | |
| 361 | - } | |
| 362 | - | |
| 363 | - public function elementor_form_submissions() { | |
| 364 | - ?> | |
| 365 | - <div class="wrap"> | |
| 366 | - <div class="elementor-blank_state"> | |
| 367 | - <img src="<?php Utils::print_unescaped_internal_string( ELEMENTOR_ASSETS_URL ); ?>images/go-pro-wp-dashboard.svg" /> | |
| 368 | - <h2><?php echo esc_html__( 'Collect Your Form Submissions', 'elementor' ); ?></h2> | |
| 369 | - <p> | |
| 370 | - <?php echo esc_html__( 'Save and manage all of your form submissions in one single place. | |
| 371 | -All within a simple, intuitive place.', 'elementor' ); ?> | |
| 372 | - <a href="http://go.elementor.com/wp-dash-submissions" target="_blank" rel="nofollow"> | |
| 373 | - <?php echo esc_html__( 'Learn More', 'elementor' ); ?> | |
| 374 | - </a> | |
| 375 | - </p> | |
| 376 | - <a class="elementor-button elementor-button-default elementor-button-go-pro" target="_blank" href="https://go.elementor.com/go-pro-submissions/"><?php echo esc_html__( 'Upgrade Now', 'elementor' ); ?></a> | |
| 377 | - </div> | |
| 378 | - </div><!-- /.wrap --> | |
| 379 | - <?php | |
| 380 | - } | |
| 381 | - | |
| 382 | - /** | |
| 383 | 166 | * On admin init. |
| 384 | 167 | * |
| 385 | 168 | * Preform actions on WordPress admin initialization. |
| 386 | 169 | * |
| @@ -613,24 +396,8 @@ | ||
| 613 | 396 | remove_all_actions( 'admin_notices' ); |
| 614 | 397 | } |
| 615 | 398 | |
| 616 | 399 | /** |
| 617 | - * Output the content for custom_code page. | |
| 618 | - */ | |
| 619 | - private function elementor_custom_code() { | |
| 620 | - ?> | |
| 621 | - <div class="wrap"> | |
| 622 | - <div class="elementor-blank_state"> | |
| 623 | - <img src="<?php Utils::print_unescaped_internal_string( ELEMENTOR_ASSETS_URL ); ?>images/go-pro-wp-dashboard.svg" /> | |
| 624 | - <h2><?php echo esc_html__( 'Add Your Custom Code', 'elementor' ); ?></h2> | |
| 625 | - <p><?php echo esc_html__( 'Custom Code is a tool gives you one place where you can insert scripts, rather than dealing with dozens of different plugins and deal with code.', 'elementor' ); ?></p> | |
| 626 | - <a class="elementor-button elementor-button-default elementor-button-go-pro" target="_blank" href="https://go.elementor.com/go-pro-custom-code/"><?php echo esc_html__( 'Upgrade Now', 'elementor' ); ?></a> | |
| 627 | - </div> | |
| 628 | - </div><!-- /.wrap --> | |
| 629 | - <?php | |
| 630 | - } | |
| 631 | - | |
| 632 | - /** | |
| 633 | 400 | * Settings page constructor. |
| 634 | 401 | * |
| 635 | 402 | * Initializing Elementor "Settings" page. |
| 636 | 403 | * |
| @@ -643,11 +410,14 @@ | ||
| 643 | 410 | add_action( 'admin_init', [ $this, 'on_admin_init' ] ); |
| 644 | 411 | |
| 645 | 412 | if ( ! Plugin::$instance->experiments->is_feature_active( 'admin_menu_rearrangement' ) ) { |
| 646 | 413 | add_action( 'admin_menu', [ $this, 'register_admin_menu' ], 20 ); |
| 414 | + | |
| 415 | + add_action( 'elementor/admin/menu/register', function ( Admin_Menu_Manager $admin_menu ) { | |
| 416 | + $this->register_knowledge_base_menu( $admin_menu ); | |
| 417 | + }, Promotions_Module::ADMIN_MENU_PRIORITY - 1 ); | |
| 418 | + | |
| 647 | 419 | add_action( 'admin_menu', [ $this, 'admin_menu_change_name' ], 200 ); |
| 648 | - add_action( 'admin_menu', [ $this, 'register_pro_menu' ], self::MENU_PRIORITY_GO_PRO ); | |
| 649 | - add_action( 'admin_menu', [ $this, 'register_knowledge_base_menu' ], 501 ); | |
| 650 | 420 | |
| 651 | 421 | add_filter( 'custom_menu_order', '__return_true' ); |
| 652 | 422 | add_filter( 'menu_order', [ $this, 'menu_order' ] ); |
| 653 | 423 | } |