| @@ -2,20 +2,19 @@ | ||
| 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 | 10 | use Elementor\Core\Utils\Assets_Config_Provider; |
| 10 | 11 | use Elementor\Core\Utils\Collection; |
| 11 | -use Elementor\Modules\FloatingButtons\Module as Floating_Buttons_Module; | |
| 12 | 12 | use Elementor\Plugin; |
| 13 | 13 | use Elementor\Settings; |
| 14 | 14 | use Elementor\User; |
| 15 | 15 | use Elementor\Utils; |
| 16 | 16 | use Elementor\Core\Utils\Hints; |
| 17 | -use Elementor\Core\DocumentTypes\Page; | |
| 18 | 17 | |
| 19 | 18 | if ( ! defined( 'ABSPATH' ) ) { |
| 20 | 19 | exit; // Exit if accessed directly. |
| 21 | 20 | } |
| @@ -38,36 +37,8 @@ | ||
| 38 | 37 | return 'admin'; |
| 39 | 38 | } |
| 40 | 39 | |
| 41 | 40 | /** |
| 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 | 41 | * @since 2.2.0 |
| 71 | 42 | * @access public |
| 72 | 43 | */ |
| 73 | 44 | public function maybe_redirect_to_getting_started() { |
| @@ -195,11 +166,13 @@ | ||
| 195 | 166 | * @since 1.0.0 |
| 196 | 167 | * @access public |
| 197 | 168 | */ |
| 198 | 169 | public function enqueue_styles() { |
| 170 | + $direction_suffix = is_rtl() ? '-rtl' : ''; | |
| 171 | + | |
| 199 | 172 | wp_register_style( |
| 200 | 173 | 'elementor-admin', |
| 201 | - $this->get_css_assets_url( 'admin' ), | |
| 174 | + $this->get_css_assets_url( 'admin' . $direction_suffix ), | |
| 202 | 175 | [ |
| 203 | 176 | 'elementor-common', |
| 204 | 177 | ], |
| 205 | 178 | ELEMENTOR_VERSION |
| @@ -371,15 +344,10 @@ | ||
| 371 | 344 | $settings_link = sprintf( '<a href="%1$s">%2$s</a>', admin_url( 'admin.php?page=' . Settings::PAGE_ID ), esc_html__( 'Settings', 'elementor' ) ); |
| 372 | 345 | |
| 373 | 346 | array_unshift( $links, $settings_link ); |
| 374 | 347 | |
| 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 | - } | |
| 348 | + $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 | 349 | |
| 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 | 350 | return $links; |
| 383 | 351 | } |
| 384 | 352 | |
| 385 | 353 | /** |
| @@ -401,10 +369,10 @@ | ||
| 401 | 369 | */ |
| 402 | 370 | public function plugin_row_meta( $plugin_meta, $plugin_file ) { |
| 403 | 371 | if ( ELEMENTOR_PLUGIN_BASE === $plugin_file ) { |
| 404 | 372 | $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>', | |
| 373 | + '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>', | |
| 374 | + '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 | 375 | ]; |
| 408 | 376 | |
| 409 | 377 | $plugin_meta = array_merge( $plugin_meta, $row_meta ); |
| 410 | 378 | } |
| @@ -508,9 +476,9 @@ | ||
| 508 | 476 | ?> |
| 509 | 477 | <div class="e-overview__header"> |
| 510 | 478 | <?php if ( $show_versions ) { ?> |
| 511 | 479 | <div class="e-overview__logo"> |
| 512 | - <div class="e-logo-wrapper"><i class="eicon-elementor-circle"></i></div> | |
| 480 | + <div class="e-logo-wrapper"><i class="eicon-elementor"></i></div> | |
| 513 | 481 | </div> |
| 514 | 482 | <div class="e-overview__versions"> |
| 515 | 483 | <span class="e-overview__version"><?php echo esc_html__( 'Elementor', 'elementor' ); ?> v<?php echo ELEMENTOR_VERSION; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></span> |
| 516 | 484 | <?php |
| @@ -537,9 +505,9 @@ | ||
| 537 | 505 | * Displays the Elementor dashboard widget - recently edited section. |
| 538 | 506 | * Fired by `elementor_dashboard_overview_widget` function. |
| 539 | 507 | * |
| 540 | 508 | * @param array $args |
| 541 | - * @param bool $show_heading | |
| 509 | + * @param bool $show_heading | |
| 542 | 510 | * |
| 543 | 511 | * @return void |
| 544 | 512 | * @since 3.12.0 |
| 545 | 513 | */ |
| @@ -573,9 +541,9 @@ | ||
| 573 | 541 | /** |
| 574 | 542 | * Displays the Elementor dashboard widget - news and updates section. |
| 575 | 543 | * Fired by `elementor_dashboard_overview_widget` function. |
| 576 | 544 | * |
| 577 | - * @param int $limit_feed | |
| 545 | + * @param int $limit_feed | |
| 578 | 546 | * @param bool $show_heading |
| 579 | 547 | * |
| 580 | 548 | * @return void |
| 581 | 549 | * @since 3.12.0 |
| @@ -651,12 +619,21 @@ | ||
| 651 | 619 | ], |
| 652 | 620 | ]; |
| 653 | 621 | |
| 654 | 622 | $additions_actions = []; |
| 655 | - $additions_actions['ai'] = [ | |
| 656 | - 'title' => esc_html__( 'Build Smart with AI', 'elementor' ), | |
| 657 | - 'link' => 'https://go.elementor.com/overview-widget-ai/', | |
| 658 | - ]; | |
| 623 | + | |
| 624 | + if ( User::get_introduction_meta( 'ai_get_started' ) ) { | |
| 625 | + $additions_actions['ai-library'] = [ | |
| 626 | + 'title' => esc_html__( 'AI Prompts Library', 'elementor' ), | |
| 627 | + 'link' => 'https://go.elementor.com/overview-ai-prompts-library/', | |
| 628 | + ]; | |
| 629 | + } else { | |
| 630 | + $additions_actions['ai'] = [ | |
| 631 | + 'title' => esc_html__( 'Build Smart with AI', 'elementor' ), | |
| 632 | + 'link' => 'https://go.elementor.com/overview-widget-ai/', | |
| 633 | + ]; | |
| 634 | + } | |
| 635 | + | |
| 659 | 636 | $additions_actions['go-pro'] = [ |
| 660 | 637 | 'title' => esc_html__( 'Upgrade', 'elementor' ), |
| 661 | 638 | 'link' => 'https://go.elementor.com/go-pro-wp-overview-widget/', |
| 662 | 639 | ]; |
| @@ -718,10 +695,8 @@ | ||
| 718 | 695 | } |
| 719 | 696 | |
| 720 | 697 | $post_data = Utils::get_super_global_value( $_GET, 'post_data' ) ?? []; |
| 721 | 698 | |
| 722 | - $post_data = $this->filter_post_data( $post_data ); | |
| 723 | - | |
| 724 | 699 | /** |
| 725 | 700 | * Create new post meta data. |
| 726 | 701 | * |
| 727 | 702 | * Filters the meta data of any new post created. |
| @@ -745,115 +720,14 @@ | ||
| 745 | 720 | if ( is_wp_error( $document ) ) { |
| 746 | 721 | wp_die( $document ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 747 | 722 | } |
| 748 | 723 | |
| 749 | - wp_safe_redirect( $document->get_edit_url() ); | |
| 724 | + wp_redirect( $document->get_edit_url() ); | |
| 750 | 725 | |
| 751 | 726 | die; |
| 752 | 727 | } |
| 753 | 728 | |
| 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 | 729 | /** |
| 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 | 730 | * @since 2.3.0 |
| 857 | 731 | * @access public |
| 858 | 732 | */ |
| 859 | 733 | public function add_new_template_template() { |
| @@ -859,31 +733,13 @@ | ||
| 859 | 733 | public function add_new_template_template() { |
| 860 | 734 | Plugin::$instance->common->add_template( ELEMENTOR_PATH . 'includes/admin-templates/new-template.php' ); |
| 861 | 735 | } |
| 862 | 736 | |
| 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 | 737 | /** |
| 882 | 738 | * @access public |
| 883 | 739 | */ |
| 884 | 740 | public function enqueue_new_template_scripts() { |
| 885 | - $suffix = Utils::is_script_debug() ? '' : '.min'; | |
| 741 | + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; | |
| 886 | 742 | |
| 887 | 743 | wp_enqueue_script( |
| 888 | 744 | 'elementor-new-template', |
| 889 | 745 | ELEMENTOR_ASSETS_URL . 'js/new-template' . $suffix . '.js', |
| @@ -906,9 +762,9 @@ | ||
| 906 | 762 | /** |
| 907 | 763 | * @access public |
| 908 | 764 | */ |
| 909 | 765 | public function enqueue_beta_tester_scripts() { |
| 910 | - $suffix = Utils::is_script_debug() ? '' : '.min'; | |
| 766 | + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; | |
| 911 | 767 | |
| 912 | 768 | wp_enqueue_script( |
| 913 | 769 | 'elementor-beta-tester', |
| 914 | 770 | ELEMENTOR_ASSETS_URL . 'js/beta-tester' . $suffix . '.js', |
| @@ -919,22 +775,8 @@ | ||
| 919 | 775 | |
| 920 | 776 | wp_set_script_translations( 'elementor-beta-tester', 'elementor' ); |
| 921 | 777 | } |
| 922 | 778 | |
| 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 | 779 | /** |
| 938 | 780 | * @access public |
| 939 | 781 | */ |
| 940 | 782 | public function init_new_template() { |
| @@ -1002,8 +844,12 @@ | ||
| 1002 | 844 | |
| 1003 | 845 | $this->add_component( 'feedback', new Feedback() ); |
| 1004 | 846 | $this->add_component( 'admin-notices', new Admin_Notices() ); |
| 1005 | 847 | |
| 848 | + if ( Plugin::$instance->experiments->is_feature_active( 'admin_menu_rearrangement' ) ) { | |
| 849 | + $this->register_menu(); | |
| 850 | + } | |
| 851 | + | |
| 1006 | 852 | add_action( 'admin_init', [ $this, 'maybe_redirect_to_getting_started' ] ); |
| 1007 | 853 | |
| 1008 | 854 | add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] ); |
| 1009 | 855 | add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_styles' ] ); |
| @@ -1023,20 +869,15 @@ | ||
| 1023 | 869 | add_action( 'wp_dashboard_setup', [ $this, 'register_dashboard_widgets' ] ); |
| 1024 | 870 | |
| 1025 | 871 | // Admin Actions |
| 1026 | 872 | 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 | 873 | |
| 1030 | 874 | add_action( 'current_screen', [ $this, 'init_new_template' ] ); |
| 1031 | - add_action( 'current_screen', [ $this, 'init_floating_elements' ] ); | |
| 1032 | 875 | add_action( 'current_screen', [ $this, 'init_beta_tester' ] ); |
| 1033 | 876 | |
| 1034 | 877 | add_action( 'in_plugin_update_message-' . ELEMENTOR_PLUGIN_BASE, function( $plugin_data ) { |
| 1035 | 878 | $this->version_update_warning( ELEMENTOR_VERSION, $plugin_data['new_version'] ); |
| 1036 | 879 | } ); |
| 1037 | - | |
| 1038 | - add_action( 'elementor/ajax/register_actions', [ $this, 'register_ajax_hints' ] ); | |
| 1039 | 880 | } |
| 1040 | 881 | |
| 1041 | 882 | /** |
| 1042 | 883 | * @since 2.3.0 |
| @@ -1104,12 +945,14 @@ | ||
| 1104 | 945 | ]; |
| 1105 | 946 | } )->all(); |
| 1106 | 947 | } |
| 1107 | 948 | |
| 949 | + private function register_menu() { | |
| 950 | + $this->menus['main'] = new MainMenu(); | |
| 951 | + } | |
| 952 | + | |
| 1108 | 953 | private function maybe_enqueue_hints() { |
| 1109 | - $plugin_slug = 'image-optimization'; | |
| 1110 | - | |
| 1111 | - if ( ! Hints::should_display_hint( $plugin_slug ) ) { | |
| 954 | + if ( ! Hints::should_display_hint( 'image-optimization-once-media-modal' ) && ! Hints::should_display_hint( 'image-optimization-media-modal' ) ) { | |
| 1112 | 955 | return; |
| 1113 | 956 | } |
| 1114 | 957 | |
| 1115 | 958 | wp_register_script( |
| @@ -1119,60 +962,36 @@ | ||
| 1119 | 962 | ELEMENTOR_VERSION, |
| 1120 | 963 | true |
| 1121 | 964 | ); |
| 1122 | 965 | |
| 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 ); | |
| 966 | + $once_dismissed = Hints::is_dismissed( 'image-optimization-once-media-modal' ); | |
| 967 | + $content = $once_dismissed ? | |
| 968 | + sprintf("%1\$s <a href='%2\$s' class='e-btn-1' target='_blank'>%3\$s</a> %4\$s", | |
| 969 | + __( 'This image is large and may slow things down.', 'elementor' ), | |
| 970 | + Hints::get_plugin_action_url( 'image-optimization' ), | |
| 971 | + ( Hints::is_plugin_installed( 'image-optimization' ) ? __( 'Activate', 'elementor' ) : __( 'Install', 'elementor' ) ) . ' ' . __( 'Image Optimizer', 'elementor' ), | |
| 972 | + __( 'to reduce size without losing quality.', 'elementor' ) | |
| 973 | + ) : | |
| 974 | + sprintf("%1\$s <a class='e-btn-1' href='%2\$s' target='_blank'>%3\$s</a>!", | |
| 975 | + __( 'Don’t let unoptimized images be the downfall of your site’s performance.', 'elementor' ), | |
| 976 | + Hints::get_plugin_action_url( 'image-optimization' ), | |
| 977 | + ( Hints::is_plugin_installed( 'image-optimization' ) ? __( 'Activate', 'elementor' ) : __( 'Install', 'elementor' ) ) . ' ' . __( 'Image Optimizer', 'elementor' ) | |
| 978 | + ); | |
| 1126 | 979 | |
| 1127 | - if ( $is_active ) { | |
| 1128 | - return; | |
| 1129 | - } | |
| 980 | + $dismissible = $once_dismissed ? 'image-optimization-media-modal' : 'image-optimization-once-media-modal'; | |
| 1130 | 981 | |
| 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 | 982 | wp_localize_script( 'media-hints', 'elementorAdminHints', [ |
| 1164 | 983 | 'mediaHint' => [ |
| 1165 | - 'display' => true, | |
| 1166 | - 'type' => 'info', | |
| 984 | + 'display' => ! $once_dismissed, | |
| 985 | + 'type' => $once_dismissed ? 'warning' : 'info', | |
| 1167 | 986 | 'content' => $content, |
| 1168 | 987 | 'icon' => true, |
| 1169 | 988 | 'dismissible' => $dismissible, |
| 1170 | - 'dismiss' => esc_attr__( 'Dismiss this notice.', 'elementor' ), | |
| 989 | + 'dismiss' => __( 'Dismiss this notice.', 'elementor' ), | |
| 1171 | 990 | 'button_event' => $dismissible, |
| 1172 | 991 | 'button_data' => base64_encode( |
| 1173 | - wp_json_encode( [ | |
| 1174 | - 'action_url' => $button_url, | |
| 992 | + json_encode( [ | |
| 993 | + 'action_url' => Hints::get_plugin_action_url( 'image-optimization' ), | |
| 1175 | 994 | ] ), |
| 1176 | 995 | ), |
| 1177 | 996 | ], |
| 1178 | 997 | ] ); |
| @@ -1177,54 +996,6 @@ | ||
| 1177 | 996 | ], |
| 1178 | 997 | ] ); |
| 1179 | 998 | |
| 1180 | 999 | 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 ); | |
| 1229 | 1000 | } |
| 1230 | 1001 | } |