Update elementor pro
This commit is contained in:
@@ -6,6 +6,7 @@ use Elementor\Settings;
|
||||
use Elementor\Utils;
|
||||
use ElementorPro\Core\Utils as Pro_Utils;
|
||||
use ElementorPro\Core\Connect\Apps\Activate;
|
||||
use ElementorPro\License\Data\Controller;
|
||||
use ElementorPro\License\Notices\Trial_Expired_Notice;
|
||||
use ElementorPro\License\Notices\Trial_Period_Notice;
|
||||
use ElementorPro\Plugin;
|
||||
@@ -28,6 +29,10 @@ class Admin {
|
||||
*/
|
||||
public static $updater = null;
|
||||
|
||||
public function __construct() {
|
||||
$this->register_rest_controller();
|
||||
}
|
||||
|
||||
public static function get_errors_details() {
|
||||
$license_page_link = self::get_url();
|
||||
|
||||
@@ -788,4 +793,8 @@ class Admin {
|
||||
|
||||
return wp_verify_nonce( $nonce, 'opt_out' );
|
||||
}
|
||||
|
||||
private function register_rest_controller() {
|
||||
new Controller();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -633,4 +633,15 @@ class API {
|
||||
|
||||
return $tier;
|
||||
}
|
||||
|
||||
public static function get_plan_type() {
|
||||
if ( ! static::is_license_active() ) {
|
||||
return 'free';
|
||||
}
|
||||
|
||||
$license_data = static::get_license_data();
|
||||
$plan_type = $license_data['tier'] ?? 'free';
|
||||
|
||||
return $plan_type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ export default class Module extends elementorModules.Module {
|
||||
|
||||
onInit() {
|
||||
this.assignMenuItemActions();
|
||||
this.assignProLicenseActivateEvent();
|
||||
}
|
||||
|
||||
assignMenuItemActions() {
|
||||
@@ -30,4 +31,31 @@ export default class Module extends elementorModules.Module {
|
||||
} );
|
||||
} );
|
||||
}
|
||||
|
||||
assignProLicenseActivateEvent() {
|
||||
window.addEventListener( 'DOMContentLoaded', () => {
|
||||
const activateButton = document.querySelector( '.button-primary[href*="elementor-connect"]' );
|
||||
|
||||
if ( activateButton ) {
|
||||
activateButton.addEventListener( 'click', () => {
|
||||
if ( ! window.elementorCommon?.config?.experimentalFeatures?.editor_events ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const eventsManager = window.elementorCommon?.eventsManager || {};
|
||||
const dispatchEvent = eventsManager.dispatchEvent?.bind( eventsManager );
|
||||
|
||||
const eventName = 'pro_license_activate';
|
||||
const eventData = {
|
||||
app_type: 'editor',
|
||||
location: 'Elementor WP-admin pages',
|
||||
secondaryLocation: 'license page',
|
||||
trigger: 'click',
|
||||
};
|
||||
|
||||
dispatchEvent?.( eventName, eventData );
|
||||
} );
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
19
wp-content/plugins/elementor-pro/license/data/controller.php
Normal file
19
wp-content/plugins/elementor-pro/license/data/controller.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
namespace ElementorPro\License\Data;
|
||||
|
||||
use ElementorPro\Core\Data\Controller as Base_Controller;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
class Controller extends Base_Controller {
|
||||
|
||||
public function get_name() {
|
||||
return 'license';
|
||||
}
|
||||
|
||||
protected function register_endpoints() {
|
||||
$this->register_endpoint( Endpoints\Get_Tier_Features::class );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
namespace ElementorPro\License\Data\Endpoints;
|
||||
|
||||
use ElementorPro\Core\Data\Endpoints\Base;
|
||||
use ElementorPro\Core\Data\Interfaces\Endpoint;
|
||||
use ElementorPro\License\API;
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
class Get_Tier_Features extends Base implements Endpoint {
|
||||
|
||||
public function get_name(): string {
|
||||
return 'get-tier-features';
|
||||
}
|
||||
|
||||
public function get_route(): string {
|
||||
return 'tier-features';
|
||||
}
|
||||
|
||||
protected function register() {
|
||||
register_rest_route(
|
||||
$this->controller->get_namespace(),
|
||||
'/' . $this->controller->get_name() . '/' . $this->get_route(),
|
||||
[
|
||||
[
|
||||
'methods' => 'GET',
|
||||
'callback' => [ $this, 'get_features' ],
|
||||
'permission_callback' => [ $this, 'permission_callback' ],
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function get_features( $request ) {
|
||||
$license_data = API::get_license_data();
|
||||
$features = ! empty( $license_data['features'] ) ? $license_data['features'] : [];
|
||||
|
||||
return new \WP_REST_Response( [
|
||||
'features' => $features,
|
||||
], 200 );
|
||||
}
|
||||
|
||||
public function permission_callback( $request ) {
|
||||
return is_user_logged_in();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user