updater` instead. */ public static $updater = null; public static function get_errors_details() { $license_page_link = self::get_url(); return [ API::STATUS_EXPIRED => [ 'title' => esc_html__( 'Your Elementor Pro license has expired.', 'elementor-pro' ), 'description' => esc_html__( 'Want to keep creating secure and high-performing websites? Renew your subscription to regain access to all of the Elementor Pro widgets, templates, updates & more', 'elementor-pro' ), 'button_text' => esc_html__( 'Renew Now', 'elementor-pro' ), 'button_url' => API::RENEW_URL, 'button_type' => 'cta', ], API::STATUS_CANCELLED => [ 'title' => esc_html__( 'Your License Is Inactive', 'elementor-pro' ), 'description' => sprintf( /* translators: 1: Bold text opening tag, 2: Bold text closing tag. */ esc_html__( '%1$sYour license key has been cancelled%2$s (most likely due to a refund request). Please consider acquiring a new license.', 'elementor-pro' ), '', '' ), 'button_text' => esc_html__( 'Activate License', 'elementor-pro' ), 'button_url' => $license_page_link, ], API::STATUS_SITE_INACTIVE => [ 'title' => esc_html__( 'License Mismatch', 'elementor-pro' ), 'description' => sprintf( /* translators: 1: Bold text opening tag, 2: Bold text closing tag. */ esc_html__( '%1$sYour license key doesn\'t match your current domain%2$s. This is most likely due to a change in the domain URL. Please deactivate the license and then reactivate it again.', 'elementor-pro' ), '', '' ), 'button_text' => esc_html__( 'Reactivate License', 'elementor-pro' ), 'button_url' => $license_page_link, ], ]; } public static function deactivate() { API::deactivate_license(); delete_option( self::LICENSE_KEY_OPTION_NAME ); delete_option( self::LICENSE_DATA_OPTION_NAME ); delete_option( self::LICENSE_DATA_FALLBACK_OPTION_NAME ); } private static function get_hidden_license_key() { $input_string = self::get_license_key(); $start = 5; $length = mb_strlen( $input_string ) - $start - 5; $mask_string = preg_replace( '/\S/', 'X', $input_string ); $mask_string = mb_substr( $mask_string, $start, $length ); $input_string = substr_replace( $input_string, $mask_string, $start, $length ); return $input_string; } /** * @deprecated 3.6.0 Use `Plugin::instance()->updater` instead. * * @return \ElementorPro\License\Updater */ public static function get_updater_instance() { static::$updater = Plugin::instance()->updater; return static::$updater; } public static function get_license_key() { return trim( get_option( self::LICENSE_KEY_OPTION_NAME ) ); } public static function set_license_key( $license_key ) { return update_option( self::LICENSE_KEY_OPTION_NAME, $license_key ); } public function action_activate_license() { check_admin_referer( 'elementor-pro-license' ); $license_key = Pro_Utils::_unstable_get_super_global_value( $_POST, 'elementor_pro_license_key' ); if ( ! $license_key ) { wp_die( esc_html__( 'Please enter your license key.', 'elementor-pro' ), esc_html__( 'Elementor Pro', 'elementor-pro' ), [ 'back_link' => true, ] ); } $data = API::activate_license( $license_key ); if ( is_wp_error( $data ) ) { wp_die( sprintf( '%s (%s) ', wp_kses_post( $data->get_error_message() ), wp_kses_post( $data->get_error_code() ) ), esc_html__( 'Elementor Pro', 'elementor-pro' ), [ 'back_link' => true, ] ); } if ( empty( $data['success'] ) ) { $error_msg = API::get_error_message( $data['error'] ); wp_die( wp_kses_post( $error_msg ), esc_html__( 'Elementor Pro', 'elementor-pro' ), [ 'back_link' => true, ] ); } self::set_license_key( $license_key ); API::set_license_data( $data ); $this->safe_redirect( Pro_Utils::_unstable_get_super_global_value( $_POST, '_wp_http_referer' ) ); } protected function safe_redirect( $url ) { wp_safe_redirect( $url ); die; } public function action_deactivate_license() { check_admin_referer( 'elementor-pro-license' ); $this->deactivate(); $this->safe_redirect( Pro_Utils::_unstable_get_super_global_value( $_POST, '_wp_http_referer' ) ); } public function register_page() { return; $menu_text = esc_html__( 'License', 'elementor-pro' ); add_submenu_page( Settings::PAGE_ID, $menu_text, $menu_text, 'manage_options', self::PAGE_ID, [ $this, 'display_page' ] ); if ( API::is_license_expired() ) { add_submenu_page( Settings::PAGE_ID, '', sprintf( ' %s ', esc_html__( 'Renew Now', 'elementor-pro' ) ), 'manage_options', 'elementor_pro_renew_license_menu_link' ); } if ( ! API::is_license_expired() && API::is_need_to_show_upgrade_promotion() ) { add_submenu_page( Settings::PAGE_ID, '', esc_html__( 'Upgrade', 'elementor-pro' ), 'manage_options', 'elementor_pro_upgrade_license_menu_link' ); } } public static function get_url() { return admin_url( 'admin.php?page=' . self::PAGE_ID ); } public function display_page() { $license_key = self::get_license_key(); $is_manual_mode = ( isset( $_GET['mode'] ) && 'manually' === $_GET['mode'] ); if ( $is_manual_mode ) { $this->render_manually_activation_widget( $license_key ); return; } ?>
', '', '', '' ); ?>
', '' ); ?>
is_block_editor() ) { return true; } if ( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) { return true; } return false; } public function admin_license_details() { if ( ! current_user_can( 'manage_options' ) ) { return; } if ( $this->is_block_editor_page() ) { return; } $renew_url = API::RENEW_URL; $license_key = self::get_license_key(); /** * @var Admin_Notices $admin_notices */ $admin_notices = Plugin::elementor()->admin->get_component( 'admin-notices' ); if ( empty( $license_key ) ) { $admin_notices->print_admin_notice( [ 'title' => esc_html__( 'Welcome to Elementor Pro!', 'elementor-pro' ), 'description' => $this->get_activate_message(), 'button' => [ 'text' => '' . esc_html__( 'Connect & Activate', 'elementor-pro' ), 'url' => $this->get_connect_url( [ 'utm_source' => 'wp-notification-banner', 'utm_medium' => 'wp-dash', 'utm_campaign' => 'connect-and-activate-license', ] ), ], ] ); return; } $license_data = API::get_license_data(); // When the license with pro trial, the messages here are not relevant, pro trial messages will be shown instead. if ( API::is_licence_pro_trial() ) { return; } $errors = self::get_errors_details(); if ( ! $license_data['success'] && isset( $license_data['error'], $errors[ $license_data['error'] ] ) ) { $error_data = $errors[ $license_data['error'] ]; $admin_notices->print_admin_notice( [ 'title' => $error_data['title'], 'description' => $error_data['description'], 'button' => [ 'text' => $error_data['button_text'], 'url' => $error_data['button_url'], 'type' => isset( $error_data['button_type'] ) ? $error_data['button_type'] : '', ], ] ); return; } if ( API::is_license_active() && API::is_license_about_to_expire() ) { $title = sprintf( /* translators: %s: Days to expire. */ esc_html__( 'Your License Will Expire in %s.', 'elementor-pro' ), human_time_diff( current_time( 'timestamp' ), strtotime( $license_data['expires'] ) ) ); if ( isset( $license_data['renewal_discount'] ) && 0 < $license_data['renewal_discount'] ) { $description = sprintf( /* translators: %s: Discount percent. */ esc_html__( 'Renew your license today, and get an exclusive, time-limited %s discount.', 'elementor-pro' ), $license_data['renewal_discount'] . '%' ); } else { $description = esc_html__( 'Renew your license today, to keep getting feature updates, premium support, Pro widgets & unlimited access to the template library.', 'elementor-pro' ); } $admin_notices->print_admin_notice( [ 'title' => $title, 'description' => $description, 'type' => 'warning', 'button' => [ 'text' => esc_html__( 'Renew now', 'elementor-pro' ), 'url' => $renew_url, 'type' => 'warning', ], ] ); } } public function filter_library_get_templates_args( $body_args ) { $license_key = self::get_license_key(); if ( ! empty( $license_key ) ) { $body_args['license'] = $license_key; $body_args['url'] = home_url(); } return $body_args; } public function handle_tracker_actions() { // Show tracker notice after 24 hours from Pro installed time. $is_need_to_show = ( $this->get_installed_time() < strtotime( '-24 hours' ) ); $is_dismiss_notice = ( '1' === get_option( 'elementor_tracker_notice' ) ); $is_dismiss_pro_notice = ( '1' === get_option( 'elementor_pro_tracker_notice' ) ); if ( $is_need_to_show && $is_dismiss_notice && ! $is_dismiss_pro_notice ) { delete_option( 'elementor_tracker_notice' ); } if ( ! isset( $_GET['elementor_tracker'] ) ) { return; } if ( 'opt_out' === $_GET['elementor_tracker'] ) { update_option( 'elementor_pro_tracker_notice', '1' ); } } public function get_installed_time() { $installed_time = get_option( '_elementor_pro_installed_time' ); if ( ! $installed_time ) { $installed_time = time(); update_option( '_elementor_pro_installed_time', $installed_time ); } return $installed_time; } public function plugin_action_links( $links ) { $license_key = self::get_license_key(); if ( empty( $license_key ) ) { $links['active_license'] = sprintf( '%s', self::get_connect_url([ 'utm_source' => 'wp-plugins', 'utm_medium' => 'wp-dash', 'utm_campaign' => 'connect-and-activate-license', ]), __( 'Connect & Activate', 'elementor-pro' ) ); } if ( API::is_license_expired() ) { $links['renew_license'] = sprintf( '%s', 'https://go.elementor.com/wp-plugins-renew/', __( 'Renew Now', 'elementor-pro' ) ); } return $links; } public function plugin_auto_update_setting_html( $html, $plugin_file ) { $license_data = API::get_license_data(); if ( ELEMENTOR_PRO_PLUGIN_BASE === $plugin_file && ! $license_data['success'] ) { return '' . esc_html__( '(unavailable)', 'elementor-pro' ) . ''; } return $html; } private function handle_dashboard_admin_widget() { add_action( 'elementor/admin/dashboard_overview_widget/after_version', function() { /* translators: %s: Elementor Pro version. */ $label = sprintf( esc_html__( 'Elementor Pro v%s', 'elementor-pro' ), ELEMENTOR_PRO_VERSION ); echo ''; Utils::print_unescaped_internal_string( $label ); echo ''; } ); add_filter( 'elementor/admin/dashboard_overview_widget/footer_actions', function( $additions_actions ) { unset( $additions_actions['go-pro'] ); if ( current_user_can( 'manage_options' ) ) { // Using 'go-pro' key to style the 'renew' button as the 'go-pro' button if ( API::is_license_expired() ) { $additions_actions['go-pro'] = [ 'title' => esc_html__( 'Renew Now', 'elementor-pro' ), 'link' => 'https://go.elementor.com/overview-widget-renew/', ]; } elseif ( API::is_need_to_show_upgrade_promotion() ) { $additions_actions['go-pro'] = [ 'title' => esc_html__( 'Upgrade', 'elementor-pro' ), 'link' => 'https://go.elementor.com/go-pro-advanced-wordpress-elementor-overview/', ]; } } return $additions_actions; }, 550 ); } public function add_finder_item( array $categories ) { $categories['settings']['items']['license'] = [ 'title' => esc_html__( 'License', 'elementor-pro' ), 'url' => self::get_url(), ]; return $categories; } private function render_manually_activation_widget( $license_key ) { ?>