first commit

This commit is contained in:
Roman Pyrih
2026-04-28 09:27:26 +02:00
commit 968c7e1248
4942 changed files with 1507729 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
<?php
namespace ElementorPro\License\EditorOneMenuItems;
use Elementor\Core\Admin\EditorOneMenu\Interfaces\Menu_Item_Interface;
use Elementor\Modules\EditorOne\Classes\Menu_Config;
use ElementorPro\License\Admin;
use Elementor\Core\Admin\Menu\Interfaces\Admin_Menu_Item_With_Page;
use ElementorPro\Plugin;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class Editor_One_License_Menu_Item implements Menu_Item_Interface, Admin_Menu_Item_With_Page {
public function get_page_title() : string {
return esc_html__( 'License', 'elementor-pro' );
}
public function get_capability() : string {
return 'manage_options';
}
public function get_label() : string {
return esc_html__( 'License', 'elementor-pro' );
}
public function get_parent_slug() : string {
return Menu_Config::ELEMENTOR_MENU_SLUG;
}
public function is_visible() : bool {
return true;
}
public function get_position() : int {
return 60;
}
public function get_slug() : string {
return Admin::PAGE_ID;
}
public function get_group_id() : string {
return Menu_Config::SYSTEM_GROUP_ID;
}
public function render() : void {
Plugin::instance()->license_admin->display_page();
}
}

View File

@@ -0,0 +1,44 @@
<?php
namespace ElementorPro\License\EditorOneMenuItems;
use Elementor\Core\Admin\EditorOneMenu\Interfaces\Menu_Item_Interface;
use Elementor\Modules\EditorOne\Classes\Menu_Config;
use ElementorPro\License\API;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class Editor_One_Renew_Menu_Item implements Menu_Item_Interface {
const RENEW_URL = 'https://go.elementor.com/wp-menu-renew/';
public function get_capability() : string {
return 'manage_options';
}
public function get_label() : string {
return esc_html__( 'Renew Now', 'elementor-pro' );
}
public function get_parent_slug() : string {
return Menu_Config::ELEMENTOR_MENU_SLUG;
}
public function is_visible() : bool {
return API::is_license_expired();
}
public function get_position() : int {
return 61;
}
public function get_slug() : string {
return self::RENEW_URL;
}
public function get_group_id(): string {
return Menu_Config::SYSTEM_GROUP_ID;
}
}

View File

@@ -0,0 +1,49 @@
<?php
namespace ElementorPro\License\EditorOneMenuItems;
use Elementor\Core\Admin\EditorOneMenu\Interfaces\Menu_Item_Interface;
use Elementor\Modules\EditorOne\Classes\Menu_Config;
use ElementorPro\Core\Utils as Pro_Utils;
use ElementorPro\License\API;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class Editor_One_Upgrade_Menu_Item implements Menu_Item_Interface {
const UPGRADE_URL = 'https://go.elementor.com/go-pro-advanced-elementor-menu/';
public function get_capability() : string {
return 'manage_options';
}
public function get_label() : string {
if ( Pro_Utils::is_sale_time() ) {
return esc_html__( 'Discounted Upgrades', 'elementor-pro' );
}
return esc_html__( 'Unlock More Features', 'elementor-pro' );
}
public function get_parent_slug() : string {
return Menu_Config::ELEMENTOR_MENU_SLUG;
}
public function is_visible() : bool {
return ! API::is_license_expired() && API::is_need_to_show_upgrade_promotion();
}
public function get_position() : int {
return 62;
}
public function get_slug() : string {
return self::UPGRADE_URL;
}
public function get_group_id(): string {
return Menu_Config::SYSTEM_GROUP_ID;
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace ElementorPro\License\Notices;
use Elementor\Core\Admin\Notices\Base_Notice;
use ElementorPro\License\API as License_API;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
class Trial_Expired_Notice extends Base_Notice {
/**
* Notice ID.
*/
const ID = 'elementor_trial_expired_promote';
/**
* @inheritDoc
*/
public function should_print() {
return License_API::is_license_expired() && License_API::is_licence_pro_trial();
}
/**
* @inheritDoc
*/
public function get_config() {
return [
'id' => static::ID,
'title' => esc_html__( 'Your trial has expired', 'elementor-pro' ),
'description' => __( 'Want to continue using Pro to build your website? Choose the plan that\'s right for you!', 'elementor-pro' ),
'button' => [
'text' => esc_html__( 'Go Pro', 'elementor-pro' ),
'url' => 'https://my.elementor.com/upgrade-subscription/?utm_source=wp-notification-banner&utm_medium=wp-dash&utm_campaign=pro-trial&utm_content=trial-expired',
'new_tab' => true,
'type' => 'cta',
],
];
}
}

View File

@@ -0,0 +1,53 @@
<?php
namespace ElementorPro\License\Notices;
use Elementor\Core\Admin\Notices\Base_Notice;
use ElementorPro\License\API;
use ElementorPro\License\API as License_API;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
class Trial_Period_Notice extends Base_Notice {
/**
* Notice ID.
*/
const ID = 'elementor_trial_period_promote';
/**
* @inheritDoc
*/
public function should_print() {
return License_API::is_license_active() && License_API::is_licence_pro_trial();
}
/**
* @inheritDoc
*/
public function get_config() {
$license_data = API::get_license_data();
$title = sprintf(
/* translators: %s: Days left to trial expiration. */
esc_html__( 'Your trial expires in %s', 'elementor-pro' ),
human_time_diff(
current_time( 'timestamp' ),
strtotime( $license_data['expires'] )
)
);
return [
'id' => static::ID,
'title' => $title,
'description' => __( 'Find the plan that matches your needs and enjoy Pro widgets, templates, and support for a whole year.', 'elementor-pro' ),
'button' => [
'text' => esc_html__( 'Choose your plan', 'elementor-pro' ),
'url' => 'https://my.elementor.com/upgrade-subscription/?utm_source=wp-notification-banner&utm_medium=wp-dash&utm_campaign=pro-trial&utm_content=trial-period',
'new_tab' => true,
'type' => 'cta',
],
];
}
}

View File

@@ -0,0 +1,45 @@
<?php
namespace ElementorPro\License;
use ElementorOne\Connect\Facade;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
class One {
/**
* Check if Elementor One is connected.
*
* @return bool
*/
public static function is_connected(): bool {
if ( ! class_exists( Facade::class ) ) {
return false;
}
$facade = Facade::get( 'elementor-pro' );
return $facade ? $facade->utils()->is_connected() : false;
}
/**
* Get the subscription display name for Elementor One.
*
* @return string
*/
public static function get_subscription_display_name(): string {
return 'Elementor One';
}
/**
* Get the manage subscription URL when One is connected.
*
* @return string
*/
public static function get_manage_subscription_url(): string {
return admin_url( 'admin.php?page=elementor-home#/home/tool-manager' );
}
}

View File

@@ -0,0 +1,249 @@
<?php
namespace ElementorPro\License;
use ElementorPro\Core\Utils as ProUtils;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
class Updater {
public $plugin_version;
public $plugin_name;
public $plugin_slug;
private $response_transient_key;
public function __construct() {
$this->plugin_version = ELEMENTOR_PRO_VERSION;
$this->plugin_name = ELEMENTOR_PRO_PLUGIN_BASE;
$this->plugin_slug = basename( ELEMENTOR_PRO__FILE__, '.php' );
$this->response_transient_key = md5( sanitize_key( $this->plugin_name ) . 'response_transient' );
$this->setup_hooks();
$this->maybe_delete_transients();
}
private function setup_hooks() {
if ( ! $this->is_elementor_pro_rollback() ) {
add_filter( 'pre_set_site_transient_update_plugins', [ $this, 'check_update' ], 50 );
}
add_action( 'delete_site_transient_update_plugins', [ $this, 'delete_transients' ] );
add_filter( 'plugins_api', [ $this, 'plugins_api_filter' ], 10, 3 );
remove_action( 'after_plugin_row_' . $this->plugin_name, 'wp_plugin_update_row' );
add_action( 'after_plugin_row_' . $this->plugin_name, [ $this, 'show_update_notification' ], 10, 2 );
add_action( 'update_option_WPLANG', function () {
$this->clean_get_version_cache();
} );
add_action( 'upgrader_process_complete', function () {
$this->clean_get_version_cache();
} );
}
public function delete_transients() {
$this->delete_transient( $this->response_transient_key );
}
private function maybe_delete_transients() {
global $pagenow;
if ( 'update-core.php' === $pagenow && isset( $_GET['force-check'] ) ) {
$this->delete_transients();
}
}
private function check_transient_data( $_transient_data ) {
if ( ! is_object( $_transient_data ) ) {
$_transient_data = new \stdClass();
}
$version_info = API::get_version( false /* Use Cache */ );
if ( is_wp_error( $version_info ) ) {
return $_transient_data;
}
// include an unmodified $wp_version
include( ABSPATH . WPINC . '/version.php' );
if ( version_compare( $wp_version, $version_info['requires'], '<' ) ) {
return $_transient_data;
}
if ( ! empty( $version_info['elementor_requires'] ) ) {
if ( version_compare( ELEMENTOR_VERSION, $version_info['elementor_requires'], '<' ) ) {
return $_transient_data;
}
}
$plugin_info = (object) $version_info;
unset( $plugin_info->sections );
$plugin_info->plugin = $this->plugin_name;
if ( version_compare( $this->plugin_version, $version_info['new_version'], '<' ) ) {
$_transient_data->response[ $this->plugin_name ] = $plugin_info;
$_transient_data->checked[ $this->plugin_name ] = $version_info['new_version'];
} else {
$_transient_data->no_update[ $this->plugin_name ] = $plugin_info;
$_transient_data->checked[ $this->plugin_name ] = $this->plugin_version;
}
$_transient_data->last_checked = current_time( 'timestamp' );
if ( ! isset( $_transient_data->translations ) ) {
$_transient_data->translations = [];
}
$_transient_data->translations = array_filter( $_transient_data->translations, function( $translation ) {
return ( $translation['slug'] !== $this->plugin_slug );
} );
if ( ! empty( $version_info['translations'] ) ) {
foreach ( $version_info['translations'] as $translation ) {
$_transient_data->translations[] = [
'type' => 'plugin',
'slug' => $this->plugin_slug,
'language' => $translation['language'],
'version' => $version_info['new_version'],
'updated' => $translation['updated'],
'package' => $translation['package'],
'autoupdate' => true,
];
}
}
return $_transient_data;
}
public function check_update( $_transient_data ) {
global $pagenow;
if ( ! is_object( $_transient_data ) ) {
$_transient_data = new \stdClass();
}
return $this->check_transient_data( $_transient_data );
}
public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
if ( 'plugin_information' !== $_action ) {
return $_data;
}
if ( ! isset( $_args->slug ) || ( $_args->slug !== $this->plugin_slug ) ) {
return $_data;
}
$cache_key = 'elementor_pro_api_request_' . substr( md5( serialize( $this->plugin_slug ) ), 0, 15 );
$api_request_transient = get_site_transient( $cache_key );
if ( empty( $api_request_transient ) ) {
$api_response = API::get_version();
if ( is_wp_error( $api_response ) ) {
return $_data;
}
$api_request_transient = new \stdClass();
$api_request_transient->name = 'Elementor Pro';
$api_request_transient->slug = $this->plugin_slug;
$api_request_transient->author = '<a href="https://elementor.com/">Elementor.com</a>';
$api_request_transient->homepage = 'https://elementor.com/';
$api_request_transient->requires = $api_response['requires'];
$api_request_transient->tested = $api_response['tested'];
$api_request_transient->version = $api_response['new_version'];
$api_request_transient->last_updated = $api_response['last_updated'];
$api_request_transient->download_link = $api_response['download_link'];
$api_request_transient->banners = [
'high' => 'https://ps.w.org/elementor/assets/banner-1544x500.png?rev=1494133',
'low' => 'https://ps.w.org/elementor/assets/banner-1544x500.png?rev=1494133',
];
$api_request_transient->autoupdate = true;
$api_request_transient->sections = unserialize( $api_response['sections'] );
// Expires in 1 day
set_site_transient( $cache_key, $api_request_transient, DAY_IN_SECONDS );
}
$_data = $api_request_transient;
return $_data;
}
public function show_update_notification( $file, $plugin ) {
if ( is_network_admin() ) {
return;
}
if ( ! current_user_can( 'update_plugins' ) ) {
return;
}
if ( ! is_multisite() ) {
return;
}
if ( $this->plugin_name !== $file ) {
return;
}
// Remove our filter on the site transient
remove_filter( 'pre_set_site_transient_update_plugins', [ $this, 'check_update' ] );
$update_cache = get_site_transient( 'update_plugins' );
$update_cache = $this->check_transient_data( $update_cache );
set_site_transient( 'update_plugins', $update_cache );
// Restore our filter
add_filter( 'pre_set_site_transient_update_plugins', [ $this, 'check_update' ] );
}
protected function get_transient( $cache_key ) {
$cache_data = get_option( $cache_key );
if ( empty( $cache_data['timeout'] ) || current_time( 'timestamp' ) > $cache_data['timeout'] ) {
// Cache is expired.
return false;
}
return $cache_data['value'];
}
protected function set_transient( $cache_key, $value, $expiration = 0 ) {
if ( empty( $expiration ) ) {
$expiration = strtotime( '+12 hours', current_time( 'timestamp' ) );
}
$data = [
'timeout' => $expiration,
'value' => $value,
];
update_option( $cache_key, $data, 'no' );
}
protected function delete_transient( $cache_key ) {
delete_option( $cache_key );
}
private function clean_get_version_cache() {
// Since `API::get_version` holds the old language.
$cache_key = API::TRANSIENT_KEY_PREFIX . ELEMENTOR_PRO_VERSION;
delete_option( $cache_key );
}
protected function is_elementor_pro_rollback(): bool {
return 'elementor_pro_rollback' === ProUtils::_unstable_get_super_global_value( $_GET, 'action' );
}
}