PluginProbe
Elementor Website Builder – more than just a page builder / 3.0.2
Elementor Website Builder – more than just a page builder v3.0.2
4.3.1 4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 All 454 releases
← All changes | core/admin/admin.php +128 -614 4.3.03.0.2 View file →
@@ -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 - <i class="eicon-wordpress" aria-hidden="true"></i>
247 - <?php echo esc_html__( 'Edit with WordPress', 'elementor' ); ?>
150 + <i class="eicon-arrow-<?php echo ( is_rtl() ) ? 'right' : 'left'; ?>" aria-hidden="true"></i>
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 ) {
@@ -294,9 +198,9 @@
294 198 if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
295 199 return;
296 200 }
297 201
298 - Plugin::$instance->documents->get( $post_id )->set_is_built_with_elementor( ! empty( $_POST['_elementor_post_mode'] ) );
202 + Plugin::$instance->db->set_is_elementor_page( $post_id, ! empty( $_POST['_elementor_post_mode'] ) );
299 203 }
300 204
301 205 /**
302 206 * Add Elementor post state.
@@ -313,12 +217,10 @@
313 217 *
314 218 * @return array A filtered array of post display states.
315 219 */
316 220 public function add_elementor_post_state( $post_states, $post ) {
317 - $document = Plugin::$instance->documents->get( $post->ID );
318 -
319 - if ( $document && $document->is_built_with_elementor() && $document->is_editable_by_current_user() ) {
320 - $post_states['elementor'] = esc_html__( 'Elementor', 'elementor' );
221 + if ( User::is_current_user_can_edit( $post->ID ) && Plugin::$instance->db->is_built_with_elementor( $post->ID ) ) {
222 + $post_states['elementor'] = __( 'Elementor', 'elementor' );
321 223 }
322 224
323 225 return $post_states;
324 226 }
@@ -342,12 +244,10 @@
342 244
343 245 if ( in_array( $pagenow, [ 'post.php', 'post-new.php' ], true ) && Utils::is_post_support() ) {
344 246 $post = get_post();
345 247
346 - $document = Plugin::$instance->documents->get( $post->ID );
248 + $mode_class = Plugin::$instance->db->is_built_with_elementor( $post->ID ) ? 'elementor-editor-active' : 'elementor-editor-inactive';
347 249
348 - $mode_class = $document && $document->is_built_with_elementor() ? 'elementor-editor-active' : 'elementor-editor-inactive';
349 -
350 250 $classes .= ' ' . $mode_class;
351 251 }
352 252
353 253 return $classes;
@@ -367,19 +267,14 @@
367 267 *
368 268 * @return array An array of plugin action links.
369 269 */
370 270 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' ) );
271 + $settings_link = sprintf( '<a href="%1$s">%2$s</a>', admin_url( 'admin.php?page=' . Settings::PAGE_ID ), __( 'Settings', 'elementor' ) );
372 272
373 273 array_unshift( $links, $settings_link );
374 274
375 - $go_pro_text = esc_html__( 'Get Elementor Pro', 'elementor' );
376 - if ( Utils::is_sale_time() ) {
377 - $go_pro_text = esc_html__( 'Sale! Upgrade Now', 'elementor' );
378 - }
275 + $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 276
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 277 return $links;
383 278 }
384 279
385 280 /**
@@ -401,10 +296,10 @@
401 296 */
402 297 public function plugin_row_meta( $plugin_meta, $plugin_file ) {
403 298 if ( ELEMENTOR_PLUGIN_BASE === $plugin_file ) {
404 299 $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>',
300 + 'docs' => '<a href="https://go.elementor.com/docs-admin-plugins/" aria-label="' . esc_attr( __( 'View Elementor Documentation', 'elementor' ) ) . '" target="_blank">' . __( 'Docs & FAQs', 'elementor' ) . '</a>',
301 + '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 302 ];
408 303
409 304 $plugin_meta = array_merge( $plugin_meta, $row_meta );
410 305 }
@@ -427,13 +322,8 @@
427 322 * @return string The content that will be printed.
428 323 */
429 324 public function admin_footer_text( $footer_text ) {
430 325 $current_screen = get_current_screen();
431 -
432 - if ( $current_screen && str_ends_with( $current_screen->id, 'elementor-mcp' ) ) {
433 - return $footer_text;
434 - }
435 -
436 326 $is_elementor_screen = ( $current_screen && false !== strpos( $current_screen->id, 'elementor' ) );
437 327
438 328 if ( $is_elementor_screen ) {
439 329 $footer_text = sprintf(
@@ -438,9 +328,9 @@
438 328 if ( $is_elementor_screen ) {
439 329 $footer_text = sprintf(
440 330 /* translators: 1: Elementor, 2: Link to plugin review */
441 331 __( 'Enjoyed %1$s? Please leave us a %2$s rating. We really appreciate your support!', 'elementor' ),
442 - '<strong>' . esc_html__( 'Elementor', 'elementor' ) . '</strong>',
332 + '<strong>' . __( 'Elementor', 'elementor' ) . '</strong>',
443 333 '<a href="https://go.elementor.com/admin-review/" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a>'
444 334 );
445 335 }
446 336
@@ -457,9 +347,9 @@
457 347 * @since 1.9.0
458 348 * @access public
459 349 */
460 350 public function register_dashboard_widgets() {
461 - wp_add_dashboard_widget( 'e-dashboard-overview', esc_html__( 'Elementor Overview', 'elementor' ), [ $this, 'elementor_dashboard_overview_widget' ] );
351 + wp_add_dashboard_widget( 'e-dashboard-overview', __( 'Elementor Overview', 'elementor' ), [ $this, 'elementor_dashboard_overview_widget' ] );
462 352
463 353 // Move our widget to top.
464 354 global $wp_meta_boxes;
465 355
@@ -471,8 +361,10 @@
471 361 $wp_meta_boxes['dashboard']['normal']['core'] = array_merge( $ours, $dashboard ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
472 362 }
473 363
474 364 /**
365 + * Elementor dashboard widget.
366 + *
475 367 * Displays the Elementor dashboard widget.
476 368 *
477 369 * Fired by `wp_add_dashboard_widget` function.
478 370 *
@@ -479,49 +371,38 @@
479 371 * @since 1.9.0
480 372 * @access public
481 373 */
482 374 public function elementor_dashboard_overview_widget() {
483 - ?>
484 - <div class="e-dashboard-overview e-dashboard-widget">
485 - <?php
486 - self::elementor_dashboard_overview_header();
487 - self::elementor_dashboard_overview_recently_edited();
488 - self::elementor_dashboard_overview_news_updates();
489 - self::elementor_dashboard_overview_footer();
490 - ?>
491 - </div>
492 - <?php
493 - }
375 + $elementor_feed = Api::get_feed_data();
494 376
495 - /**
496 - * Displays the Elementor dashboard widget - header section.
497 - * Fired by `elementor_dashboard_overview_widget` function.
498 - *
499 - * @param bool $show_versions
500 - * @param bool $is_create_post_enabled
501 - *
502 - * @return void
503 - * @since 3.12.0
504 - */
505 - public static function elementor_dashboard_overview_header( bool $show_versions = true, bool $is_create_post_enabled = true ) {
377 + $recently_edited_query_args = [
378 + 'post_type' => 'any',
379 + 'post_status' => [ 'publish', 'draft' ],
380 + 'posts_per_page' => '3',
381 + 'meta_key' => '_elementor_edit_mode',
382 + 'meta_value' => 'builder',
383 + 'orderby' => 'modified',
384 + ];
385 +
386 + $recently_edited_query = new \WP_Query( $recently_edited_query_args );
387 +
506 388 if ( User::is_current_user_can_edit_post_type( 'page' ) ) {
507 - $create_new_label = esc_html__( 'Create New Page', 'elementor' );
389 + $create_new_label = __( 'Create New Page', 'elementor' );
508 390 $create_new_post_type = 'page';
509 391 } elseif ( User::is_current_user_can_edit_post_type( 'post' ) ) {
510 - $create_new_label = esc_html__( 'Create New Post', 'elementor' );
392 + $create_new_label = __( 'Create New Post', 'elementor' );
511 393 $create_new_post_type = 'post';
512 394 }
513 395 ?>
514 - <div class="e-overview__header">
515 - <?php if ( $show_versions ) { ?>
516 - <div class="e-overview__logo">
517 - <div class="e-logo-wrapper"><i class="eicon-elementor-circle"></i></div>
518 - </div>
396 + <div class="e-dashboard-widget">
397 + <div class="e-overview__header">
398 + <div class="e-overview__logo"><div class="e-logo-wrapper"><i class="eicon-elementor"></i></div></div>
519 399 <div class="e-overview__versions">
520 - <span class="e-overview__version"><?php echo esc_html__( 'Elementor', 'elementor' ); ?> v<?php echo ELEMENTOR_VERSION; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></span>
400 + <span class="e-overview__version"><?php echo __( 'Elementor', 'elementor' ); ?> v<?php echo ELEMENTOR_VERSION; ?></span>
521 401 <?php
522 402 /**
523 403 * Elementor dashboard widget after the version.
404 + *
524 405 * Fires after Elementor version display in the dashboard widget.
525 406 *
526 407 * @since 1.9.0
527 408 */
@@ -527,112 +408,57 @@
527 408 */
528 409 do_action( 'elementor/admin/dashboard_overview_widget/after_version' );
529 410 ?>
530 411 </div>
531 - <?php } ?>
532 - <?php if ( ! empty( $create_new_post_type ) && $is_create_post_enabled ) { ?>
533 - <div class="e-overview__create">
534 - <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>
535 - </div>
536 - <?php } ?>
537 - </div>
538 - <?php
539 - }
540 -
541 - /**
542 - * Displays the Elementor dashboard widget - recently edited section.
543 - * Fired by `elementor_dashboard_overview_widget` function.
544 - *
545 - * @param array $args
546 - * @param bool $show_heading
547 - *
548 - * @return void
549 - * @since 3.12.0
550 - */
551 - public static function elementor_dashboard_overview_recently_edited( array $args = [], bool $show_heading = true ) {
552 - $recently_edited_query = Utils::get_recently_edited_posts_query( $args );
553 -
554 - if ( $recently_edited_query->have_posts() ) { ?>
555 - <div class="e-overview__recently-edited">
556 - <?php if ( $show_heading ) { ?>
557 - <h3 class="e-heading e-divider_bottom"><?php echo esc_html__( 'Recently Edited', 'elementor' ); ?></h3>
558 - <?php } ?>
559 - <ul class="e-overview__posts">
560 - <?php
561 - while ( $recently_edited_query->have_posts() ) {
562 - $recently_edited_query->the_post();
563 - $document = Plugin::$instance->documents->get( get_the_ID() );
564 -
565 - $date = date_i18n( _x( 'M jS', 'Dashboard Overview Widget Recently Date', 'elementor' ), get_the_modified_time( 'U' ) );
566 - ?>
567 - <li class="e-overview__post">
568 - <a href="<?php echo esc_url( $document->get_edit_url() ); ?>" class="e-overview__post-link"><?php echo esc_html( get_the_title() ); ?>
569 - <span class="dashicons dashicons-edit"></span></a>
570 - <span><?php echo $date; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>, <?php the_modified_time(); ?></span>
571 - </li>
572 - <?php } ?>
573 - </ul>
412 + <?php if ( ! empty( $create_new_post_type ) ) : ?>
413 + <div class="e-overview__create">
414 + <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>
415 + </div>
416 + <?php endif; ?>
574 417 </div>
575 - <?php }
576 - }
418 + <?php if ( $recently_edited_query->have_posts() ) : ?>
419 + <div class="e-overview__recently-edited">
420 + <h3 class="e-overview__heading"><?php echo __( 'Recently Edited', 'elementor' ); ?></h3>
421 + <ul class="e-overview__posts">
422 + <?php
423 + while ( $recently_edited_query->have_posts() ) :
424 + $recently_edited_query->the_post();
425 + $document = Plugin::$instance->documents->get( get_the_ID() );
577 426
578 - /**
579 - * Displays the Elementor dashboard widget - news and updates section.
580 - * Fired by `elementor_dashboard_overview_widget` function.
581 - *
582 - * @param int $limit_feed
583 - * @param bool $show_heading
584 - *
585 - * @return void
586 - * @since 3.12.0
587 - * @access public
588 - */
589 - public static function elementor_dashboard_overview_news_updates( int $limit_feed = 0, bool $show_heading = true ) {
590 - $elementor_feed = Api::get_feed_data();
591 - if ( $limit_feed > 0 ) {
592 - $elementor_feed = array_slice( $elementor_feed, 0, $limit_feed );
593 - }
594 -
595 - if ( ! empty( $elementor_feed ) ) { ?>
596 - <div class="e-overview__feed">
597 - <?php if ( $show_heading ) { ?>
598 - <h3 class="e-heading e-divider_bottom"><?php echo esc_html__( 'News & Updates', 'elementor' ); ?></h3>
599 - <?php } ?>
600 - <ul class="e-overview__posts">
601 - <?php foreach ( $elementor_feed as $feed_item ) { ?>
602 - <li class="e-overview__post">
603 - <a href="<?php echo esc_url( $feed_item['url'] ); ?>" class="e-overview__post-link" target="_blank">
604 - <?php if ( ! empty( $feed_item['badge'] ) ) { ?>
605 - <span class="e-overview__badge"><?php echo esc_html( $feed_item['badge'] ); ?></span>
606 - <?php } ?>
607 - <?php echo esc_html( $feed_item['title'] ); ?>
608 - </a>
609 - <p class="e-overview__post-description"><?php echo esc_html( $feed_item['excerpt'] ); ?></p>
610 - </li>
611 - <?php } ?>
427 + $date = date_i18n( _x( 'M jS', 'Dashboard Overview Widget Recently Date', 'elementor' ), get_the_modified_time( 'U' ) );
428 + ?>
429 + <li class="e-overview__post">
430 + <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>
431 + </li>
432 + <?php endwhile; ?>
433 + </ul>
434 + </div>
435 + <?php endif; ?>
436 + <?php if ( ! empty( $elementor_feed ) ) : ?>
437 + <div class="e-overview__feed">
438 + <h3 class="e-overview__heading"><?php echo __( 'News & Updates', 'elementor' ); ?></h3>
439 + <ul class="e-overview__posts">
440 + <?php foreach ( $elementor_feed as $feed_item ) : ?>
441 + <li class="e-overview__post">
442 + <a href="<?php echo esc_url( $feed_item['url'] ); ?>" class="e-overview__post-link" target="_blank">
443 + <?php if ( ! empty( $feed_item['badge'] ) ) : ?>
444 + <span class="e-overview__badge"><?php echo esc_html( $feed_item['badge'] ); ?></span>
445 + <?php endif; ?>
446 + <?php echo esc_html( $feed_item['title'] ); ?>
447 + </a>
448 + <p class="e-overview__post-description"><?php echo esc_html( $feed_item['excerpt'] ); ?></p>
449 + </li>
450 + <?php endforeach; ?>
451 + </ul>
452 + </div>
453 + <?php endif; ?>
454 + <div class="e-overview__footer">
455 + <ul>
456 + <?php foreach ( $this->get_dashboard_overview_widget_footer_actions() as $action_id => $action ) : ?>
457 + <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>
458 + <?php endforeach; ?>
612 459 </ul>
613 460 </div>
614 - <?php }
615 - }
616 -
617 - /**
618 - * Displays the Elementor dashboard widget - footer section.
619 - * Fired by `elementor_dashboard_overview_widget` function.
620 - *
621 - * @since 3.12.0
622 - */
623 - public static function elementor_dashboard_overview_footer() {
624 - ?>
625 - <div class="e-overview__footer e-divider_top">
626 - <ul>
627 - <?php foreach ( self::static_get_dashboard_overview_widget_footer_actions() as $action_id => $action ) { ?>
628 - <li class="e-overview__<?php echo esc_attr( $action_id ); ?>">
629 - <a href="<?php echo esc_url( $action['link'] ); ?>" target="_blank"><?php echo esc_html( $action['title'] ); ?>
630 - <span class="screen-reader-text"><?php echo esc_html__( '(opens in a new window)', 'elementor' ); ?></span>
631 - <span aria-hidden="true" class="dashicons dashicons-external"></span></a>
632 - </li>
633 - <?php } ?>
634 - </ul>
635 461 </div>
636 462 <?php
637 463 }
638 464
@@ -640,32 +466,29 @@
640 466 * Get elementor dashboard overview widget footer actions.
641 467 *
642 468 * Retrieves the footer action links displayed in elementor dashboard widget.
643 469 *
644 - * @since 3.12.0
645 - * @access public
470 + * @since 1.9.0
471 + * @access private
646 472 */
647 - public static function static_get_dashboard_overview_widget_footer_actions() {
473 + private function get_dashboard_overview_widget_footer_actions() {
648 474 $base_actions = [
649 475 'blog' => [
650 - 'title' => esc_html__( 'Blog', 'elementor' ),
476 + 'title' => __( 'Blog', 'elementor' ),
651 477 'link' => 'https://go.elementor.com/overview-widget-blog/',
652 478 ],
653 479 'help' => [
654 - 'title' => esc_html__( 'Help', 'elementor' ),
480 + 'title' => __( 'Help', 'elementor' ),
655 481 'link' => 'https://go.elementor.com/overview-widget-docs/',
656 482 ],
657 483 ];
658 484
659 - $additions_actions = [];
660 - $additions_actions['ai'] = [
661 - 'title' => esc_html__( 'Build Smart with AI', 'elementor' ),
662 - 'link' => 'https://go.elementor.com/overview-widget-ai/',
485 + $additions_actions = [
486 + 'go-pro' => [
487 + 'title' => __( 'Go Pro', 'elementor' ),
488 + 'link' => Utils::get_pro_link( 'https://elementor.com/pro/?utm_source=wp-overview-widget&utm_campaign=gopro&utm_medium=wp-dash' ),
489 + ],
663 490 ];
664 - $additions_actions['go-pro'] = [
665 - 'title' => esc_html__( 'Upgrade', 'elementor' ),
666 - 'link' => 'https://go.elementor.com/go-pro-wp-overview-widget/',
667 - ];
668 491
669 492 /**
670 493 * Dashboard widget footer actions.
671 494 *
@@ -685,20 +508,8 @@
685 508 return $actions;
686 509 }
687 510
688 511 /**
689 - * Get elementor dashboard overview widget footer actions.
690 - *
691 - * Retrieves the footer action links displayed in elementor dashboard widget.
692 - *
693 - * @since 1.9.0
694 - * @access private
695 - */
696 - private function get_dashboard_overview_widget_footer_actions() {
697 - return self::static_get_dashboard_overview_widget_footer_actions();
698 - }
699 -
700 - /**
701 512 * Admin action new post.
702 513 *
703 514 * When a new post action is fired the title is set to 'Elementor' and the post ID.
704 515 *
@@ -709,9 +520,13 @@
709 520 */
710 521 public function admin_action_new_post() {
711 522 check_admin_referer( 'elementor_action_new_post' );
712 523
713 - $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 + }
714 529
715 530 if ( ! User::is_current_user_can_edit_post_type( $post_type ) ) {
716 531 return;
717 532 }
@@ -718,14 +533,14 @@
718 533
719 534 if ( empty( $_GET['template_type'] ) ) {
720 535 $type = 'post';
721 536 } else {
722 - $type = sanitize_text_field( wp_unslash( $_GET['template_type'] ) );
537 + $type = sanitize_text_field( $_GET['template_type'] );
723 538 }
724 539
725 - $post_data = Utils::get_super_global_value( $_GET, 'post_data' ) ?? [];
540 + $post_data = isset( $_GET['post_data'] ) ? $_GET['post_data'] : [];
726 541
727 - $post_data = $this->filter_post_data( $post_data );
542 + $meta = [];
728 543
729 544 /**
730 545 * Create new post meta data.
731 546 *
@@ -734,14 +549,8 @@
734 549 * @since 2.0.0
735 550 *
736 551 * @param array $meta Post meta data.
737 552 */
738 - $meta = [];
739 -
740 - if ( isset( $_GET['meta'] ) && is_array( $_GET['meta'] ) ) {
741 - $meta = array_map( 'sanitize_text_field', wp_unslash( $_GET['meta'] ) );
742 - }
743 -
744 553 $meta = apply_filters( 'elementor/admin/create_new_post/meta', $meta );
745 554
746 555 $post_data['post_type'] = $post_type;
747 556
@@ -747,118 +556,17 @@
747 556
748 557 $document = Plugin::$instance->documents->create( $type, $post_data, $meta );
749 558
750 559 if ( is_wp_error( $document ) ) {
751 - wp_die( $document ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
560 + wp_die( $document );
752 561 }
753 562
754 - wp_safe_redirect( $document->get_edit_url() );
563 + wp_redirect( $document->get_edit_url() );
755 564
756 565 die;
757 566 }
758 567
759 - public function admin_action_site_settings_redirect() {
760 - check_admin_referer( 'elementor_action_site_settings_redirect' );
761 -
762 - if ( ! current_user_can( 'edit_theme_options' ) ) {
763 - wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'elementor' ) );
764 - }
765 -
766 - $active_tab = filter_input( INPUT_GET, 'active-tab', FILTER_SANITIZE_ENCODED );
767 -
768 - $site_settings_url_config = Page::get_site_settings_url_config( $active_tab );
769 -
770 - if ( empty( $site_settings_url_config['url'] ) ) {
771 - wp_die( esc_html__( 'Unable to create or access Site Settings page.', 'elementor' ) );
772 - }
773 -
774 - wp_safe_redirect( $site_settings_url_config['url'] );
775 -
776 - die;
777 - }
778 -
779 568 /**
780 - * Admin action edit website.
781 - *
782 - * Redirects to the homepage edit URL if it exists and is built with Elementor,
783 - * otherwise redirects to create a new page.
784 - *
785 - * Fired by `admin_action_elementor_edit_website` action.
786 - *
787 - * @since 3.x.x
788 - * @access public
789 - */
790 - public function admin_action_edit_website_redirect() {
791 - check_admin_referer( 'elementor_action_edit_website' );
792 -
793 - if ( ! User::is_current_user_can_edit_post_type( 'page' ) ) {
794 - wp_die( esc_html__( 'You do not have sufficient permissions to access this page.', 'elementor' ) );
795 - }
796 -
797 - $homepage_id = $this->get_homepage_id();
798 - $edit_url = $this->get_edit_website_url( $homepage_id );
799 -
800 - wp_safe_redirect( $edit_url );
801 -
802 - die;
803 - }
804 -
805 - private function get_homepage_id(): ?int {
806 - if ( get_option( 'show_on_front' ) !== 'page' ) {
807 - return null;
808 - }
809 -
810 - $homepage_id = get_option( 'page_on_front' );
811 -
812 - return $homepage_id ? (int) $homepage_id : null;
813 - }
814 -
815 - private function get_edit_website_url( ?int $homepage_id ): string {
816 - if ( ! $homepage_id ) {
817 - return Plugin::$instance->documents->get_create_new_post_url( 'page' );
818 - }
819 -
820 - $document = Plugin::$instance->documents->get( $homepage_id );
821 -
822 - if ( ! $document || ! $document->is_built_with_elementor() ) {
823 - return Plugin::$instance->documents->get_create_new_post_url( 'page' );
824 - }
825 -
826 - return $document->get_edit_url();
827 - }
828 -
829 - private function get_allowed_fields_for_role() {
830 - $allowed_fields = [
831 - 'post_title',
832 - 'post_content',
833 - 'post_excerpt',
834 - 'post_category',
835 - 'post_type',
836 - 'tags_input',
837 - ];
838 -
839 - if ( current_user_can( 'publish_posts' ) ) {
840 - $allowed_fields[] = 'post_status';
841 - }
842 -
843 - if ( current_user_can( 'edit_others_posts' ) ) {
844 - $allowed_fields[] = 'post_author';
845 - }
846 -
847 - return $allowed_fields;
848 - }
849 -
850 - private function filter_post_data( $post_data ) {
851 - $allowed_fields = $this->get_allowed_fields_for_role();
852 - return array_filter(
853 - $post_data,
854 - function( $key ) use ( $allowed_fields ) {
855 - return in_array( $key, $allowed_fields, true );
856 - },
857 - ARRAY_FILTER_USE_KEY
858 - );
859 - }
860 - /**
861 569 * @since 2.3.0
862 570 * @access public
863 571 */
864 572 public function add_new_template_template() {
@@ -864,31 +572,13 @@
864 572 public function add_new_template_template() {
865 573 Plugin::$instance->common->add_template( ELEMENTOR_PATH . 'includes/admin-templates/new-template.php' );
866 574 }
867 575
868 - public function add_new_floating_elements_template() {
869 - Plugin::$instance->common->add_template( ELEMENTOR_PATH . 'includes/admin-templates/new-floating-elements.php' );
870 - }
871 -
872 - public function enqueue_new_floating_elements_scripts() {
873 - $suffix = Utils::is_script_debug() ? '' : '.min';
874 -
875 - wp_enqueue_script(
876 - 'elementor-floating-elements-modal',
877 - ELEMENTOR_ASSETS_URL . 'js/floating-elements-modal' . $suffix . '.js',
878 - [],
879 - ELEMENTOR_VERSION,
880 - true
881 - );
882 -
883 - wp_set_script_translations( 'elementor-floating-elements-modal', 'elementor' );
884 - }
885 -
886 576 /**
887 577 * @access public
888 578 */
889 579 public function enqueue_new_template_scripts() {
890 - $suffix = Utils::is_script_debug() ? '' : '.min';
580 + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
891 581
892 582 wp_enqueue_script(
893 583 'elementor-new-template',
894 584 ELEMENTOR_ASSETS_URL . 'js/new-template' . $suffix . '.js',
@@ -895,10 +585,8 @@
895 585 [],
896 586 ELEMENTOR_VERSION,
897 587 true
898 588 );
899 -
900 - wp_set_script_translations( 'elementor-new-template', 'elementor' );
901 589 }
902 590
903 591 /**
904 592 * @since 2.6.0
@@ -911,9 +599,9 @@
911 599 /**
912 600 * @access public
913 601 */
914 602 public function enqueue_beta_tester_scripts() {
915 - $suffix = Utils::is_script_debug() ? '' : '.min';
603 + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
916 604
917 605 wp_enqueue_script(
918 606 'elementor-beta-tester',
919 607 ELEMENTOR_ASSETS_URL . 'js/beta-tester' . $suffix . '.js',
@@ -920,26 +608,10 @@
920 608 [],
921 609 ELEMENTOR_VERSION,
922 610 true
923 611 );
924 -
925 - wp_set_script_translations( 'elementor-beta-tester', 'elementor' );
926 612 }
927 613
928 - public function init_floating_elements() {
929 - $screens = [
930 - 'elementor_library_page_e-floating-buttons' => true,
931 - 'edit-e-floating-buttons' => true,
932 - ];
933 -
934 - if ( ! isset( $screens[ get_current_screen()->id ] ) ) {
935 - return;
936 - }
937 -
938 - add_action( 'admin_head', [ $this, 'add_new_floating_elements_template' ] );
939 - add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_new_floating_elements_scripts' ] );
940 - }
941 -
942 614 /**
943 615 * @access public
944 616 */
945 617 public function init_new_template() {
@@ -959,28 +631,11 @@
959 631 if ( $current_version_minor_part === $new_version_minor_part ) {
960 632 return;
961 633 }
962 634 ?>
963 - <hr class="e-major-update-warning__separator" />
964 635 <div class="e-major-update-warning">
965 - <div class="e-major-update-warning__icon">
966 - <i class="eicon-info-circle"></i>
967 - </div>
968 - <div>
969 - <div class="e-major-update-warning__title">
970 - <?php echo esc_html__( 'Heads up, Please backup before upgrade!', 'elementor' ); ?>
971 - </div>
972 - <div class="e-major-update-warning__message">
973 - <?php
974 - printf(
975 - /* translators: %1$s Link open tag, %2$s: Link close tag. */
976 - 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' ),
977 - '<a href="https://go.elementor.com/wp-dash-update-backup/">',
978 - '</a>'
979 - );
980 - ?>
981 - </div>
982 - </div>
636 + <div class="e-major-update-warning__title"><?php echo __( 'Heads up, Please backup before upgrade!', 'elementor' ); ?></div>
637 + <div class="e-major-update-warning__message"><?php echo __( 'The latest update includes some substantial changes across different areas of the plugin. We highly recommend you backup your site before upgrading, and make sure you first update in a staging environment', 'elementor' ); ?></div>
983 638 </div>
984 639 <?php
985 640 }
986 641
@@ -1005,8 +660,9 @@
1005 660 public function __construct() {
1006 661 Plugin::$instance->init_common();
1007 662
1008 663 $this->add_component( 'feedback', new Feedback() );
664 + $this->add_component( 'canary-deployment', new Canary_Deployment() );
1009 665 $this->add_component( 'admin-notices', new Admin_Notices() );
1010 666
1011 667 add_action( 'admin_init', [ $this, 'maybe_redirect_to_getting_started' ] );
1012 668
@@ -1028,20 +684,15 @@
1028 684 add_action( 'wp_dashboard_setup', [ $this, 'register_dashboard_widgets' ] );
1029 685
1030 686 // Admin Actions
1031 687 add_action( 'admin_action_elementor_new_post', [ $this, 'admin_action_new_post' ] );
1032 - add_action( 'admin_action_elementor_site_settings_redirect', [ $this, 'admin_action_site_settings_redirect' ] );
1033 - add_action( 'admin_action_elementor_edit_website_redirect', [ $this, 'admin_action_edit_website_redirect' ] );
1034 688
1035 689 add_action( 'current_screen', [ $this, 'init_new_template' ] );
1036 - add_action( 'current_screen', [ $this, 'init_floating_elements' ] );
1037 690 add_action( 'current_screen', [ $this, 'init_beta_tester' ] );
1038 691
1039 692 add_action( 'in_plugin_update_message-' . ELEMENTOR_PLUGIN_BASE, function( $plugin_data ) {
1040 693 $this->version_update_warning( ELEMENTOR_VERSION, $plugin_data['new_version'] );
1041 694 } );
1042 -
1043 - add_action( 'elementor/ajax/register_actions', [ $this, 'register_ajax_hints' ] );
1044 695 }
1045 696
1046 697 /**
1047 698 * @since 2.3.0
@@ -1055,12 +706,21 @@
1055 706
1056 707 $settings = [
1057 708 'home_url' => home_url(),
1058 709 'settings_url' => Settings::get_url(),
710 + 'i18n' => [
711 + 'rollback_confirm' => __( 'Are you sure you want to reinstall previous version?', 'elementor' ),
712 + 'rollback_to_previous_version' => __( 'Rollback to Previous Version', 'elementor' ),
713 + 'yes' => __( 'Continue', 'elementor' ),
714 + 'cancel' => __( 'Cancel', 'elementor' ),
715 + 'new_template' => __( 'New Template', 'elementor' ),
716 + 'back_to_wordpress_editor_message' => __( 'Please note that you are switching to WordPress default editor. Your current layout, design and content might break.', 'elementor' ),
717 + 'back_to_wordpress_editor_header' => __( 'Back to WordPress Editor', 'elementor' ),
718 + 'beta_tester_sign_up' => __( 'Sign Up', 'elementor' ),
719 + 'do_not_show_again' => __( 'Don\'t Show Again', 'elementor' ),
720 + ],
1059 721 'user' => [
1060 722 'introduction' => User::get_introduction_meta(),
1061 - 'restrictions' => Plugin::$instance->role_manager->get_user_restrictions_array(),
1062 - 'is_administrator' => current_user_can( 'manage_options' ),
1063 723 ],
1064 724 'beta_tester' => [
1065 725 'beta_tester_signup' => Beta_Testers::BETA_TESTER_SIGNUP,
1066 726 'has_email' => $beta_tester_email,
@@ -1066,155 +726,9 @@
1066 726 'has_email' => $beta_tester_email,
1067 727 'option_enabled' => 'no' !== $elementor_beta,
1068 728 'signup_dismissed' => $beta_tester_signup_dismissed,
1069 729 ],
1070 - 'experiments' => $this->get_experiments(),
1071 730 ];
1072 731
1073 - /**
1074 - * Localize settings.
1075 - *
1076 - * Filters the initial localize settings in the admin.
1077 - *
1078 - * WordPress has it's own way to pass localized data from PHP (backend) to
1079 - * JS (frontend). Elementor uses this method to pass localize data in the
1080 - * admin. This hook can be used to add more localized settings in addition
1081 - * to the initial Elementor settings.
1082 - *
1083 - * @since 2.3.0
1084 - *
1085 - * @param array $settings Initial localize settings.
1086 - */
1087 - $settings = apply_filters( 'elementor/admin/localize_settings', $settings );
1088 -
1089 - return $settings;
1090 - }
1091 -
1092 - private function get_experiments() {
1093 - return ( new Collection( Plugin::$instance->experiments->get_features() ) )
1094 - ->map( function ( $experiment_data ) {
1095 - $dependencies = $experiment_data['dependencies'] ?? [];
1096 -
1097 - $dependencies = ( new Collection( $dependencies ) )
1098 - ->map( function ( $dependency ) {
1099 - return $dependency->get_name();
1100 - } )->all();
1101 -
1102 - return [
1103 - 'name' => $experiment_data['name'],
1104 - 'title' => $experiment_data['title'] ?? $experiment_data['name'],
1105 - 'state' => $experiment_data['state'],
1106 - 'default' => $experiment_data['default'],
1107 - 'dependencies' => $dependencies,
1108 - 'messages' => $experiment_data['messages'] ?? [],
1109 - ];
1110 - } )->all();
1111 - }
1112 -
1113 - private function maybe_enqueue_hints() {
1114 - $plugin_slug = 'image-optimization';
1115 -
1116 - if ( ! Hints::should_display_hint( $plugin_slug ) ) {
1117 - return;
1118 - }
1119 -
1120 - wp_register_script(
1121 - 'media-hints',
1122 - $this->get_js_assets_url( 'media-hints' ),
1123 - [],
1124 - ELEMENTOR_VERSION,
1125 - true
1126 - );
1127 -
1128 - $one_subscription = Hints::is_plugin_connected_to_one_subscription();
1129 - $is_installed = Hints::is_plugin_installed( $plugin_slug );
1130 - $is_active = Hints::is_plugin_active( $plugin_slug );
1131 -
1132 - if ( $is_active ) {
1133 - return;
1134 - }
1135 -
1136 - if ( $one_subscription ) {
1137 - if ( ! $is_installed ) {
1138 - $description = esc_html__( 'Automatically optimize images to improve site speed and performance. Included with your ONE subscription.', 'elementor' );
1139 - $button_text = esc_html__( 'Install now', 'elementor' );
1140 - $button_url = Hints::get_plugin_install_url( $plugin_slug );
1141 - } elseif ( ! $is_active ) {
1142 - $description = esc_html__( 'Image Optimization is installed and included in your ONE subscription. Activate it to optimize images and improve site performance.', 'elementor' );
1143 - $button_text = esc_html__( 'Activate now', 'elementor' );
1144 - $button_url = Hints::get_plugin_activate_url( $plugin_slug );
1145 - }
1146 - } else {
1147 - $description = esc_html__( 'Optimize your images to enhance site performance by using Image Optimization.', 'elementor' );
1148 - if ( ! $is_installed ) {
1149 - $button_text = esc_html__( 'Install now', 'elementor' );
1150 - $button_url = Hints::get_plugin_install_url( $plugin_slug );
1151 - } elseif ( ! $is_active ) {
1152 - $button_text = esc_html__( 'Activate now', 'elementor' );
1153 - $button_url = Hints::get_plugin_activate_url( $plugin_slug );
1154 - }
1155 - }
1156 -
1157 - $dismissible = 'image_optimizer_hint';
1158 -
1159 - $title = esc_html__( 'Speed up your website with Image Optimization', 'elementor' );
1160 - $content = sprintf(
1161 - "<strong>%1\$s</strong><br>%2\$s <a class='e-btn-1' href='%3\$s' target='_blank'>%4\$s</a>!",
1162 - $title,
1163 - $description,
1164 - $button_url,
1165 - $button_text
1166 - );
1167 -
1168 - wp_localize_script( 'media-hints', 'elementorAdminHints', [
1169 - 'mediaHint' => [
1170 - 'display' => true,
1171 - 'type' => 'info',
1172 - 'content' => $content,
1173 - 'icon' => true,
1174 - 'dismissible' => $dismissible,
1175 - 'dismiss' => esc_attr__( 'Dismiss this notice.', 'elementor' ),
1176 - 'button_event' => $dismissible,
1177 - 'button_data' => base64_encode(
1178 - wp_json_encode( [
1179 - 'action_url' => $button_url,
1180 - ] ),
1181 - ),
1182 - ],
1183 - ] );
1184 -
1185 - wp_enqueue_script( 'media-hints' );
1186 - }
1187 -
1188 - public function register_ajax_hints( $ajax_manager ) {
1189 - $ajax_manager->register_ajax_action( 'elementor_image_optimization_campaign', [ $this, 'ajax_set_image_optimization_campaign' ] );
1190 - $ajax_manager->register_ajax_action( 'elementor_core_ally_campaign', [ $this, 'ajax_ally_campaign' ] );
1191 - }
1192 -
1193 - public function ajax_ally_campaign( $request ) {
1194 - if ( ! current_user_can( 'install_plugins' ) ) {
1195 - return;
1196 - }
1197 -
1198 - $campaign_data = [
1199 - 'campaign' => sanitize_key( $request['campaign'] ?? '' ),
1200 - 'source' => sanitize_key( $request['source'] ?? '' ),
1201 - 'medium' => sanitize_key( $request['medium'] ?? '' ),
1202 - ];
1203 -
1204 - set_transient( 'elementor_ea11y_campaign', $campaign_data, 30 * DAY_IN_SECONDS );
1205 - }
1206 -
1207 - public function ajax_set_image_optimization_campaign( $request ) {
1208 - if ( ! current_user_can( 'install_plugins' ) ) {
1209 - return;
1210 - }
1211 -
1212 - $campaign_data = [
1213 - 'campaign' => sanitize_key( $request['campaign'] ?? '' ),
1214 - 'source' => sanitize_key( $request['source'] ?? '' ),
1215 - 'medium' => sanitize_key( $request['medium'] ?? '' ),
1216 - ];
1217 -
1218 - set_transient( 'elementor_image_optimization_campaign', $campaign_data, 30 * DAY_IN_SECONDS );
732 + return apply_filters( 'elementor/admin/localize_settings', $settings );
1219 733 }
1220 734 }