PluginProbe
Elementor Website Builder – more than just a page builder / 3.13.2
Elementor Website Builder – more than just a page builder v3.13.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 +65 -338 4.3.03.13.2 View file →
@@ -2,20 +2,17 @@
2 2 namespace Elementor\Core\Admin;
3 3
4 4 use Elementor\Api;
5 5 use Elementor\Beta_Testers;
6 +use Elementor\Core\Admin\Menu\Main as MainMenu;
6 7 use Elementor\App\Modules\Onboarding\Module as Onboarding_Module;
7 8 use Elementor\Core\Base\App;
8 9 use Elementor\Core\Upgrade\Manager as Upgrade_Manager;
9 -use Elementor\Core\Utils\Assets_Config_Provider;
10 10 use Elementor\Core\Utils\Collection;
11 -use Elementor\Modules\FloatingButtons\Module as Floating_Buttons_Module;
12 11 use Elementor\Plugin;
13 12 use Elementor\Settings;
14 13 use Elementor\User;
15 14 use Elementor\Utils;
16 -use Elementor\Core\Utils\Hints;
17 -use Elementor\Core\DocumentTypes\Page;
18 15
19 16 if ( ! defined( 'ABSPATH' ) ) {
20 17 exit; // Exit if accessed directly.
21 18 }
@@ -38,36 +35,8 @@
38 35 return 'admin';
39 36 }
40 37
41 38 /**
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 39 * @since 2.2.0
71 40 * @access public
72 41 */
73 42 public function maybe_redirect_to_getting_started() {
@@ -105,27 +74,40 @@
105 74
106 75 exit;
107 76 }
108 77
78 + private function get_package_config( $package_name ) {
79 + $asset_file = ELEMENTOR_ASSETS_PATH . "js/packages/$package_name.asset.php";
80 +
81 + if ( ! file_exists( $asset_file ) ) {
82 + return [];
83 + }
84 +
85 + $data = require $asset_file;
86 +
87 + return [
88 + 'handle' => $data['handle'],
89 + 'src' => $data['src'],
90 + 'deps' => $data['deps'],
91 + ];
92 + }
93 +
109 94 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 ) {
95 + Collection::make( [ 'ui', 'icons' ] )
96 + ->map( function( $package_name ) {
97 + return $this->get_package_config( $package_name );
98 + } )
99 + ->filter( function( $package_config ) {
100 + return ! empty( $package_config );
101 + } )
102 + ->each( function( $package_config ) {
117 103 $suffix = Utils::is_script_debug() ? '' : '.min';
118 - $config = $assets_config_provider->load( $package )->get( $package );
104 + $src = str_replace( '{{MIN_SUFFIX}}', $suffix, $package_config['src'] );
119 105
120 - if ( ! $config ) {
121 - return;
122 - }
123 -
124 106 wp_register_script(
125 - $config['handle'],
126 - ELEMENTOR_ASSETS_URL . "js/packages/{$package}/{$package}{$suffix}.js",
127 - $config['deps'],
107 + $package_config['handle'],
108 + $src,
109 + $package_config['deps'],
128 110 ELEMENTOR_VERSION,
129 111 true
130 112 );
131 113 } );
@@ -157,10 +139,10 @@
157 139 'elementor-ai-admin',
158 140 $this->get_js_assets_url( 'ai-admin' ),
159 141 [
160 142 'elementor-common',
161 - 'elementor-v2-ui',
162 - 'elementor-v2-icons',
143 + 'elementor-packages-ui',
144 + 'elementor-packages-icons',
163 145 ],
164 146 ELEMENTOR_VERSION,
165 147 true
166 148 );
@@ -177,12 +159,8 @@
177 159 );
178 160
179 161 wp_enqueue_script( 'elementor-admin' );
180 162
181 - wp_set_script_translations( 'elementor-admin', 'elementor' );
182 -
183 - $this->maybe_enqueue_hints();
184 -
185 163 $this->print_config();
186 164 }
187 165
188 166 /**
@@ -195,11 +173,13 @@
195 173 * @since 1.0.0
196 174 * @access public
197 175 */
198 176 public function enqueue_styles() {
177 + $direction_suffix = is_rtl() ? '-rtl' : '';
178 +
199 179 wp_register_style(
200 180 'elementor-admin',
201 - $this->get_css_assets_url( 'admin' ),
181 + $this->get_css_assets_url( 'admin' . $direction_suffix ),
202 182 [
203 183 'elementor-common',
204 184 ],
205 185 ELEMENTOR_VERSION
@@ -242,10 +222,10 @@
242 222 <div id="elementor-switch-mode">
243 223 <input id="elementor-switch-mode-input" type="hidden" name="_elementor_post_mode" value="<?php echo esc_attr( $document->is_built_with_elementor() ); ?>" />
244 224 <button id="elementor-switch-mode-button" type="button" class="button button-primary button-hero">
245 225 <span class="elementor-switch-mode-on">
246 - <i class="eicon-wordpress" aria-hidden="true"></i>
247 - <?php echo esc_html__( 'Edit with WordPress', 'elementor' ); ?>
226 + <i class="eicon-arrow-<?php echo ( is_rtl() ) ? 'right' : 'left'; ?>" aria-hidden="true"></i>
227 + <?php echo esc_html__( 'Back to WordPress Editor', 'elementor' ); ?>
248 228 </span>
249 229 <span class="elementor-switch-mode-off">
250 230 <i class="eicon-elementor-square" aria-hidden="true"></i>
251 231 <?php echo esc_html__( 'Edit with Elementor', 'elementor' ); ?>
@@ -371,15 +351,10 @@
371 351 $settings_link = sprintf( '<a href="%1$s">%2$s</a>', admin_url( 'admin.php?page=' . Settings::PAGE_ID ), esc_html__( 'Settings', 'elementor' ) );
372 352
373 353 array_unshift( $links, $settings_link );
374 354
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 - }
355 + $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/', esc_html__( 'Get Elementor Pro', 'elementor' ) );
379 356
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 357 return $links;
383 358 }
384 359
385 360 /**
@@ -401,10 +376,10 @@
401 376 */
402 377 public function plugin_row_meta( $plugin_meta, $plugin_file ) {
403 378 if ( ELEMENTOR_PLUGIN_BASE === $plugin_file ) {
404 379 $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>',
380 + 'docs' => '<a href="https://go.elementor.com/docs-admin-plugins/" aria-label="' . esc_attr( esc_html__( 'View Elementor Documentation', 'elementor' ) ) . '" target="_blank">' . esc_html__( 'Docs & FAQs', 'elementor' ) . '</a>',
381 + 'ideo' => '<a href="https://go.elementor.com/yt-admin-plugins/" aria-label="' . esc_attr( esc_html__( 'View Elementor Video Tutorials', 'elementor' ) ) . '" target="_blank">' . esc_html__( 'Video Tutorials', 'elementor' ) . '</a>',
407 382 ];
408 383
409 384 $plugin_meta = array_merge( $plugin_meta, $row_meta );
410 385 }
@@ -427,18 +402,13 @@
427 402 * @return string The content that will be printed.
428 403 */
429 404 public function admin_footer_text( $footer_text ) {
430 405 $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 406 $is_elementor_screen = ( $current_screen && false !== strpos( $current_screen->id, 'elementor' ) );
437 407
438 408 if ( $is_elementor_screen ) {
439 409 $footer_text = sprintf(
440 - /* translators: 1: Elementor, 2: Link to plugin review */
410 + /* translators: 1: Elementor, 2: Link to plugin review */
441 411 __( 'Enjoyed %1$s? Please leave us a %2$s rating. We really appreciate your support!', 'elementor' ),
442 412 '<strong>' . esc_html__( 'Elementor', 'elementor' ) . '</strong>',
443 413 '<a href="https://go.elementor.com/admin-review/" target="_blank">&#9733;&#9733;&#9733;&#9733;&#9733;</a>'
444 414 );
@@ -513,9 +483,9 @@
513 483 ?>
514 484 <div class="e-overview__header">
515 485 <?php if ( $show_versions ) { ?>
516 486 <div class="e-overview__logo">
517 - <div class="e-logo-wrapper"><i class="eicon-elementor-circle"></i></div>
487 + <div class="e-logo-wrapper"><i class="eicon-elementor"></i></div>
518 488 </div>
519 489 <div class="e-overview__versions">
520 490 <span class="e-overview__version"><?php echo esc_html__( 'Elementor', 'elementor' ); ?> v<?php echo ELEMENTOR_VERSION; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></span>
521 491 <?php
@@ -542,9 +512,9 @@
542 512 * Displays the Elementor dashboard widget - recently edited section.
543 513 * Fired by `elementor_dashboard_overview_widget` function.
544 514 *
545 515 * @param array $args
546 - * @param bool $show_heading
516 + * @param bool $show_heading
547 517 *
548 518 * @return void
549 519 * @since 3.12.0
550 520 */
@@ -564,9 +534,9 @@
564 534
565 535 $date = date_i18n( _x( 'M jS', 'Dashboard Overview Widget Recently Date', 'elementor' ), get_the_modified_time( 'U' ) );
566 536 ?>
567 537 <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() ); ?>
538 + <a href="<?php echo esc_attr( $document->get_edit_url() ); ?>" class="e-overview__post-link"><?php echo esc_html( get_the_title() ); ?>
569 539 <span class="dashicons dashicons-edit"></span></a>
570 540 <span><?php echo $date; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>, <?php the_modified_time(); ?></span>
571 541 </li>
572 542 <?php } ?>
@@ -578,9 +548,9 @@
578 548 /**
579 549 * Displays the Elementor dashboard widget - news and updates section.
580 550 * Fired by `elementor_dashboard_overview_widget` function.
581 551 *
582 - * @param int $limit_feed
552 + * @param int $limit_feed
583 553 * @param bool $show_heading
584 554 *
585 555 * @return void
586 556 * @since 3.12.0
@@ -625,9 +595,9 @@
625 595 <div class="e-overview__footer e-divider_top">
626 596 <ul>
627 597 <?php foreach ( self::static_get_dashboard_overview_widget_footer_actions() as $action_id => $action ) { ?>
628 598 <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'] ); ?>
599 + <a href="<?php echo esc_attr( $action['link'] ); ?>" target="_blank"><?php echo esc_html( $action['title'] ); ?>
630 600 <span class="screen-reader-text"><?php echo esc_html__( '(opens in a new window)', 'elementor' ); ?></span>
631 601 <span aria-hidden="true" class="dashicons dashicons-external"></span></a>
632 602 </li>
633 603 <?php } ?>
@@ -655,16 +625,19 @@
655 625 'link' => 'https://go.elementor.com/overview-widget-docs/',
656 626 ],
657 627 ];
658 628
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/',
629 + $additions_actions = [
630 + 'go-pro' => [
631 + 'title' => esc_html__( 'Upgrade', 'elementor' ),
632 + 'link' => 'https://go.elementor.com/go-pro-wp-overview-widget/',
633 + ],
663 634 ];
664 - $additions_actions['go-pro'] = [
665 - 'title' => esc_html__( 'Upgrade', 'elementor' ),
666 - 'link' => 'https://go.elementor.com/go-pro-wp-overview-widget/',
635 +
636 + // Visible to all core users when Elementor Pro is not installed.
637 + $additions_actions['find_an_expert'] = [
638 + 'title' => esc_html__( 'Find an Expert', 'elementor' ),
639 + 'link' => 'https://go.elementor.com/go-pro-find-an-expert/',
667 640 ];
668 641
669 642 /**
670 643 * Dashboard widget footer actions.
@@ -723,10 +696,8 @@
723 696 }
724 697
725 698 $post_data = Utils::get_super_global_value( $_GET, 'post_data' ) ?? [];
726 699
727 - $post_data = $this->filter_post_data( $post_data );
728 -
729 700 /**
730 701 * Create new post meta data.
731 702 *
732 703 * Filters the meta data of any new post created.
@@ -750,115 +721,14 @@
750 721 if ( is_wp_error( $document ) ) {
751 722 wp_die( $document ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
752 723 }
753 724
754 - wp_safe_redirect( $document->get_edit_url() );
725 + wp_redirect( $document->get_edit_url() );
755 726
756 727 die;
757 728 }
758 729
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 730 /**
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 731 * @since 2.3.0
862 732 * @access public
863 733 */
864 734 public function add_new_template_template() {
@@ -864,31 +734,13 @@
864 734 public function add_new_template_template() {
865 735 Plugin::$instance->common->add_template( ELEMENTOR_PATH . 'includes/admin-templates/new-template.php' );
866 736 }
867 737
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 738 /**
887 739 * @access public
888 740 */
889 741 public function enqueue_new_template_scripts() {
890 - $suffix = Utils::is_script_debug() ? '' : '.min';
742 + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
891 743
892 744 wp_enqueue_script(
893 745 'elementor-new-template',
894 746 ELEMENTOR_ASSETS_URL . 'js/new-template' . $suffix . '.js',
@@ -895,10 +747,8 @@
895 747 [],
896 748 ELEMENTOR_VERSION,
897 749 true
898 750 );
899 -
900 - wp_set_script_translations( 'elementor-new-template', 'elementor' );
901 751 }
902 752
903 753 /**
904 754 * @since 2.6.0
@@ -911,9 +761,9 @@
911 761 /**
912 762 * @access public
913 763 */
914 764 public function enqueue_beta_tester_scripts() {
915 - $suffix = Utils::is_script_debug() ? '' : '.min';
765 + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
916 766
917 767 wp_enqueue_script(
918 768 'elementor-beta-tester',
919 769 ELEMENTOR_ASSETS_URL . 'js/beta-tester' . $suffix . '.js',
@@ -920,26 +770,10 @@
920 770 [],
921 771 ELEMENTOR_VERSION,
922 772 true
923 773 );
924 -
925 - wp_set_script_translations( 'elementor-beta-tester', 'elementor' );
926 774 }
927 775
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 776 /**
943 777 * @access public
944 778 */
945 779 public function init_new_template() {
@@ -971,9 +805,9 @@
971 805 </div>
972 806 <div class="e-major-update-warning__message">
973 807 <?php
974 808 printf(
975 - /* translators: %1$s Link open tag, %2$s: Link close tag. */
809 + /* translators: %1$s Link open tag, %2$s: Link close tag. */
976 810 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 811 '<a href="https://go.elementor.com/wp-dash-update-backup/">',
978 812 '</a>'
979 813 );
@@ -1007,8 +841,12 @@
1007 841
1008 842 $this->add_component( 'feedback', new Feedback() );
1009 843 $this->add_component( 'admin-notices', new Admin_Notices() );
1010 844
845 + if ( Plugin::$instance->experiments->is_feature_active( 'admin_menu_rearrangement' ) ) {
846 + $this->register_menu();
847 + }
848 +
1011 849 add_action( 'admin_init', [ $this, 'maybe_redirect_to_getting_started' ] );
1012 850
1013 851 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
1014 852 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_styles' ] );
@@ -1028,20 +866,15 @@
1028 866 add_action( 'wp_dashboard_setup', [ $this, 'register_dashboard_widgets' ] );
1029 867
1030 868 // Admin Actions
1031 869 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 870
1035 871 add_action( 'current_screen', [ $this, 'init_new_template' ] );
1036 - add_action( 'current_screen', [ $this, 'init_floating_elements' ] );
1037 872 add_action( 'current_screen', [ $this, 'init_beta_tester' ] );
1038 873
1039 874 add_action( 'in_plugin_update_message-' . ELEMENTOR_PLUGIN_BASE, function( $plugin_data ) {
1040 875 $this->version_update_warning( ELEMENTOR_VERSION, $plugin_data['new_version'] );
1041 876 } );
1042 -
1043 - add_action( 'elementor/ajax/register_actions', [ $this, 'register_ajax_hints' ] );
1044 877 }
1045 878
1046 879 /**
1047 880 * @since 2.3.0
@@ -1057,10 +890,8 @@
1057 890 'home_url' => home_url(),
1058 891 'settings_url' => Settings::get_url(),
1059 892 'user' => [
1060 893 'introduction' => User::get_introduction_meta(),
1061 - 'restrictions' => Plugin::$instance->role_manager->get_user_restrictions_array(),
1062 - 'is_administrator' => current_user_can( 'manage_options' ),
1063 894 ],
1064 895 'beta_tester' => [
1065 896 'beta_tester_signup' => Beta_Testers::BETA_TESTER_SIGNUP,
1066 897 'has_email' => $beta_tester_email,
@@ -1109,112 +940,8 @@
1109 940 ];
1110 941 } )->all();
1111 942 }
1112 943
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 );
944 + private function register_menu() {
945 + $this->menus['main'] = new MainMenu();
1219 946 }
1220 947 }