| @@ -1,8 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Elementor; |
| 3 | 3 | |
| 4 | 4 | use Elementor\Core\Admin\Menu\Admin_Menu_Manager; |
| 5 | +use Elementor\Core\Admin\Menu\Main as MainMenu; | |
| 5 | 6 | use Elementor\Core\Kits\Manager; |
| 6 | 7 | use Elementor\Includes\Settings\AdminMenuItems\Tools_Menu_Item; |
| 7 | 8 | use Elementor\Modules\EditorOne\Classes\Menu_Data_Provider; |
| 8 | 9 | use Elementor\Includes\Settings\AdminMenuItems\Editor_One_Tools_Menu; |
| @@ -27,8 +28,18 @@ | ||
| 27 | 28 | * Settings page ID for Elementor tools. |
| 28 | 29 | */ |
| 29 | 30 | const PAGE_ID = 'elementor-tools'; |
| 30 | 31 | |
| 32 | + private function register_admin_menu( MainMenu $menu ) { | |
| 33 | + $menu->add_submenu( [ | |
| 34 | + 'page_title' => esc_html__( 'Tools', 'elementor' ), | |
| 35 | + 'menu_title' => esc_html__( 'Tools', 'elementor' ), | |
| 36 | + 'menu_slug' => self::PAGE_ID, | |
| 37 | + 'function' => [ $this, 'display_settings_page' ], | |
| 38 | + 'index' => 50, | |
| 39 | + ] ); | |
| 40 | + } | |
| 41 | + | |
| 31 | 42 | /** |
| 32 | 43 | * Clear cache. |
| 33 | 44 | * |
| 34 | 45 | * Delete post meta containing the post CSS file data. And delete the actual |
| @@ -197,8 +208,14 @@ | ||
| 197 | 208 | */ |
| 198 | 209 | public function __construct() { |
| 199 | 210 | parent::__construct(); |
| 200 | 211 | |
| 212 | + add_action( 'elementor/admin/menu/register', function( Admin_Menu_Manager $admin_menu ) { | |
| 213 | + if ( ! $this->is_editor_one_active() ) { | |
| 214 | + $admin_menu->register( static::PAGE_ID, new Tools_Menu_Item( $this ) ); | |
| 215 | + } | |
| 216 | + }, Settings::ADMIN_MENU_PRIORITY + 20 ); | |
| 217 | + | |
| 201 | 218 | add_action( 'elementor/editor-one/menu/register', function ( Menu_Data_Provider $menu_data_provider ) { |
| 202 | 219 | $this->register_editor_one_menu( $menu_data_provider ); |
| 203 | 220 | } ); |
| 204 | 221 | |
| @@ -213,11 +230,10 @@ | ||
| 213 | 230 | private function register_editor_one_menu( Menu_Data_Provider $menu_data_provider ) { |
| 214 | 231 | $menu_data_provider->register_menu( new Editor_One_Tools_Menu() ); |
| 215 | 232 | } |
| 216 | 233 | |
| 217 | - public function get_warning_span( string $text ): string { | |
| 218 | - $color = 'var(--e-one-palette-error-main)'; | |
| 219 | - return sprintf( '<span style="color: %s;">%s</span>', esc_attr( $color ), esc_html( $text ) ); | |
| 234 | + private function is_editor_one_active(): bool { | |
| 235 | + return (bool) Plugin::instance()->modules_manager->get_modules( 'editor-one' ); | |
| 220 | 236 | } |
| 221 | 237 | |
| 222 | 238 | private function get_rollback_versions() { |
| 223 | 239 | $rollback_versions = get_transient( 'elementor_rollback_versions_' . ELEMENTOR_VERSION ); |
| @@ -381,13 +397,13 @@ | ||
| 381 | 397 | 'label' => esc_html__( 'Rollback Version', 'elementor' ), |
| 382 | 398 | 'field_args' => [ |
| 383 | 399 | 'type' => 'raw_html', |
| 384 | 400 | 'html' => sprintf( |
| 385 | - $rollback_html . '<button data-placeholder-text="%1$s v{VERSION}" data-placeholder-url="%2$s" class="button elementor-button-spinner elementor-rollback-button">%1$s</button>', | |
| 401 | + $rollback_html . '<a data-placeholder-text="%1$s v{VERSION}" href="#" data-placeholder-url="%2$s" class="button elementor-button-spinner elementor-rollback-button">%1$s</a>', | |
| 386 | 402 | esc_html__( 'Reinstall', 'elementor' ), |
| 387 | 403 | wp_nonce_url( admin_url( 'admin-post.php?action=elementor_rollback&version=VERSION' ), 'elementor_rollback' ) |
| 388 | 404 | ), |
| 389 | - 'desc' => $this->get_warning_span( esc_html__( 'Warning: Please back up your database before making the rollback.', 'elementor' ) ), | |
| 405 | + 'desc' => '<span style="color: red;">' . esc_html__( 'Warning: Please backup your database before making the rollback.', 'elementor' ) . '</span>', | |
| 390 | 406 | ], |
| 391 | 407 | ], |
| 392 | 408 | ], |
| 393 | 409 | ], |
| @@ -416,9 +432,9 @@ | ||
| 416 | 432 | 'options' => [ |
| 417 | 433 | 'no' => esc_html__( 'Disable', 'elementor' ), |
| 418 | 434 | 'yes' => esc_html__( 'Enable', 'elementor' ), |
| 419 | 435 | ], |
| 420 | - 'desc' => $this->get_warning_span( esc_html__( 'Please Note: We do not recommend updating to a beta version on production sites.', 'elementor' ) ), | |
| 436 | + 'desc' => '<span style="color: red;">' . esc_html__( 'Please Note: We do not recommend updating to a beta version on production sites.', 'elementor' ) . '</span>', | |
| 421 | 437 | ], |
| 422 | 438 | ], |
| 423 | 439 | ], |
| 424 | 440 | ], |