| @@ -1,12 +1,11 @@ | ||
| 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 | -use Elementor\Modules\EditorOne\Classes\Menu_Data_Provider; | |
| 8 | -use Elementor\Includes\Settings\AdminMenuItems\Editor_One_Tools_Menu; | |
| 9 | 8 | |
| 10 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 11 | 10 | exit; // Exit if accessed directly. |
| 12 | 11 | } |
| @@ -27,8 +26,18 @@ | ||
| 27 | 26 | * Settings page ID for Elementor tools. |
| 28 | 27 | */ |
| 29 | 28 | const PAGE_ID = 'elementor-tools'; |
| 30 | 29 | |
| 30 | + private function register_admin_menu( MainMenu $menu ) { | |
| 31 | + $menu->add_submenu( [ | |
| 32 | + 'page_title' => esc_html__( 'Tools', 'elementor' ), | |
| 33 | + 'menu_title' => esc_html__( 'Tools', 'elementor' ), | |
| 34 | + 'menu_slug' => self::PAGE_ID, | |
| 35 | + 'function' => [ $this, 'display_settings_page' ], | |
| 36 | + 'index' => 50, | |
| 37 | + ] ); | |
| 38 | + } | |
| 39 | + | |
| 31 | 40 | /** |
| 32 | 41 | * Clear cache. |
| 33 | 42 | * |
| 34 | 43 | * Delete post meta containing the post CSS file data. And delete the actual |
| @@ -197,11 +206,11 @@ | ||
| 197 | 206 | */ |
| 198 | 207 | public function __construct() { |
| 199 | 208 | parent::__construct(); |
| 200 | 209 | |
| 201 | - add_action( 'elementor/editor-one/menu/register', function ( Menu_Data_Provider $menu_data_provider ) { | |
| 202 | - $this->register_editor_one_menu( $menu_data_provider ); | |
| 203 | - } ); | |
| 210 | + add_action( 'elementor/admin/menu/register', function( Admin_Menu_Manager $admin_menu ) { | |
| 211 | + $admin_menu->register( static::PAGE_ID, new Tools_Menu_Item( $this ) ); | |
| 212 | + }, Settings::ADMIN_MENU_PRIORITY + 20 ); | |
| 204 | 213 | |
| 205 | 214 | add_action( 'wp_ajax_elementor_clear_cache', [ $this, 'ajax_elementor_clear_cache' ] ); |
| 206 | 215 | add_action( 'admin_post_elementor_site_clear_cache', [ $this, 'admin_post_elementor_site_clear_cache' ] ); |
| 207 | 216 | add_action( 'wp_ajax_elementor_replace_url', [ $this, 'ajax_elementor_replace_url' ] ); |
| @@ -209,17 +218,8 @@ | ||
| 209 | 218 | |
| 210 | 219 | add_action( 'admin_post_elementor_rollback', [ $this, 'post_elementor_rollback' ] ); |
| 211 | 220 | } |
| 212 | 221 | |
| 213 | - private function register_editor_one_menu( Menu_Data_Provider $menu_data_provider ) { | |
| 214 | - $menu_data_provider->register_menu( new Editor_One_Tools_Menu() ); | |
| 215 | - } | |
| 216 | - | |
| 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 ) ); | |
| 220 | - } | |
| 221 | - | |
| 222 | 222 | private function get_rollback_versions() { |
| 223 | 223 | $rollback_versions = get_transient( 'elementor_rollback_versions_' . ELEMENTOR_VERSION ); |
| 224 | 224 | |
| 225 | 225 | if ( false === $rollback_versions ) { |
| @@ -275,9 +275,9 @@ | ||
| 275 | 275 | if ( version_compare( $version, ELEMENTOR_VERSION, '>=' ) ) { |
| 276 | 276 | continue; |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - ++$current_index; | |
| 279 | + $current_index++; | |
| 280 | 280 | $rollback_versions[] = $version; |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | set_transient( 'elementor_rollback_versions_' . ELEMENTOR_VERSION, $rollback_versions, WEEK_IN_SECONDS ); |
| @@ -313,9 +313,9 @@ | ||
| 313 | 313 | 'clear_cache' => [ |
| 314 | 314 | 'label' => esc_html__( 'Elementor Cache', 'elementor' ), |
| 315 | 315 | 'field_args' => [ |
| 316 | 316 | 'type' => 'raw_html', |
| 317 | - 'html' => sprintf( '<button data-nonce="%s" data-id="elementor-tools-general-button-clear-files-data" class="button elementor-button-spinner" id="elementor-clear-cache-button">%s</button>', wp_create_nonce( 'elementor_clear_cache' ), esc_html__( 'Clear Files & Data', 'elementor' ) ), | |
| 317 | + 'html' => sprintf( '<button data-nonce="%s" class="button elementor-button-spinner" id="elementor-clear-cache-button">%s</button>', wp_create_nonce( 'elementor_clear_cache' ), esc_html__( 'Clear Files & Data', 'elementor' ) ), | |
| 318 | 318 | 'desc' => esc_html__( "Clear outdated CSS files and cached data in the database (rendered HTML, JS/CSS assets, etc.). We'll regenerate those files the next time someone visits any page on your website.", 'elementor' ), |
| 319 | 319 | ], |
| 320 | 320 | ], |
| 321 | 321 | 'reset_api_data' => [ |
| @@ -321,9 +321,9 @@ | ||
| 321 | 321 | 'reset_api_data' => [ |
| 322 | 322 | 'label' => esc_html__( 'Sync Library', 'elementor' ), |
| 323 | 323 | 'field_args' => [ |
| 324 | 324 | 'type' => 'raw_html', |
| 325 | - 'html' => sprintf( '<button data-nonce="%s" data-id="elementor-tools-general-button-sync-library" class="button elementor-button-spinner" id="elementor-library-sync-button">%s</button>', wp_create_nonce( 'elementor_reset_library' ), esc_html__( 'Sync Library', 'elementor' ) ), | |
| 325 | + 'html' => sprintf( '<button data-nonce="%s" class="button elementor-button-spinner" id="elementor-library-sync-button">%s</button>', wp_create_nonce( 'elementor_reset_library' ), esc_html__( 'Sync Library', 'elementor' ) ), | |
| 326 | 326 | 'desc' => esc_html__( 'Elementor Library automatically updates on a daily basis. You can also manually update it by clicking on the sync button.', 'elementor' ), |
| 327 | 327 | ], |
| 328 | 328 | ], |
| 329 | 329 | ], |
| @@ -351,9 +351,9 @@ | ||
| 351 | 351 | 'replace_url' => [ |
| 352 | 352 | 'label' => esc_html__( 'Update Site Address (URL)', 'elementor' ), |
| 353 | 353 | 'field_args' => [ |
| 354 | 354 | 'type' => 'raw_html', |
| 355 | - 'html' => sprintf( '<input type="text" name="from" placeholder="https://old.example.com" class="large-text"><input type="text" name="to" placeholder="https://new.example.com" class="large-text"><button data-nonce="%s" data-id="elementor-tools-replace_url-button-replace-url" class="button elementor-button-spinner" id="elementor-replace-url-button">%s</button>', wp_create_nonce( 'elementor_replace_url' ), esc_html__( 'Replace URL', 'elementor' ) ), | |
| 355 | + 'html' => sprintf( '<input type="text" name="from" placeholder="https://old.example.com" class="large-text"><input type="text" name="to" placeholder="https://new.example.com" class="large-text"><button data-nonce="%s" class="button elementor-button-spinner" id="elementor-replace-url-button">%s</button>', wp_create_nonce( 'elementor_replace_url' ), esc_html__( 'Replace URL', 'elementor' ) ), | |
| 356 | 356 | 'desc' => esc_html__( 'Enter your old and new URLs for your WordPress installation, to update all Elementor data (Relevant for domain transfers or move to \'HTTPS\').', 'elementor' ), |
| 357 | 357 | ], |
| 358 | 358 | ], |
| 359 | 359 | ], |
| @@ -381,13 +381,13 @@ | ||
| 381 | 381 | 'label' => esc_html__( 'Rollback Version', 'elementor' ), |
| 382 | 382 | 'field_args' => [ |
| 383 | 383 | 'type' => 'raw_html', |
| 384 | 384 | '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>', | |
| 385 | + $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 | 386 | esc_html__( 'Reinstall', 'elementor' ), |
| 387 | 387 | wp_nonce_url( admin_url( 'admin-post.php?action=elementor_rollback&version=VERSION' ), 'elementor_rollback' ) |
| 388 | 388 | ), |
| 389 | - 'desc' => $this->get_warning_span( esc_html__( 'Warning: Please backup your database before making the rollback.', 'elementor' ) ), | |
| 389 | + 'desc' => '<span style="color: red;">' . esc_html__( 'Warning: Please backup your database before making the rollback.', 'elementor' ) . '</span>', | |
| 390 | 390 | ], |
| 391 | 391 | ], |
| 392 | 392 | ], |
| 393 | 393 | ], |
| @@ -416,9 +416,9 @@ | ||
| 416 | 416 | 'options' => [ |
| 417 | 417 | 'no' => esc_html__( 'Disable', 'elementor' ), |
| 418 | 418 | 'yes' => esc_html__( 'Enable', 'elementor' ), |
| 419 | 419 | ], |
| 420 | - 'desc' => $this->get_warning_span( esc_html__( 'Please Note: We do not recommend updating to a beta version on production sites.', 'elementor' ) ), | |
| 420 | + 'desc' => '<span style="color: red;">' . esc_html__( 'Please Note: We do not recommend updating to a beta version on production sites.', 'elementor' ) . '</span>', | |
| 421 | 421 | ], |
| 422 | 422 | ], |
| 423 | 423 | ], |
| 424 | 424 | ], |