| @@ -2,14 +2,13 @@ | ||
| 2 | 2 | namespace Elementor\Core\Editor; |
| 3 | 3 | |
| 4 | 4 | use Elementor\Core\Base\Base_Object; |
| 5 | 5 | use Elementor\Core\Common\Modules\Ajax\Module as Ajax; |
| 6 | -use Elementor\Core\Utils\Promotions\Filtered_Promotions_Manager; | |
| 7 | 6 | use Elementor\Plugin; |
| 8 | 7 | use Elementor\Utils; |
| 9 | 8 | |
| 10 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 11 | - exit; // Exit if accessed directly. | |
| 10 | + exit; // Exit if accessed directly | |
| 12 | 11 | } |
| 13 | 12 | |
| 14 | 13 | class Notice_Bar extends Base_Object { |
| 15 | 14 | |
| @@ -17,37 +16,19 @@ | ||
| 17 | 16 | if ( Plugin::$instance->get_install_time() > strtotime( '-1 days' ) ) { |
| 18 | 17 | return []; |
| 19 | 18 | } |
| 20 | 19 | |
| 21 | - $upgrade_url = 'https://go.elementor.com/go-pro-editor-notice-bar/'; | |
| 22 | - | |
| 23 | - $config = [ | |
| 24 | - 'description' => $this->get_description(), | |
| 25 | - 'upgrade_text' => $this->get_upgrade_text(), | |
| 26 | - 'upgrade_url' => $upgrade_url, | |
| 27 | - ]; | |
| 28 | - | |
| 29 | - $config = Filtered_Promotions_Manager::get_filtered_promotion_data( $config, 'elementor/notice-bar/custom_promotion', 'upgrade_url' ); | |
| 30 | - | |
| 31 | 20 | return [ |
| 32 | 21 | 'muted_period' => 14, |
| 33 | 22 | 'option_key' => '_elementor_editor_upgrade_notice_dismissed', |
| 34 | - 'message' => $config['description'] ?? $this->get_description(), | |
| 35 | - 'action_title' => $config['upgrade_text'] ?? $this->get_upgrade_text(), | |
| 36 | - 'action_url' => $config['upgrade_url'] ?? $upgrade_url, | |
| 23 | + 'message' => esc_html__( 'Unleash the full power of Elementor\'s features and web creation tools.', 'elementor' ), | |
| 24 | + 'action_title' => esc_html__( 'Upgrade Now', 'elementor' ), | |
| 25 | + 'action_url' => 'https://go.elementor.com/go-pro-editor-notice-bar/', | |
| 37 | 26 | ]; |
| 38 | 27 | } |
| 39 | 28 | |
| 40 | - public function get_upgrade_text() { | |
| 41 | - return esc_html__( 'Upgrade Now', 'elementor' ); | |
| 42 | - } | |
| 43 | - | |
| 44 | - public function get_description() { | |
| 45 | - return esc_html__( 'Unleash the full power of Elementor\'s features and web creation tools.', 'elementor' ); | |
| 46 | - } | |
| 47 | - | |
| 48 | 29 | final public function get_notice() { |
| 49 | - if ( ! $this->has_access_to_notice() ) { | |
| 30 | + if ( ! current_user_can( 'manage_options' ) ) { | |
| 50 | 31 | return null; |
| 51 | 32 | } |
| 52 | 33 | |
| 53 | 34 | $settings = $this->get_settings(); |
| @@ -90,13 +71,13 @@ | ||
| 90 | 71 | |
| 91 | 72 | } |
| 92 | 73 | |
| 93 | 74 | ?> |
| 94 | - <div class="e-notice-bar__message <?php echo esc_attr( "e-notice-bar__{$type}_message" ); ?>"> | |
| 75 | + <div class="e-notice-bar__message <?php echo esc_attr( "e-notice-bar__${type}_message" ); ?>"> | |
| 95 | 76 | <?php Utils::print_unescaped_internal_string( sprintf( $settings[ $action_message ], $settings[ $action_url ] ) ); ?> |
| 96 | 77 | </div> |
| 97 | 78 | |
| 98 | - <div class="e-notice-bar__action <?php echo esc_attr( "e-notice-bar__{$type}_action" ); ?>"> | |
| 79 | + <div class="e-notice-bar__action <?php echo esc_attr( "e-notice-bar__${type}_action" ); ?>"> | |
| 99 | 80 | <a href="<?php Utils::print_unescaped_internal_string( $settings[ $action_url ] ); ?>" |
| 100 | 81 | target="<?php echo empty( $settings[ $action_target ] ) ? '_blank' : esc_attr( $settings[ $action_target ] ); ?>" |
| 101 | 82 | > |
| 102 | 83 | <?php Utils::print_unescaped_internal_string( $settings[ $action_title ] ); ?> |
| @@ -130,19 +111,11 @@ | ||
| 130 | 111 | add_action( 'elementor/ajax/register_actions', [ $this, 'register_ajax_actions' ] ); |
| 131 | 112 | } |
| 132 | 113 | |
| 133 | 114 | public function set_notice_dismissed() { |
| 134 | - if ( ! $this->has_access_to_notice() ) { | |
| 135 | - throw new \Exception( 'Access denied' ); | |
| 136 | - } | |
| 137 | - | |
| 138 | 115 | update_option( $this->get_settings( 'option_key' ), time() ); |
| 139 | 116 | } |
| 140 | 117 | |
| 141 | 118 | public function register_ajax_actions( Ajax $ajax ) { |
| 142 | 119 | $ajax->register_ajax_action( 'notice_bar_dismiss', [ $this, 'set_notice_dismissed' ] ); |
| 143 | - } | |
| 144 | - | |
| 145 | - private function has_access_to_notice() { | |
| 146 | - return current_user_can( 'manage_options' ); | |
| 147 | 120 | } |
| 148 | 121 | } |