mirror of
https://github.com/proelements/proelements.git
synced 2026-04-05 20:13:47 +00:00
v3.33.1
This commit is contained in:
58
core/behaviors/feature-lock.php
Normal file
58
core/behaviors/feature-lock.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
namespace ElementorPro\Core\Behaviors;
|
||||
|
||||
use ElementorPro\License\API;
|
||||
use ElementorPro\Plugin;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Feature_Lock implements Temp_Lock_Behavior {
|
||||
|
||||
private $config;
|
||||
|
||||
public function __construct( $config = [] ) {
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
public function is_locked() {
|
||||
return ! API::is_license_active();
|
||||
}
|
||||
|
||||
public function get_config() {
|
||||
$utm_args = [
|
||||
'utm_source' => '%%utm_source%%', // Will be replaced in the frontend.
|
||||
'utm_medium' => '%%utm_medium%%',
|
||||
'utm_campaign' => API::is_license_expired()
|
||||
? 'renew-license'
|
||||
: 'connect-and-activate-license',
|
||||
'utm_term' => $this->config['type'],
|
||||
];
|
||||
|
||||
$connect_url = Plugin::instance()->license_admin->get_connect_url( $utm_args );
|
||||
|
||||
$renew_url = add_query_arg( $utm_args, 'https://my.elementor.com/subscriptions/' );
|
||||
|
||||
return [
|
||||
'is_locked' => $this->is_locked(),
|
||||
'badge' => [
|
||||
'icon' => 'eicon-lock',
|
||||
'text' => esc_html__( 'Pro', 'elementor-pro' ),
|
||||
],
|
||||
'content' => [
|
||||
'heading' => esc_html__( '', 'elementor-pro' ),
|
||||
'description' => esc_html__( '', 'elementor-pro' ),
|
||||
],
|
||||
'button' => [
|
||||
'text' => API::is_license_expired()
|
||||
? esc_html__( 'Renew now', 'elementor-pro' )
|
||||
: esc_html__( 'Connect & Activate', 'elementor-pro' ),
|
||||
|
||||
'url' => API::is_license_expired()
|
||||
? $renew_url
|
||||
: $connect_url,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
39
core/behaviors/temp-lock-behavior.php
Normal file
39
core/behaviors/temp-lock-behavior.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
namespace ElementorPro\Core\Behaviors;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
// TODO: Used here for testing. Should be removed when it'll be available in the Core.
|
||||
interface Temp_Lock_Behavior {
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function is_locked();
|
||||
|
||||
/**
|
||||
* @return array {
|
||||
*
|
||||
* @type bool $is_locked
|
||||
*
|
||||
* @type array $badge {
|
||||
* @type string $icon
|
||||
* @type string $text
|
||||
* }
|
||||
*
|
||||
* @type array $content {
|
||||
* @type string $heading
|
||||
* @type string $description
|
||||
* }
|
||||
*
|
||||
* @type array $button {
|
||||
* @type string $text
|
||||
* @type string $url
|
||||
* }
|
||||
*
|
||||
* }
|
||||
*/
|
||||
public function get_config();
|
||||
}
|
||||
Reference in New Issue
Block a user