| @@ -2,20 +2,13 @@ | ||
| 2 | 2 | namespace Elementor\Core\Admin; |
| 3 | 3 | |
| 4 | 4 | use Elementor\Api; |
| 5 | 5 | use Elementor\Beta_Testers; |
| 6 | -use Elementor\App\Modules\Onboarding\Module as Onboarding_Module; | |
| 7 | 6 | use Elementor\Core\Base\App; |
| 8 | -use Elementor\Core\Upgrade\Manager as Upgrade_Manager; | |
| 9 | -use Elementor\Core\Utils\Assets_Config_Provider; | |
| 10 | -use Elementor\Core\Utils\Collection; | |
| 11 | -use Elementor\Modules\FloatingButtons\Module as Floating_Buttons_Module; | |
| 12 | 7 | use Elementor\Plugin; |
| 13 | 8 | use Elementor\Settings; |
| 14 | 9 | use Elementor\User; |
| 15 | 10 | use Elementor\Utils; |
| 16 | -use Elementor\Core\Utils\Hints; | |
| 17 | -use Elementor\Core\DocumentTypes\Page; | |
| 18 | 11 | |
| 19 | 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 20 | 13 | exit; // Exit if accessed directly. |
| 21 | 14 | } |
| @@ -21,10 +14,8 @@ | ||
| 21 | 14 | } |
| 22 | 15 | |
| 23 | 16 | class Admin extends App { |
| 24 | 17 | |
| 25 | - private $menus = []; | |
| 26 | - | |
| 27 | 18 | /** |
| 28 | 19 | * Get module name. |
| 29 | 20 | * |
| 30 | 21 | * Retrieve the module name. |
| @@ -38,36 +29,8 @@ | ||
| 38 | 29 | return 'admin'; |
| 39 | 30 | } |
| 40 | 31 | |
| 41 | 32 | /** |
| 42 | - * Check if current page is an Elementor admin page. | |
| 43 | - * | |
| 44 | - * @param \WP_Screen|null $current_screen Optional. Screen object to check. Defaults to current screen. | |
| 45 | - * | |
| 46 | - * @return bool Whether current page is an Elementor admin page. | |
| 47 | - */ | |
| 48 | - public static function is_elementor_admin_page( $current_screen = null ) { | |
| 49 | - if ( ! $current_screen ) { | |
| 50 | - $current_screen = get_current_screen(); | |
| 51 | - } | |
| 52 | - | |
| 53 | - if ( ! $current_screen ) { | |
| 54 | - return false; | |
| 55 | - } | |
| 56 | - | |
| 57 | - $screen_id = $current_screen->id ?? ''; | |
| 58 | - $post_type = $current_screen->post_type ?? ''; | |
| 59 | - | |
| 60 | - $is_elementor_screen = strpos( $screen_id, 'elementor' ) !== false | |
| 61 | - || strpos( $screen_id, Floating_Buttons_Module::CPT_FLOATING_BUTTONS ) !== false; | |
| 62 | - | |
| 63 | - $is_elementor_post_type = strpos( $post_type, 'elementor' ) !== false | |
| 64 | - || strpos( $post_type, Floating_Buttons_Module::CPT_FLOATING_BUTTONS ) !== false; | |
| 65 | - | |
| 66 | - return $is_elementor_screen || $is_elementor_post_type; | |
| 67 | - } | |
| 68 | - | |
| 69 | - /** | |
| 70 | 33 | * @since 2.2.0 |
| 71 | 34 | * @access public |
| 72 | 35 | */ |
| 73 | 36 | public function maybe_redirect_to_getting_started() { |
| @@ -84,54 +47,21 @@ | ||
| 84 | 47 | if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
| 85 | 48 | return; |
| 86 | 49 | } |
| 87 | 50 | |
| 88 | - $already_had_onboarding = get_option( Onboarding_Module::ONBOARDING_OPTION ); | |
| 51 | + global $wpdb; | |
| 89 | 52 | |
| 90 | - // Get the latest installation from Elementor's Install log in the DB. | |
| 91 | - $latest_install = key( Upgrade_Manager::get_installs_history() ); | |
| 53 | + $has_elementor_page = ! ! $wpdb->get_var( "SELECT `post_id` FROM `{$wpdb->postmeta}` WHERE `meta_key` = '_elementor_edit_mode' LIMIT 1;" ); | |
| 92 | 54 | |
| 93 | - if ( ! empty( $latest_install ) ) { | |
| 94 | - $is_new_install = version_compare( $latest_install, '3.6.0-beta', '>=' ); | |
| 95 | - } else { | |
| 96 | - // If `$latest_install` is not set, Elementor was never installed on this site. | |
| 97 | - $is_new_install = true; | |
| 98 | - } | |
| 99 | - | |
| 100 | - if ( $already_had_onboarding || ! $is_new_install ) { | |
| 55 | + if ( $has_elementor_page ) { | |
| 101 | 56 | return; |
| 102 | 57 | } |
| 103 | 58 | |
| 104 | - wp_safe_redirect( admin_url( 'admin.php?page=elementor-app#onboarding' ) ); | |
| 59 | + wp_safe_redirect( admin_url( 'admin.php?page=elementor-getting-started' ) ); | |
| 105 | 60 | |
| 106 | 61 | exit; |
| 107 | 62 | } |
| 108 | 63 | |
| 109 | - private function register_packages() { | |
| 110 | - $assets_config_provider = ( new Assets_Config_Provider() ) | |
| 111 | - ->set_path_resolver( function ( $name ) { | |
| 112 | - return ELEMENTOR_ASSETS_PATH . "js/packages/{$name}/{$name}.asset.php"; | |
| 113 | - } ); | |
| 114 | - | |
| 115 | - Collection::make( [ 'ui', 'icons', 'query' ] ) | |
| 116 | - ->each( function( $package ) use ( $assets_config_provider ) { | |
| 117 | - $suffix = Utils::is_script_debug() ? '' : '.min'; | |
| 118 | - $config = $assets_config_provider->load( $package )->get( $package ); | |
| 119 | - | |
| 120 | - if ( ! $config ) { | |
| 121 | - return; | |
| 122 | - } | |
| 123 | - | |
| 124 | - wp_register_script( | |
| 125 | - $config['handle'], | |
| 126 | - ELEMENTOR_ASSETS_URL . "js/packages/{$package}/{$package}{$suffix}.js", | |
| 127 | - $config['deps'], | |
| 128 | - ELEMENTOR_VERSION, | |
| 129 | - true | |
| 130 | - ); | |
| 131 | - } ); | |
| 132 | - } | |
| 133 | - | |
| 134 | 64 | /** |
| 135 | 65 | * Enqueue admin scripts. |
| 136 | 66 | * |
| 137 | 67 | * Registers all the admin scripts and enqueues them. |
| @@ -142,36 +72,12 @@ | ||
| 142 | 72 | * @access public |
| 143 | 73 | */ |
| 144 | 74 | public function enqueue_scripts() { |
| 145 | 75 | wp_register_script( |
| 146 | - 'elementor-admin-modules', | |
| 147 | - $this->get_js_assets_url( 'admin-modules' ), | |
| 148 | - [], | |
| 149 | - ELEMENTOR_VERSION, | |
| 150 | - true | |
| 151 | - ); | |
| 152 | - | |
| 153 | - $this->register_packages(); | |
| 154 | - | |
| 155 | - // Temporary solution for the admin. | |
| 156 | - wp_register_script( | |
| 157 | - 'elementor-ai-admin', | |
| 158 | - $this->get_js_assets_url( 'ai-admin' ), | |
| 159 | - [ | |
| 160 | - 'elementor-common', | |
| 161 | - 'elementor-v2-ui', | |
| 162 | - 'elementor-v2-icons', | |
| 163 | - ], | |
| 164 | - ELEMENTOR_VERSION, | |
| 165 | - true | |
| 166 | - ); | |
| 167 | - | |
| 168 | - wp_register_script( | |
| 169 | 76 | 'elementor-admin', |
| 170 | 77 | $this->get_js_assets_url( 'admin' ), |
| 171 | 78 | [ |
| 172 | 79 | 'elementor-common', |
| 173 | - 'elementor-admin-modules', | |
| 174 | 80 | ], |
| 175 | 81 | ELEMENTOR_VERSION, |
| 176 | 82 | true |
| 177 | 83 | ); |
| @@ -177,12 +83,8 @@ | ||
| 177 | 83 | ); |
| 178 | 84 | |
| 179 | 85 | wp_enqueue_script( 'elementor-admin' ); |
| 180 | 86 | |
| 181 | - wp_set_script_translations( 'elementor-admin', 'elementor' ); | |
| 182 | - | |
| 183 | - $this->maybe_enqueue_hints(); | |
| 184 | - | |
| 185 | 87 | $this->print_config(); |
| 186 | 88 | } |
| 187 | 89 | |
| 188 | 90 | /** |
| @@ -195,11 +97,13 @@ | ||
| 195 | 97 | * @since 1.0.0 |
| 196 | 98 | * @access public |
| 197 | 99 | */ |
| 198 | 100 | public function enqueue_styles() { |
| 101 | + $direction_suffix = is_rtl() ? '-rtl' : ''; | |
| 102 | + | |
| 199 | 103 | wp_register_style( |
| 200 | 104 | 'elementor-admin', |
| 201 | - $this->get_css_assets_url( 'admin' ), | |
| 105 | + $this->get_css_assets_url( 'admin' . $direction_suffix ), | |
| 202 | 106 | [ |
| 203 | 107 | 'elementor-common', |
| 204 | 108 | ], |
| 205 | 109 | ELEMENTOR_VERSION |
| @@ -239,25 +143,25 @@ | ||
| 239 | 143 | |
| 240 | 144 | wp_nonce_field( basename( __FILE__ ), '_elementor_edit_mode_nonce' ); |
| 241 | 145 | ?> |
| 242 | 146 | <div id="elementor-switch-mode"> |
| 243 | - <input id="elementor-switch-mode-input" type="hidden" name="_elementor_post_mode" value="<?php echo esc_attr( $document->is_built_with_elementor() ); ?>" /> | |
| 147 | + <input id="elementor-switch-mode-input" type="hidden" name="_elementor_post_mode" value="<?php echo $document->is_built_with_elementor(); ?>" /> | |
| 244 | 148 | <button id="elementor-switch-mode-button" type="button" class="button button-primary button-hero"> |
| 245 | 149 | <span class="elementor-switch-mode-on"> |
| 246 | 150 | <i class="eicon-arrow-<?php echo ( is_rtl() ) ? 'right' : 'left'; ?>" aria-hidden="true"></i> |
| 247 | - <?php echo esc_html__( 'Back to WordPress Editor', 'elementor' ); ?> | |
| 151 | + <?php echo __( 'Back to WordPress Editor', 'elementor' ); ?> | |
| 248 | 152 | </span> |
| 249 | 153 | <span class="elementor-switch-mode-off"> |
| 250 | 154 | <i class="eicon-elementor-square" aria-hidden="true"></i> |
| 251 | - <?php echo esc_html__( 'Edit with Elementor', 'elementor' ); ?> | |
| 155 | + <?php echo __( 'Edit with Elementor', 'elementor' ); ?> | |
| 252 | 156 | </span> |
| 253 | 157 | </button> |
| 254 | 158 | </div> |
| 255 | 159 | <div id="elementor-editor"> |
| 256 | - <a id="elementor-go-to-edit-page-link" href="<?php echo esc_url( $document->get_edit_url() ); ?>"> | |
| 160 | + <a id="elementor-go-to-edit-page-link" href="<?php echo $document->get_edit_url(); ?>"> | |
| 257 | 161 | <div id="elementor-editor-button" class="button button-primary button-hero"> |
| 258 | 162 | <i class="eicon-elementor-square" aria-hidden="true"></i> |
| 259 | - <?php echo esc_html__( 'Edit with Elementor', 'elementor' ); ?> | |
| 163 | + <?php echo __( 'Edit with Elementor', 'elementor' ); ?> | |
| 260 | 164 | </div> |
| 261 | 165 | <div class="elementor-loader-wrapper"> |
| 262 | 166 | <div class="elementor-loader"> |
| 263 | 167 | <div class="elementor-loader-boxes"> |
| @@ -266,9 +170,9 @@ | ||
| 266 | 170 | <div class="elementor-loader-box"></div> |
| 267 | 171 | <div class="elementor-loader-box"></div> |
| 268 | 172 | </div> |
| 269 | 173 | </div> |
| 270 | - <div class="elementor-loading-title"><?php echo esc_html__( 'Loading', 'elementor' ); ?></div> | |
| 174 | + <div class="elementor-loading-title"><?php echo __( 'Loading', 'elementor' ); ?></div> | |
| 271 | 175 | </div> |
| 272 | 176 | </a> |
| 273 | 177 | </div> |
| 274 | 178 | <?php |
| @@ -286,9 +190,9 @@ | ||
| 286 | 190 | * |
| 287 | 191 | * @param int $post_id Post ID. |
| 288 | 192 | */ |
| 289 | 193 | public function save_post( $post_id ) { |
| 290 | - if ( ! wp_verify_nonce( Utils::get_super_global_value( $_POST, '_elementor_edit_mode_nonce' ), basename( __FILE__ ) ) ) { | |
| 194 | + if ( ! isset( $_POST['_elementor_edit_mode_nonce'] ) || ! wp_verify_nonce( $_POST['_elementor_edit_mode_nonce'], basename( __FILE__ ) ) ) { | |
| 291 | 195 | return; |
| 292 | 196 | } |
| 293 | 197 | |
| 294 | 198 | if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { |
| @@ -316,9 +220,9 @@ | ||
| 316 | 220 | public function add_elementor_post_state( $post_states, $post ) { |
| 317 | 221 | $document = Plugin::$instance->documents->get( $post->ID ); |
| 318 | 222 | |
| 319 | 223 | if ( $document && $document->is_built_with_elementor() && $document->is_editable_by_current_user() ) { |
| 320 | - $post_states['elementor'] = esc_html__( 'Elementor', 'elementor' ); | |
| 224 | + $post_states['elementor'] = __( 'Elementor', 'elementor' ); | |
| 321 | 225 | } |
| 322 | 226 | |
| 323 | 227 | return $post_states; |
| 324 | 228 | } |
| @@ -367,19 +271,14 @@ | ||
| 367 | 271 | * |
| 368 | 272 | * @return array An array of plugin action links. |
| 369 | 273 | */ |
| 370 | 274 | public function plugin_action_links( $links ) { |
| 371 | - $settings_link = sprintf( '<a href="%1$s">%2$s</a>', admin_url( 'admin.php?page=' . Settings::PAGE_ID ), esc_html__( 'Settings', 'elementor' ) ); | |
| 275 | + $settings_link = sprintf( '<a href="%1$s">%2$s</a>', admin_url( 'admin.php?page=' . Settings::PAGE_ID ), __( 'Settings', 'elementor' ) ); | |
| 372 | 276 | |
| 373 | 277 | array_unshift( $links, $settings_link ); |
| 374 | 278 | |
| 375 | - $go_pro_text = esc_html__( 'Get Elementor Pro', 'elementor' ); | |
| 376 | - if ( Utils::is_sale_time() ) { | |
| 377 | - $go_pro_text = esc_html__( 'Discounted Upgrades Now!', 'elementor' ); | |
| 378 | - } | |
| 279 | + $links['go_pro'] = sprintf( '<a href="%1$s" target="_blank" class="elementor-plugins-gopro">%2$s</a>', Utils::get_pro_link( 'https://elementor.com/pro/?utm_source=wp-plugins&utm_campaign=gopro&utm_medium=wp-dash' ), __( 'Go Pro', 'elementor' ) ); | |
| 379 | 280 | |
| 380 | - $links['go_pro'] = sprintf( '<a href="%1$s" target="_blank" class="elementor-plugins-gopro">%2$s</a>', 'https://go.elementor.com/go-pro-wp-plugins/', $go_pro_text ); | |
| 381 | - | |
| 382 | 281 | return $links; |
| 383 | 282 | } |
| 384 | 283 | |
| 385 | 284 | /** |
| @@ -401,10 +300,10 @@ | ||
| 401 | 300 | */ |
| 402 | 301 | public function plugin_row_meta( $plugin_meta, $plugin_file ) { |
| 403 | 302 | if ( ELEMENTOR_PLUGIN_BASE === $plugin_file ) { |
| 404 | 303 | $row_meta = [ |
| 405 | - 'docs' => '<a href="https://go.elementor.com/docs-admin-plugins/" aria-label="' . esc_attr__( 'View Elementor Documentation', 'elementor' ) . '" target="_blank">' . esc_html__( 'Docs & FAQs', 'elementor' ) . '</a>', | |
| 406 | - 'ideo' => '<a href="https://go.elementor.com/yt-admin-plugins/" aria-label="' . esc_attr__( 'View Elementor Video Tutorials', 'elementor' ) . '" target="_blank">' . esc_html__( 'Video Tutorials', 'elementor' ) . '</a>', | |
| 304 | + 'docs' => '<a href="https://go.elementor.com/docs-admin-plugins/" aria-label="' . esc_attr( __( 'View Elementor Documentation', 'elementor' ) ) . '" target="_blank">' . __( 'Docs & FAQs', 'elementor' ) . '</a>', | |
| 305 | + 'ideo' => '<a href="https://go.elementor.com/yt-admin-plugins/" aria-label="' . esc_attr( __( 'View Elementor Video Tutorials', 'elementor' ) ) . '" target="_blank">' . __( 'Video Tutorials', 'elementor' ) . '</a>', | |
| 407 | 306 | ]; |
| 408 | 307 | |
| 409 | 308 | $plugin_meta = array_merge( $plugin_meta, $row_meta ); |
| 410 | 309 | } |
| @@ -433,9 +332,9 @@ | ||
| 433 | 332 | if ( $is_elementor_screen ) { |
| 434 | 333 | $footer_text = sprintf( |
| 435 | 334 | /* translators: 1: Elementor, 2: Link to plugin review */ |
| 436 | 335 | __( 'Enjoyed %1$s? Please leave us a %2$s rating. We really appreciate your support!', 'elementor' ), |
| 437 | - '<strong>' . esc_html__( 'Elementor', 'elementor' ) . '</strong>', | |
| 336 | + '<strong>' . __( 'Elementor', 'elementor' ) . '</strong>', | |
| 438 | 337 | '<a href="https://go.elementor.com/admin-review/" target="_blank">★★★★★</a>' |
| 439 | 338 | ); |
| 440 | 339 | } |
| 441 | 340 | |
| @@ -452,9 +351,9 @@ | ||
| 452 | 351 | * @since 1.9.0 |
| 453 | 352 | * @access public |
| 454 | 353 | */ |
| 455 | 354 | public function register_dashboard_widgets() { |
| 456 | - wp_add_dashboard_widget( 'e-dashboard-overview', esc_html__( 'Elementor Overview', 'elementor' ), [ $this, 'elementor_dashboard_overview_widget' ] ); | |
| 355 | + wp_add_dashboard_widget( 'e-dashboard-overview', __( 'Elementor Overview', 'elementor' ), [ $this, 'elementor_dashboard_overview_widget' ] ); | |
| 457 | 356 | |
| 458 | 357 | // Move our widget to top. |
| 459 | 358 | global $wp_meta_boxes; |
| 460 | 359 | |
| @@ -466,8 +365,10 @@ | ||
| 466 | 365 | $wp_meta_boxes['dashboard']['normal']['core'] = array_merge( $ours, $dashboard ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited |
| 467 | 366 | } |
| 468 | 367 | |
| 469 | 368 | /** |
| 369 | + * Elementor dashboard widget. | |
| 370 | + * | |
| 470 | 371 | * Displays the Elementor dashboard widget. |
| 471 | 372 | * |
| 472 | 373 | * Fired by `wp_add_dashboard_widget` function. |
| 473 | 374 | * |
| @@ -474,49 +375,28 @@ | ||
| 474 | 375 | * @since 1.9.0 |
| 475 | 376 | * @access public |
| 476 | 377 | */ |
| 477 | 378 | public function elementor_dashboard_overview_widget() { |
| 478 | - ?> | |
| 479 | - <div class="e-dashboard-overview e-dashboard-widget"> | |
| 480 | - <?php | |
| 481 | - self::elementor_dashboard_overview_header(); | |
| 482 | - self::elementor_dashboard_overview_recently_edited(); | |
| 483 | - self::elementor_dashboard_overview_news_updates(); | |
| 484 | - self::elementor_dashboard_overview_footer(); | |
| 485 | - ?> | |
| 486 | - </div> | |
| 487 | - <?php | |
| 488 | - } | |
| 379 | + $elementor_feed = Api::get_feed_data(); | |
| 380 | + $recently_edited_query = Utils::get_recently_edited_posts_query(); | |
| 489 | 381 | |
| 490 | - /** | |
| 491 | - * Displays the Elementor dashboard widget - header section. | |
| 492 | - * Fired by `elementor_dashboard_overview_widget` function. | |
| 493 | - * | |
| 494 | - * @param bool $show_versions | |
| 495 | - * @param bool $is_create_post_enabled | |
| 496 | - * | |
| 497 | - * @return void | |
| 498 | - * @since 3.12.0 | |
| 499 | - */ | |
| 500 | - public static function elementor_dashboard_overview_header( bool $show_versions = true, bool $is_create_post_enabled = true ) { | |
| 501 | 382 | if ( User::is_current_user_can_edit_post_type( 'page' ) ) { |
| 502 | - $create_new_label = esc_html__( 'Create New Page', 'elementor' ); | |
| 383 | + $create_new_label = __( 'Create New Page', 'elementor' ); | |
| 503 | 384 | $create_new_post_type = 'page'; |
| 504 | 385 | } elseif ( User::is_current_user_can_edit_post_type( 'post' ) ) { |
| 505 | - $create_new_label = esc_html__( 'Create New Post', 'elementor' ); | |
| 386 | + $create_new_label = __( 'Create New Post', 'elementor' ); | |
| 506 | 387 | $create_new_post_type = 'post'; |
| 507 | 388 | } |
| 508 | 389 | ?> |
| 509 | - <div class="e-overview__header"> | |
| 510 | - <?php if ( $show_versions ) { ?> | |
| 511 | - <div class="e-overview__logo"> | |
| 512 | - <div class="e-logo-wrapper"><i class="eicon-elementor-circle"></i></div> | |
| 513 | - </div> | |
| 390 | + <div class="e-dashboard-widget"> | |
| 391 | + <div class="e-overview__header"> | |
| 392 | + <div class="e-overview__logo"><div class="e-logo-wrapper"><i class="eicon-elementor"></i></div></div> | |
| 514 | 393 | <div class="e-overview__versions"> |
| 515 | - <span class="e-overview__version"><?php echo esc_html__( 'Elementor', 'elementor' ); ?> v<?php echo ELEMENTOR_VERSION; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></span> | |
| 394 | + <span class="e-overview__version"><?php echo __( 'Elementor', 'elementor' ); ?> v<?php echo ELEMENTOR_VERSION; ?></span> | |
| 516 | 395 | <?php |
| 517 | 396 | /** |
| 518 | 397 | * Elementor dashboard widget after the version. |
| 398 | + * | |
| 519 | 399 | * Fires after Elementor version display in the dashboard widget. |
| 520 | 400 | * |
| 521 | 401 | * @since 1.9.0 |
| 522 | 402 | */ |
| @@ -522,112 +402,57 @@ | ||
| 522 | 402 | */ |
| 523 | 403 | do_action( 'elementor/admin/dashboard_overview_widget/after_version' ); |
| 524 | 404 | ?> |
| 525 | 405 | </div> |
| 526 | - <?php } ?> | |
| 527 | - <?php if ( ! empty( $create_new_post_type ) && $is_create_post_enabled ) { ?> | |
| 528 | - <div class="e-overview__create"> | |
| 529 | - <a href="<?php echo esc_url( Plugin::$instance->documents->get_create_new_post_url( $create_new_post_type ) ); ?>" class="button"><span aria-hidden="true" class="dashicons dashicons-plus"></span> <?php echo esc_html( $create_new_label ); ?></a> | |
| 530 | - </div> | |
| 531 | - <?php } ?> | |
| 532 | - </div> | |
| 533 | - <?php | |
| 534 | - } | |
| 535 | - | |
| 536 | - /** | |
| 537 | - * Displays the Elementor dashboard widget - recently edited section. | |
| 538 | - * Fired by `elementor_dashboard_overview_widget` function. | |
| 539 | - * | |
| 540 | - * @param array $args | |
| 541 | - * @param bool $show_heading | |
| 542 | - * | |
| 543 | - * @return void | |
| 544 | - * @since 3.12.0 | |
| 545 | - */ | |
| 546 | - public static function elementor_dashboard_overview_recently_edited( array $args = [], bool $show_heading = true ) { | |
| 547 | - $recently_edited_query = Utils::get_recently_edited_posts_query( $args ); | |
| 548 | - | |
| 549 | - if ( $recently_edited_query->have_posts() ) { ?> | |
| 550 | - <div class="e-overview__recently-edited"> | |
| 551 | - <?php if ( $show_heading ) { ?> | |
| 552 | - <h3 class="e-heading e-divider_bottom"><?php echo esc_html__( 'Recently Edited', 'elementor' ); ?></h3> | |
| 553 | - <?php } ?> | |
| 554 | - <ul class="e-overview__posts"> | |
| 555 | - <?php | |
| 556 | - while ( $recently_edited_query->have_posts() ) { | |
| 557 | - $recently_edited_query->the_post(); | |
| 558 | - $document = Plugin::$instance->documents->get( get_the_ID() ); | |
| 559 | - | |
| 560 | - $date = date_i18n( _x( 'M jS', 'Dashboard Overview Widget Recently Date', 'elementor' ), get_the_modified_time( 'U' ) ); | |
| 561 | - ?> | |
| 562 | - <li class="e-overview__post"> | |
| 563 | - <a href="<?php echo esc_url( $document->get_edit_url() ); ?>" class="e-overview__post-link"><?php echo esc_html( get_the_title() ); ?> | |
| 564 | - <span class="dashicons dashicons-edit"></span></a> | |
| 565 | - <span><?php echo $date; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>, <?php the_modified_time(); ?></span> | |
| 566 | - </li> | |
| 567 | - <?php } ?> | |
| 568 | - </ul> | |
| 406 | + <?php if ( ! empty( $create_new_post_type ) ) : ?> | |
| 407 | + <div class="e-overview__create"> | |
| 408 | + <a href="<?php echo esc_url( Utils::get_create_new_post_url( $create_new_post_type ) ); ?>" class="button"><span aria-hidden="true" class="dashicons dashicons-plus"></span> <?php echo esc_html( $create_new_label ); ?></a> | |
| 409 | + </div> | |
| 410 | + <?php endif; ?> | |
| 569 | 411 | </div> |
| 570 | - <?php } | |
| 571 | - } | |
| 412 | + <?php if ( $recently_edited_query->have_posts() ) : ?> | |
| 413 | + <div class="e-overview__recently-edited"> | |
| 414 | + <h3 class="e-heading e-divider_bottom"><?php echo __( 'Recently Edited', 'elementor' ); ?></h3> | |
| 415 | + <ul class="e-overview__posts"> | |
| 416 | + <?php | |
| 417 | + while ( $recently_edited_query->have_posts() ) : | |
| 418 | + $recently_edited_query->the_post(); | |
| 419 | + $document = Plugin::$instance->documents->get( get_the_ID() ); | |
| 572 | 420 | |
| 573 | - /** | |
| 574 | - * Displays the Elementor dashboard widget - news and updates section. | |
| 575 | - * Fired by `elementor_dashboard_overview_widget` function. | |
| 576 | - * | |
| 577 | - * @param int $limit_feed | |
| 578 | - * @param bool $show_heading | |
| 579 | - * | |
| 580 | - * @return void | |
| 581 | - * @since 3.12.0 | |
| 582 | - * @access public | |
| 583 | - */ | |
| 584 | - public static function elementor_dashboard_overview_news_updates( int $limit_feed = 0, bool $show_heading = true ) { | |
| 585 | - $elementor_feed = Api::get_feed_data(); | |
| 586 | - if ( $limit_feed > 0 ) { | |
| 587 | - $elementor_feed = array_slice( $elementor_feed, 0, $limit_feed ); | |
| 588 | - } | |
| 589 | - | |
| 590 | - if ( ! empty( $elementor_feed ) ) { ?> | |
| 591 | - <div class="e-overview__feed"> | |
| 592 | - <?php if ( $show_heading ) { ?> | |
| 593 | - <h3 class="e-heading e-divider_bottom"><?php echo esc_html__( 'News & Updates', 'elementor' ); ?></h3> | |
| 594 | - <?php } ?> | |
| 595 | - <ul class="e-overview__posts"> | |
| 596 | - <?php foreach ( $elementor_feed as $feed_item ) { ?> | |
| 597 | - <li class="e-overview__post"> | |
| 598 | - <a href="<?php echo esc_url( $feed_item['url'] ); ?>" class="e-overview__post-link" target="_blank"> | |
| 599 | - <?php if ( ! empty( $feed_item['badge'] ) ) { ?> | |
| 600 | - <span class="e-overview__badge"><?php echo esc_html( $feed_item['badge'] ); ?></span> | |
| 601 | - <?php } ?> | |
| 602 | - <?php echo esc_html( $feed_item['title'] ); ?> | |
| 603 | - </a> | |
| 604 | - <p class="e-overview__post-description"><?php echo esc_html( $feed_item['excerpt'] ); ?></p> | |
| 605 | - </li> | |
| 606 | - <?php } ?> | |
| 421 | + $date = date_i18n( _x( 'M jS', 'Dashboard Overview Widget Recently Date', 'elementor' ), get_the_modified_time( 'U' ) ); | |
| 422 | + ?> | |
| 423 | + <li class="e-overview__post"> | |
| 424 | + <a href="<?php echo esc_attr( $document->get_edit_url() ); ?>" class="e-overview__post-link"><?php echo esc_html( get_the_title() ); ?> <span class="dashicons dashicons-edit"></span></a> <span><?php echo $date; ?>, <?php the_time(); ?></span> | |
| 425 | + </li> | |
| 426 | + <?php endwhile; ?> | |
| 427 | + </ul> | |
| 428 | + </div> | |
| 429 | + <?php endif; ?> | |
| 430 | + <?php if ( ! empty( $elementor_feed ) ) : ?> | |
| 431 | + <div class="e-overview__feed"> | |
| 432 | + <h3 class="e-heading e-divider_bottom"><?php echo __( 'News & Updates', 'elementor' ); ?></h3> | |
| 433 | + <ul class="e-overview__posts"> | |
| 434 | + <?php foreach ( $elementor_feed as $feed_item ) : ?> | |
| 435 | + <li class="e-overview__post"> | |
| 436 | + <a href="<?php echo esc_url( $feed_item['url'] ); ?>" class="e-overview__post-link" target="_blank"> | |
| 437 | + <?php if ( ! empty( $feed_item['badge'] ) ) : ?> | |
| 438 | + <span class="e-overview__badge"><?php echo esc_html( $feed_item['badge'] ); ?></span> | |
| 439 | + <?php endif; ?> | |
| 440 | + <?php echo esc_html( $feed_item['title'] ); ?> | |
| 441 | + </a> | |
| 442 | + <p class="e-overview__post-description"><?php echo esc_html( $feed_item['excerpt'] ); ?></p> | |
| 443 | + </li> | |
| 444 | + <?php endforeach; ?> | |
| 445 | + </ul> | |
| 446 | + </div> | |
| 447 | + <?php endif; ?> | |
| 448 | + <div class="e-overview__footer e-divider_top"> | |
| 449 | + <ul> | |
| 450 | + <?php foreach ( $this->get_dashboard_overview_widget_footer_actions() as $action_id => $action ) : ?> | |
| 451 | + <li class="e-overview__<?php echo esc_attr( $action_id ); ?>"><a href="<?php echo esc_attr( $action['link'] ); ?>" target="_blank"><?php echo esc_html( $action['title'] ); ?> <span class="screen-reader-text"><?php echo __( '(opens in a new window)', 'elementor' ); ?></span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></li> | |
| 452 | + <?php endforeach; ?> | |
| 607 | 453 | </ul> |
| 608 | 454 | </div> |
| 609 | - <?php } | |
| 610 | - } | |
| 611 | - | |
| 612 | - /** | |
| 613 | - * Displays the Elementor dashboard widget - footer section. | |
| 614 | - * Fired by `elementor_dashboard_overview_widget` function. | |
| 615 | - * | |
| 616 | - * @since 3.12.0 | |
| 617 | - */ | |
| 618 | - public static function elementor_dashboard_overview_footer() { | |
| 619 | - ?> | |
| 620 | - <div class="e-overview__footer e-divider_top"> | |
| 621 | - <ul> | |
| 622 | - <?php foreach ( self::static_get_dashboard_overview_widget_footer_actions() as $action_id => $action ) { ?> | |
| 623 | - <li class="e-overview__<?php echo esc_attr( $action_id ); ?>"> | |
| 624 | - <a href="<?php echo esc_url( $action['link'] ); ?>" target="_blank"><?php echo esc_html( $action['title'] ); ?> | |
| 625 | - <span class="screen-reader-text"><?php echo esc_html__( '(opens in a new window)', 'elementor' ); ?></span> | |
| 626 | - <span aria-hidden="true" class="dashicons dashicons-external"></span></a> | |
| 627 | - </li> | |
| 628 | - <?php } ?> | |
| 629 | - </ul> | |
| 630 | 455 | </div> |
| 631 | 456 | <?php |
| 632 | 457 | } |
| 633 | 458 | |
| @@ -635,31 +460,34 @@ | ||
| 635 | 460 | * Get elementor dashboard overview widget footer actions. |
| 636 | 461 | * |
| 637 | 462 | * Retrieves the footer action links displayed in elementor dashboard widget. |
| 638 | 463 | * |
| 639 | - * @since 3.12.0 | |
| 640 | - * @access public | |
| 464 | + * @since 1.9.0 | |
| 465 | + * @access private | |
| 641 | 466 | */ |
| 642 | - public static function static_get_dashboard_overview_widget_footer_actions() { | |
| 467 | + private function get_dashboard_overview_widget_footer_actions() { | |
| 643 | 468 | $base_actions = [ |
| 644 | 469 | 'blog' => [ |
| 645 | - 'title' => esc_html__( 'Blog', 'elementor' ), | |
| 470 | + 'title' => __( 'Blog', 'elementor' ), | |
| 646 | 471 | 'link' => 'https://go.elementor.com/overview-widget-blog/', |
| 647 | 472 | ], |
| 648 | 473 | 'help' => [ |
| 649 | - 'title' => esc_html__( 'Help', 'elementor' ), | |
| 474 | + 'title' => __( 'Help', 'elementor' ), | |
| 650 | 475 | 'link' => 'https://go.elementor.com/overview-widget-docs/', |
| 651 | 476 | ], |
| 652 | 477 | ]; |
| 653 | 478 | |
| 654 | - $additions_actions = []; | |
| 655 | - $additions_actions['ai'] = [ | |
| 656 | - 'title' => esc_html__( 'Build Smart with AI', 'elementor' ), | |
| 657 | - 'link' => 'https://go.elementor.com/overview-widget-ai/', | |
| 479 | + $additions_actions = [ | |
| 480 | + 'go-pro' => [ | |
| 481 | + 'title' => __( 'Go Pro', 'elementor' ), | |
| 482 | + 'link' => Utils::get_pro_link( 'https://elementor.com/pro/?utm_source=wp-overview-widget&utm_campaign=gopro&utm_medium=wp-dash' ), | |
| 483 | + ], | |
| 658 | 484 | ]; |
| 659 | - $additions_actions['go-pro'] = [ | |
| 660 | - 'title' => esc_html__( 'Upgrade', 'elementor' ), | |
| 661 | - 'link' => 'https://go.elementor.com/go-pro-wp-overview-widget/', | |
| 485 | + | |
| 486 | + // Visible to all core users when Elementor Pro is not installed. | |
| 487 | + $additions_actions['find_an_expert'] = [ | |
| 488 | + 'title' => __( 'Find an Expert', 'elementor' ), | |
| 489 | + 'link' => 'https://go.elementor.com/go-pro-find-an-expert', | |
| 662 | 490 | ]; |
| 663 | 491 | |
| 664 | 492 | /** |
| 665 | 493 | * Dashboard widget footer actions. |
| @@ -680,20 +508,8 @@ | ||
| 680 | 508 | return $actions; |
| 681 | 509 | } |
| 682 | 510 | |
| 683 | 511 | /** |
| 684 | - * Get elementor dashboard overview widget footer actions. | |
| 685 | - * | |
| 686 | - * Retrieves the footer action links displayed in elementor dashboard widget. | |
| 687 | - * | |
| 688 | - * @since 1.9.0 | |
| 689 | - * @access private | |
| 690 | - */ | |
| 691 | - private function get_dashboard_overview_widget_footer_actions() { | |
| 692 | - return self::static_get_dashboard_overview_widget_footer_actions(); | |
| 693 | - } | |
| 694 | - | |
| 695 | - /** | |
| 696 | 512 | * Admin action new post. |
| 697 | 513 | * |
| 698 | 514 | * When a new post action is fired the title is set to 'Elementor' and the post ID. |
| 699 | 515 | * |
| @@ -704,9 +520,13 @@ | ||
| 704 | 520 | */ |
| 705 | 521 | public function admin_action_new_post() { |
| 706 | 522 | check_admin_referer( 'elementor_action_new_post' ); |
| 707 | 523 | |
| 708 | - $post_type = Utils::get_super_global_value( $_GET, 'post_type' ) ?? 'post'; | |
| 524 | + if ( empty( $_GET['post_type'] ) ) { | |
| 525 | + $post_type = 'post'; | |
| 526 | + } else { | |
| 527 | + $post_type = $_GET['post_type']; | |
| 528 | + } | |
| 709 | 529 | |
| 710 | 530 | if ( ! User::is_current_user_can_edit_post_type( $post_type ) ) { |
| 711 | 531 | return; |
| 712 | 532 | } |
| @@ -713,14 +533,14 @@ | ||
| 713 | 533 | |
| 714 | 534 | if ( empty( $_GET['template_type'] ) ) { |
| 715 | 535 | $type = 'post'; |
| 716 | 536 | } else { |
| 717 | - $type = sanitize_text_field( wp_unslash( $_GET['template_type'] ) ); | |
| 537 | + $type = sanitize_text_field( $_GET['template_type'] ); | |
| 718 | 538 | } |
| 719 | 539 | |
| 720 | - $post_data = Utils::get_super_global_value( $_GET, 'post_data' ) ?? []; | |
| 540 | + $post_data = isset( $_GET['post_data'] ) ? $_GET['post_data'] : []; | |
| 721 | 541 | |
| 722 | - $post_data = $this->filter_post_data( $post_data ); | |
| 542 | + $meta = []; | |
| 723 | 543 | |
| 724 | 544 | /** |
| 725 | 545 | * Create new post meta data. |
| 726 | 546 | * |
| @@ -729,14 +549,8 @@ | ||
| 729 | 549 | * @since 2.0.0 |
| 730 | 550 | * |
| 731 | 551 | * @param array $meta Post meta data. |
| 732 | 552 | */ |
| 733 | - $meta = []; | |
| 734 | - | |
| 735 | - if ( isset( $_GET['meta'] ) && is_array( $_GET['meta'] ) ) { | |
| 736 | - $meta = array_map( 'sanitize_text_field', wp_unslash( $_GET['meta'] ) ); | |
| 737 | - } | |
| 738 | - | |
| 739 | 553 | $meta = apply_filters( 'elementor/admin/create_new_post/meta', $meta ); |
| 740 | 554 | |
| 741 | 555 | $post_data['post_type'] = $post_type; |
| 742 | 556 | |
| @@ -742,118 +556,17 @@ | ||
| 742 | 556 | |
| 743 | 557 | $document = Plugin::$instance->documents->create( $type, $post_data, $meta ); |
| 744 | 558 | |
| 745 | 559 | if ( is_wp_error( $document ) ) { |
| 746 | - wp_die( $document ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 560 | + wp_die( $document ); | |
| 747 | 561 | } |
| 748 | 562 | |
| 749 | - wp_safe_redirect( $document->get_edit_url() ); | |
| 563 | + wp_redirect( $document->get_edit_url() ); | |
| 750 | 564 | |
| 751 | 565 | die; |
| 752 | 566 | } |
| 753 | 567 | |
| 754 | - public function admin_action_site_settings_redirect() { | |
| 755 | - check_admin_referer( 'elementor_action_site_settings_redirect' ); | |
| 756 | - | |
| 757 | - if ( ! current_user_can( 'edit_theme_options' ) ) { | |
| 758 | - wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'elementor' ) ); | |
| 759 | - } | |
| 760 | - | |
| 761 | - $active_tab = filter_input( INPUT_GET, 'active-tab', FILTER_SANITIZE_ENCODED ); | |
| 762 | - | |
| 763 | - $site_settings_url_config = Page::get_site_settings_url_config( $active_tab ); | |
| 764 | - | |
| 765 | - if ( empty( $site_settings_url_config['url'] ) ) { | |
| 766 | - wp_die( esc_html__( 'Unable to create or access Site Settings page.', 'elementor' ) ); | |
| 767 | - } | |
| 768 | - | |
| 769 | - wp_safe_redirect( $site_settings_url_config['url'] ); | |
| 770 | - | |
| 771 | - die; | |
| 772 | - } | |
| 773 | - | |
| 774 | 568 | /** |
| 775 | - * Admin action edit website. | |
| 776 | - * | |
| 777 | - * Redirects to the homepage edit URL if it exists and is built with Elementor, | |
| 778 | - * otherwise redirects to create a new page. | |
| 779 | - * | |
| 780 | - * Fired by `admin_action_elementor_edit_website` action. | |
| 781 | - * | |
| 782 | - * @since 3.x.x | |
| 783 | - * @access public | |
| 784 | - */ | |
| 785 | - public function admin_action_edit_website_redirect() { | |
| 786 | - check_admin_referer( 'elementor_action_edit_website' ); | |
| 787 | - | |
| 788 | - if ( ! User::is_current_user_can_edit_post_type( 'page' ) ) { | |
| 789 | - wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'elementor' ) ); | |
| 790 | - } | |
| 791 | - | |
| 792 | - $homepage_id = $this->get_homepage_id(); | |
| 793 | - $edit_url = $this->get_edit_website_url( $homepage_id ); | |
| 794 | - | |
| 795 | - wp_safe_redirect( $edit_url ); | |
| 796 | - | |
| 797 | - die; | |
| 798 | - } | |
| 799 | - | |
| 800 | - private function get_homepage_id(): ?int { | |
| 801 | - if ( get_option( 'show_on_front' ) !== 'page' ) { | |
| 802 | - return null; | |
| 803 | - } | |
| 804 | - | |
| 805 | - $homepage_id = get_option( 'page_on_front' ); | |
| 806 | - | |
| 807 | - return $homepage_id ? (int) $homepage_id : null; | |
| 808 | - } | |
| 809 | - | |
| 810 | - private function get_edit_website_url( ?int $homepage_id ): string { | |
| 811 | - if ( ! $homepage_id ) { | |
| 812 | - return Plugin::$instance->documents->get_create_new_post_url( 'page' ); | |
| 813 | - } | |
| 814 | - | |
| 815 | - $document = Plugin::$instance->documents->get( $homepage_id ); | |
| 816 | - | |
| 817 | - if ( ! $document || ! $document->is_built_with_elementor() ) { | |
| 818 | - return Plugin::$instance->documents->get_create_new_post_url( 'page' ); | |
| 819 | - } | |
| 820 | - | |
| 821 | - return $document->get_edit_url(); | |
| 822 | - } | |
| 823 | - | |
| 824 | - private function get_allowed_fields_for_role() { | |
| 825 | - $allowed_fields = [ | |
| 826 | - 'post_title', | |
| 827 | - 'post_content', | |
| 828 | - 'post_excerpt', | |
| 829 | - 'post_category', | |
| 830 | - 'post_type', | |
| 831 | - 'tags_input', | |
| 832 | - ]; | |
| 833 | - | |
| 834 | - if ( current_user_can( 'publish_posts' ) ) { | |
| 835 | - $allowed_fields[] = 'post_status'; | |
| 836 | - } | |
| 837 | - | |
| 838 | - if ( current_user_can( 'edit_others_posts' ) ) { | |
| 839 | - $allowed_fields[] = 'post_author'; | |
| 840 | - } | |
| 841 | - | |
| 842 | - return $allowed_fields; | |
| 843 | - } | |
| 844 | - | |
| 845 | - private function filter_post_data( $post_data ) { | |
| 846 | - $allowed_fields = $this->get_allowed_fields_for_role(); | |
| 847 | - return array_filter( | |
| 848 | - $post_data, | |
| 849 | - function( $key ) use ( $allowed_fields ) { | |
| 850 | - return in_array( $key, $allowed_fields, true ); | |
| 851 | - }, | |
| 852 | - ARRAY_FILTER_USE_KEY | |
| 853 | - ); | |
| 854 | - } | |
| 855 | - /** | |
| 856 | 569 | * @since 2.3.0 |
| 857 | 570 | * @access public |
| 858 | 571 | */ |
| 859 | 572 | public function add_new_template_template() { |
| @@ -859,31 +572,13 @@ | ||
| 859 | 572 | public function add_new_template_template() { |
| 860 | 573 | Plugin::$instance->common->add_template( ELEMENTOR_PATH . 'includes/admin-templates/new-template.php' ); |
| 861 | 574 | } |
| 862 | 575 | |
| 863 | - public function add_new_floating_elements_template() { | |
| 864 | - Plugin::$instance->common->add_template( ELEMENTOR_PATH . 'includes/admin-templates/new-floating-elements.php' ); | |
| 865 | - } | |
| 866 | - | |
| 867 | - public function enqueue_new_floating_elements_scripts() { | |
| 868 | - $suffix = Utils::is_script_debug() ? '' : '.min'; | |
| 869 | - | |
| 870 | - wp_enqueue_script( | |
| 871 | - 'elementor-floating-elements-modal', | |
| 872 | - ELEMENTOR_ASSETS_URL . 'js/floating-elements-modal' . $suffix . '.js', | |
| 873 | - [], | |
| 874 | - ELEMENTOR_VERSION, | |
| 875 | - true | |
| 876 | - ); | |
| 877 | - | |
| 878 | - wp_set_script_translations( 'elementor-floating-elements-modal', 'elementor' ); | |
| 879 | - } | |
| 880 | - | |
| 881 | 576 | /** |
| 882 | 577 | * @access public |
| 883 | 578 | */ |
| 884 | 579 | public function enqueue_new_template_scripts() { |
| 885 | - $suffix = Utils::is_script_debug() ? '' : '.min'; | |
| 580 | + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; | |
| 886 | 581 | |
| 887 | 582 | wp_enqueue_script( |
| 888 | 583 | 'elementor-new-template', |
| 889 | 584 | ELEMENTOR_ASSETS_URL . 'js/new-template' . $suffix . '.js', |
| @@ -890,10 +585,8 @@ | ||
| 890 | 585 | [], |
| 891 | 586 | ELEMENTOR_VERSION, |
| 892 | 587 | true |
| 893 | 588 | ); |
| 894 | - | |
| 895 | - wp_set_script_translations( 'elementor-new-template', 'elementor' ); | |
| 896 | 589 | } |
| 897 | 590 | |
| 898 | 591 | /** |
| 899 | 592 | * @since 2.6.0 |
| @@ -906,9 +599,9 @@ | ||
| 906 | 599 | /** |
| 907 | 600 | * @access public |
| 908 | 601 | */ |
| 909 | 602 | public function enqueue_beta_tester_scripts() { |
| 910 | - $suffix = Utils::is_script_debug() ? '' : '.min'; | |
| 603 | + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; | |
| 911 | 604 | |
| 912 | 605 | wp_enqueue_script( |
| 913 | 606 | 'elementor-beta-tester', |
| 914 | 607 | ELEMENTOR_ASSETS_URL . 'js/beta-tester' . $suffix . '.js', |
| @@ -915,26 +608,10 @@ | ||
| 915 | 608 | [], |
| 916 | 609 | ELEMENTOR_VERSION, |
| 917 | 610 | true |
| 918 | 611 | ); |
| 919 | - | |
| 920 | - wp_set_script_translations( 'elementor-beta-tester', 'elementor' ); | |
| 921 | 612 | } |
| 922 | 613 | |
| 923 | - public function init_floating_elements() { | |
| 924 | - $screens = [ | |
| 925 | - 'elementor_library_page_e-floating-buttons' => true, | |
| 926 | - 'edit-e-floating-buttons' => true, | |
| 927 | - ]; | |
| 928 | - | |
| 929 | - if ( ! isset( $screens[ get_current_screen()->id ] ) ) { | |
| 930 | - return; | |
| 931 | - } | |
| 932 | - | |
| 933 | - add_action( 'admin_head', [ $this, 'add_new_floating_elements_template' ] ); | |
| 934 | - add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_new_floating_elements_scripts' ] ); | |
| 935 | - } | |
| 936 | - | |
| 937 | 614 | /** |
| 938 | 615 | * @access public |
| 939 | 616 | */ |
| 940 | 617 | public function init_new_template() { |
| @@ -961,20 +638,11 @@ | ||
| 961 | 638 | <i class="eicon-info-circle"></i> |
| 962 | 639 | </div> |
| 963 | 640 | <div> |
| 964 | 641 | <div class="e-major-update-warning__title"> |
| 965 | - <?php echo esc_html__( 'Heads up, Please backup before upgrade!', 'elementor' ); ?> | |
| 642 | + <?php echo __( 'Heads up, Please backup before upgrade!', 'elementor' ); ?> | |
| 966 | 643 | </div> |
| 967 | - <div class="e-major-update-warning__message"> | |
| 968 | - <?php | |
| 969 | - printf( | |
| 970 | - /* translators: %1$s Link open tag, %2$s: Link close tag. */ | |
| 971 | - esc_html__( 'The latest update includes some substantial changes across different areas of the plugin. We highly recommend you %1$sbackup your site before upgrading%2$s, and make sure you first update in a staging environment', 'elementor' ), | |
| 972 | - '<a href="https://go.elementor.com/wp-dash-update-backup/">', | |
| 973 | - '</a>' | |
| 974 | - ); | |
| 975 | - ?> | |
| 976 | - </div> | |
| 644 | + <div class="e-major-update-warning__message"><?php echo sprintf( __( 'The latest update includes some substantial changes across different areas of the plugin. We highly recommend you <a href="%s">backup your site before upgrading</a>, and make sure you first update in a staging environment', 'elementor' ), 'https://go.elementor.com/wp-dash-update-backup' ); ?></div> | |
| 977 | 645 | </div> |
| 978 | 646 | </div> |
| 979 | 647 | <?php |
| 980 | 648 | } |
| @@ -1000,8 +668,9 @@ | ||
| 1000 | 668 | public function __construct() { |
| 1001 | 669 | Plugin::$instance->init_common(); |
| 1002 | 670 | |
| 1003 | 671 | $this->add_component( 'feedback', new Feedback() ); |
| 672 | + $this->add_component( 'canary-deployment', new Canary_Deployment() ); | |
| 1004 | 673 | $this->add_component( 'admin-notices', new Admin_Notices() ); |
| 1005 | 674 | |
| 1006 | 675 | add_action( 'admin_init', [ $this, 'maybe_redirect_to_getting_started' ] ); |
| 1007 | 676 | |
| @@ -1023,20 +692,15 @@ | ||
| 1023 | 692 | add_action( 'wp_dashboard_setup', [ $this, 'register_dashboard_widgets' ] ); |
| 1024 | 693 | |
| 1025 | 694 | // Admin Actions |
| 1026 | 695 | add_action( 'admin_action_elementor_new_post', [ $this, 'admin_action_new_post' ] ); |
| 1027 | - add_action( 'admin_action_elementor_site_settings_redirect', [ $this, 'admin_action_site_settings_redirect' ] ); | |
| 1028 | - add_action( 'admin_action_elementor_edit_website_redirect', [ $this, 'admin_action_edit_website_redirect' ] ); | |
| 1029 | 696 | |
| 1030 | 697 | add_action( 'current_screen', [ $this, 'init_new_template' ] ); |
| 1031 | - add_action( 'current_screen', [ $this, 'init_floating_elements' ] ); | |
| 1032 | 698 | add_action( 'current_screen', [ $this, 'init_beta_tester' ] ); |
| 1033 | 699 | |
| 1034 | 700 | add_action( 'in_plugin_update_message-' . ELEMENTOR_PLUGIN_BASE, function( $plugin_data ) { |
| 1035 | 701 | $this->version_update_warning( ELEMENTOR_VERSION, $plugin_data['new_version'] ); |
| 1036 | 702 | } ); |
| 1037 | - | |
| 1038 | - add_action( 'elementor/ajax/register_actions', [ $this, 'register_ajax_hints' ] ); | |
| 1039 | 703 | } |
| 1040 | 704 | |
| 1041 | 705 | /** |
| 1042 | 706 | * @since 2.3.0 |
| @@ -1052,10 +716,8 @@ | ||
| 1052 | 716 | 'home_url' => home_url(), |
| 1053 | 717 | 'settings_url' => Settings::get_url(), |
| 1054 | 718 | 'user' => [ |
| 1055 | 719 | 'introduction' => User::get_introduction_meta(), |
| 1056 | - 'restrictions' => Plugin::$instance->role_manager->get_user_restrictions_array(), | |
| 1057 | - 'is_administrator' => current_user_can( 'manage_options' ), | |
| 1058 | 720 | ], |
| 1059 | 721 | 'beta_tester' => [ |
| 1060 | 722 | 'beta_tester_signup' => Beta_Testers::BETA_TESTER_SIGNUP, |
| 1061 | 723 | 'has_email' => $beta_tester_email, |
| @@ -1061,170 +723,9 @@ | ||
| 1061 | 723 | 'has_email' => $beta_tester_email, |
| 1062 | 724 | 'option_enabled' => 'no' !== $elementor_beta, |
| 1063 | 725 | 'signup_dismissed' => $beta_tester_signup_dismissed, |
| 1064 | 726 | ], |
| 1065 | - 'experiments' => $this->get_experiments(), | |
| 1066 | 727 | ]; |
| 1067 | 728 | |
| 1068 | - /** | |
| 1069 | - * Localize settings. | |
| 1070 | - * | |
| 1071 | - * Filters the initial localize settings in the admin. | |
| 1072 | - * | |
| 1073 | - * WordPress has it's own way to pass localized data from PHP (backend) to | |
| 1074 | - * JS (frontend). Elementor uses this method to pass localize data in the | |
| 1075 | - * admin. This hook can be used to add more localized settings in addition | |
| 1076 | - * to the initial Elementor settings. | |
| 1077 | - * | |
| 1078 | - * @since 2.3.0 | |
| 1079 | - * | |
| 1080 | - * @param array $settings Initial localize settings. | |
| 1081 | - */ | |
| 1082 | - $settings = apply_filters( 'elementor/admin/localize_settings', $settings ); | |
| 1083 | - | |
| 1084 | - return $settings; | |
| 1085 | - } | |
| 1086 | - | |
| 1087 | - private function get_experiments() { | |
| 1088 | - return ( new Collection( Plugin::$instance->experiments->get_features() ) ) | |
| 1089 | - ->map( function ( $experiment_data ) { | |
| 1090 | - $dependencies = $experiment_data['dependencies'] ?? []; | |
| 1091 | - | |
| 1092 | - $dependencies = ( new Collection( $dependencies ) ) | |
| 1093 | - ->map( function ( $dependency ) { | |
| 1094 | - return $dependency->get_name(); | |
| 1095 | - } )->all(); | |
| 1096 | - | |
| 1097 | - return [ | |
| 1098 | - 'name' => $experiment_data['name'], | |
| 1099 | - 'title' => $experiment_data['title'] ?? $experiment_data['name'], | |
| 1100 | - 'state' => $experiment_data['state'], | |
| 1101 | - 'default' => $experiment_data['default'], | |
| 1102 | - 'dependencies' => $dependencies, | |
| 1103 | - 'messages' => $experiment_data['messages'] ?? [], | |
| 1104 | - ]; | |
| 1105 | - } )->all(); | |
| 1106 | - } | |
| 1107 | - | |
| 1108 | - private function maybe_enqueue_hints() { | |
| 1109 | - $plugin_slug = 'image-optimization'; | |
| 1110 | - | |
| 1111 | - if ( ! Hints::should_display_hint( $plugin_slug ) ) { | |
| 1112 | - return; | |
| 1113 | - } | |
| 1114 | - | |
| 1115 | - wp_register_script( | |
| 1116 | - 'media-hints', | |
| 1117 | - $this->get_js_assets_url( 'media-hints' ), | |
| 1118 | - [], | |
| 1119 | - ELEMENTOR_VERSION, | |
| 1120 | - true | |
| 1121 | - ); | |
| 1122 | - | |
| 1123 | - $one_subscription = Hints::is_plugin_connected_to_one_subscription(); | |
| 1124 | - $is_installed = Hints::is_plugin_installed( $plugin_slug ); | |
| 1125 | - $is_active = Hints::is_plugin_active( $plugin_slug ); | |
| 1126 | - | |
| 1127 | - if ( $is_active ) { | |
| 1128 | - return; | |
| 1129 | - } | |
| 1130 | - | |
| 1131 | - if ( $one_subscription ) { | |
| 1132 | - if ( ! $is_installed ) { | |
| 1133 | - $description = esc_html__( 'Automatically optimize images to improve site speed and performance. Included with your ONE subscription.', 'elementor' ); | |
| 1134 | - $button_text = esc_html__( 'Install now', 'elementor' ); | |
| 1135 | - $button_url = Hints::get_plugin_install_url( $plugin_slug ); | |
| 1136 | - } elseif ( ! $is_active ) { | |
| 1137 | - $description = esc_html__( 'Image Optimizer is installed and included in your ONE subscription. Activate it to optimize images and improve site performance.', 'elementor' ); | |
| 1138 | - $button_text = esc_html__( 'Activate now', 'elementor' ); | |
| 1139 | - $button_url = Hints::get_plugin_activate_url( $plugin_slug ); | |
| 1140 | - } | |
| 1141 | - } else { | |
| 1142 | - $description = esc_html__( 'Optimize your images to enhance site performance by using Image Optimizer.', 'elementor' ); | |
| 1143 | - if ( ! $is_installed ) { | |
| 1144 | - $button_text = esc_html__( 'Install now', 'elementor' ); | |
| 1145 | - $button_url = Hints::get_plugin_install_url( $plugin_slug ); | |
| 1146 | - } elseif ( ! $is_active ) { | |
| 1147 | - $button_text = esc_html__( 'Activate now', 'elementor' ); | |
| 1148 | - $button_url = Hints::get_plugin_activate_url( $plugin_slug ); | |
| 1149 | - } | |
| 1150 | - } | |
| 1151 | - | |
| 1152 | - $dismissible = 'image_optimizer_hint'; | |
| 1153 | - | |
| 1154 | - $title = esc_html__( 'Speed up your website with Image Optimizer', 'elementor' ); | |
| 1155 | - $content = sprintf( | |
| 1156 | - "<strong>%1\$s</strong><br>%2\$s <a class='e-btn-1' href='%3\$s' target='_blank'>%4\$s</a>!", | |
| 1157 | - $title, | |
| 1158 | - $description, | |
| 1159 | - $button_url, | |
| 1160 | - $button_text | |
| 1161 | - ); | |
| 1162 | - | |
| 1163 | - wp_localize_script( 'media-hints', 'elementorAdminHints', [ | |
| 1164 | - 'mediaHint' => [ | |
| 1165 | - 'display' => true, | |
| 1166 | - 'type' => 'info', | |
| 1167 | - 'content' => $content, | |
| 1168 | - 'icon' => true, | |
| 1169 | - 'dismissible' => $dismissible, | |
| 1170 | - 'dismiss' => esc_attr__( 'Dismiss this notice.', 'elementor' ), | |
| 1171 | - 'button_event' => $dismissible, | |
| 1172 | - 'button_data' => base64_encode( | |
| 1173 | - wp_json_encode( [ | |
| 1174 | - 'action_url' => $button_url, | |
| 1175 | - ] ), | |
| 1176 | - ), | |
| 1177 | - ], | |
| 1178 | - ] ); | |
| 1179 | - | |
| 1180 | - wp_enqueue_script( 'media-hints' ); | |
| 1181 | - } | |
| 1182 | - | |
| 1183 | - public function register_ajax_hints( $ajax_manager ) { | |
| 1184 | - $ajax_manager->register_ajax_action( 'elementor_image_optimization_campaign', [ $this, 'ajax_set_image_optimization_campaign' ] ); | |
| 1185 | - $ajax_manager->register_ajax_action( 'elementor_core_site_mailer_campaign', [ $this, 'ajax_site_mailer_campaign' ] ); | |
| 1186 | - $ajax_manager->register_ajax_action( 'elementor_core_ally_campaign', [ $this, 'ajax_ally_campaign' ] ); | |
| 1187 | - } | |
| 1188 | - | |
| 1189 | - public function ajax_ally_campaign( $request ) { | |
| 1190 | - if ( ! current_user_can( 'install_plugins' ) ) { | |
| 1191 | - return; | |
| 1192 | - } | |
| 1193 | - | |
| 1194 | - $campaign_data = [ | |
| 1195 | - 'campaign' => sanitize_key( $request['campaign'] ?? '' ), | |
| 1196 | - 'source' => sanitize_key( $request['source'] ?? '' ), | |
| 1197 | - 'medium' => sanitize_key( $request['medium'] ?? '' ), | |
| 1198 | - ]; | |
| 1199 | - | |
| 1200 | - set_transient( 'elementor_ea11y_campaign', $campaign_data, 30 * DAY_IN_SECONDS ); | |
| 1201 | - } | |
| 1202 | - | |
| 1203 | - public function ajax_set_image_optimization_campaign( $request ) { | |
| 1204 | - if ( ! current_user_can( 'install_plugins' ) ) { | |
| 1205 | - return; | |
| 1206 | - } | |
| 1207 | - | |
| 1208 | - $campaign_data = [ | |
| 1209 | - 'campaign' => sanitize_key( $request['campaign'] ?? '' ), | |
| 1210 | - 'source' => sanitize_key( $request['source'] ?? '' ), | |
| 1211 | - 'medium' => sanitize_key( $request['medium'] ?? '' ), | |
| 1212 | - ]; | |
| 1213 | - | |
| 1214 | - set_transient( 'elementor_image_optimization_campaign', $campaign_data, 30 * DAY_IN_SECONDS ); | |
| 1215 | - } | |
| 1216 | - | |
| 1217 | - public function ajax_site_mailer_campaign( $request ) { | |
| 1218 | - if ( ! current_user_can( 'install_plugins' ) ) { | |
| 1219 | - return; | |
| 1220 | - } | |
| 1221 | - | |
| 1222 | - $campaign_data = [ | |
| 1223 | - 'campaign' => sanitize_key( $request['campaign'] ?? '' ), | |
| 1224 | - 'source' => sanitize_key( $request['source'] ?? '' ), | |
| 1225 | - 'medium' => sanitize_key( $request['medium'] ?? '' ), | |
| 1226 | - ]; | |
| 1227 | - | |
| 1228 | - set_transient( 'elementor_site_mailer_campaign', $campaign_data, 30 * DAY_IN_SECONDS ); | |
| 729 | + return apply_filters( 'elementor/admin/localize_settings', $settings ); | |
| 1229 | 730 | } |
| 1230 | 731 | } |