| @@ -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 |
| @@ -50,26 +59,8 @@ | ||
| 50 | 59 | |
| 51 | 60 | wp_send_json_success(); |
| 52 | 61 | } |
| 53 | 62 | |
| 54 | - public function admin_post_elementor_site_clear_cache() { | |
| 55 | - check_ajax_referer( 'elementor_site_clear_cache' ); | |
| 56 | - | |
| 57 | - if ( ! current_user_can( static::CAPABILITY ) ) { | |
| 58 | - wp_die( 'Permission denied' ); | |
| 59 | - } | |
| 60 | - | |
| 61 | - Plugin::$instance->files_manager->clear_cache(); | |
| 62 | - | |
| 63 | - $http_referer = wp_get_raw_referer(); | |
| 64 | - if ( empty( $http_referer ) ) { | |
| 65 | - $http_referer = admin_url( 'admin.php?page=' . static::PAGE_ID ); | |
| 66 | - } | |
| 67 | - | |
| 68 | - wp_safe_redirect( $http_referer ); | |
| 69 | - die; | |
| 70 | - } | |
| 71 | - | |
| 72 | 63 | /** |
| 73 | 64 | * Recreate kit. |
| 74 | 65 | * |
| 75 | 66 | * Recreate default kit (only when default kit does not exist). |
| @@ -197,14 +188,13 @@ | ||
| 197 | 188 | */ |
| 198 | 189 | public function __construct() { |
| 199 | 190 | parent::__construct(); |
| 200 | 191 | |
| 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 | - } ); | |
| 192 | + add_action( 'elementor/admin/menu/register', function( Admin_Menu_Manager $admin_menu ) { | |
| 193 | + $admin_menu->register( static::PAGE_ID, new Tools_Menu_Item( $this ) ); | |
| 194 | + }, Settings::ADMIN_MENU_PRIORITY + 20 ); | |
| 204 | 195 | |
| 205 | 196 | add_action( 'wp_ajax_elementor_clear_cache', [ $this, 'ajax_elementor_clear_cache' ] ); |
| 206 | - add_action( 'admin_post_elementor_site_clear_cache', [ $this, 'admin_post_elementor_site_clear_cache' ] ); | |
| 207 | 197 | add_action( 'wp_ajax_elementor_replace_url', [ $this, 'ajax_elementor_replace_url' ] ); |
| 208 | 198 | add_action( 'wp_ajax_elementor_recreate_kit', [ $this, 'ajax_elementor_recreate_kit' ] ); |
| 209 | 199 | |
| 210 | 200 | add_action( 'admin_post_elementor_rollback', [ $this, 'post_elementor_rollback' ] ); |
| @@ -209,17 +199,8 @@ | ||
| 209 | 199 | |
| 210 | 200 | add_action( 'admin_post_elementor_rollback', [ $this, 'post_elementor_rollback' ] ); |
| 211 | 201 | } |
| 212 | 202 | |
| 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 | 203 | private function get_rollback_versions() { |
| 223 | 204 | $rollback_versions = get_transient( 'elementor_rollback_versions_' . ELEMENTOR_VERSION ); |
| 224 | 205 | |
| 225 | 206 | if ( false === $rollback_versions ) { |
| @@ -275,9 +256,9 @@ | ||
| 275 | 256 | if ( version_compare( $version, ELEMENTOR_VERSION, '>=' ) ) { |
| 276 | 257 | continue; |
| 277 | 258 | } |
| 278 | 259 | |
| 279 | - ++$current_index; | |
| 260 | + $current_index++; | |
| 280 | 261 | $rollback_versions[] = $version; |
| 281 | 262 | } |
| 282 | 263 | |
| 283 | 264 | set_transient( 'elementor_rollback_versions_' . ELEMENTOR_VERSION, $rollback_versions, WEEK_IN_SECONDS ); |
| @@ -310,13 +291,13 @@ | ||
| 310 | 291 | 'sections' => [ |
| 311 | 292 | 'tools' => [ |
| 312 | 293 | 'fields' => [ |
| 313 | 294 | 'clear_cache' => [ |
| 314 | - 'label' => esc_html__( 'Elementor Cache', 'elementor' ), | |
| 295 | + 'label' => esc_html__( 'Regenerate CSS & Data', 'elementor' ), | |
| 315 | 296 | 'field_args' => [ |
| 316 | 297 | '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' ) ), | |
| 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' ), | |
| 298 | + '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__( 'Regenerate Files & Data', 'elementor' ) ), | |
| 299 | + 'desc' => esc_html__( 'Styles set in Elementor are saved in CSS files in the uploads folder and in the site’s database. Recreate those files and settings, according to the most recent settings.', 'elementor' ), | |
| 319 | 300 | ], |
| 320 | 301 | ], |
| 321 | 302 | 'reset_api_data' => [ |
| 322 | 303 | 'label' => esc_html__( 'Sync Library', 'elementor' ), |
| @@ -321,9 +302,9 @@ | ||
| 321 | 302 | 'reset_api_data' => [ |
| 322 | 303 | 'label' => esc_html__( 'Sync Library', 'elementor' ), |
| 323 | 304 | 'field_args' => [ |
| 324 | 305 | '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' ) ), | |
| 306 | + '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 | 307 | '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 | 308 | ], |
| 328 | 309 | ], |
| 329 | 310 | ], |
| @@ -335,9 +316,9 @@ | ||
| 335 | 316 | 'sections' => [ |
| 336 | 317 | 'replace_url' => [ |
| 337 | 318 | 'callback' => function() { |
| 338 | 319 | echo '<h2>' . esc_html__( 'Replace URL', 'elementor' ) . '</h2>'; |
| 339 | - printf( | |
| 320 | + echo sprintf( | |
| 340 | 321 | '<p><strong>%1$s</strong> %2$s</p>', |
| 341 | 322 | esc_html__( 'Important:', 'elementor' ), |
| 342 | 323 | sprintf( |
| 343 | 324 | /* translators: 1: Link open tag, 2: Link close tag. */ |
| @@ -351,9 +332,9 @@ | ||
| 351 | 332 | 'replace_url' => [ |
| 352 | 333 | 'label' => esc_html__( 'Update Site Address (URL)', 'elementor' ), |
| 353 | 334 | 'field_args' => [ |
| 354 | 335 | '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' ) ), | |
| 336 | + '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 | 337 | '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 | 338 | ], |
| 358 | 339 | ], |
| 359 | 340 | ], |
| @@ -381,13 +362,13 @@ | ||
| 381 | 362 | 'label' => esc_html__( 'Rollback Version', 'elementor' ), |
| 382 | 363 | 'field_args' => [ |
| 383 | 364 | 'type' => 'raw_html', |
| 384 | 365 | '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>', | |
| 366 | + $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 | 367 | esc_html__( 'Reinstall', 'elementor' ), |
| 387 | 368 | wp_nonce_url( admin_url( 'admin-post.php?action=elementor_rollback&version=VERSION' ), 'elementor_rollback' ) |
| 388 | 369 | ), |
| 389 | - 'desc' => $this->get_warning_span( esc_html__( 'Warning: Please backup your database before making the rollback.', 'elementor' ) ), | |
| 370 | + 'desc' => '<span style="color: red;">' . esc_html__( 'Warning: Please backup your database before making the rollback.', 'elementor' ) . '</span>', | |
| 390 | 371 | ], |
| 391 | 372 | ], |
| 392 | 373 | ], |
| 393 | 374 | ], |
| @@ -416,9 +397,9 @@ | ||
| 416 | 397 | 'options' => [ |
| 417 | 398 | 'no' => esc_html__( 'Disable', 'elementor' ), |
| 418 | 399 | 'yes' => esc_html__( 'Enable', 'elementor' ), |
| 419 | 400 | ], |
| 420 | - 'desc' => $this->get_warning_span( esc_html__( 'Please Note: We do not recommend updating to a beta version on production sites.', 'elementor' ) ), | |
| 401 | + 'desc' => '<span style="color: red;">' . esc_html__( 'Please Note: We do not recommend updating to a beta version on production sites.', 'elementor' ) . '</span>', | |
| 421 | 402 | ], |
| 422 | 403 | ], |
| 423 | 404 | ], |
| 424 | 405 | ], |