PluginProbe
Elementor Website Builder – more than just a page builder / 4.1.4
Elementor Website Builder – more than just a page builder v4.1.4
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
← All changes | app/modules/site-builder/module.php +56 -3 4.2.04.1.4 View file →
@@ -2,9 +2,8 @@
2 2 namespace Elementor\App\Modules\SiteBuilder;
3 3
4 4 use Elementor\App\Modules\SiteBuilder\Connect\App;
5 5 use Elementor\App\Modules\SiteBuilder\Rest\Rest_Api;
6 -use Elementor\App\Modules\SiteBuilder\Services\Connect_Auth_Service;
7 6 use Elementor\Core\Base\Module as BaseModule;
8 7 use Elementor\Plugin;
9 8
10 9 if ( ! defined( 'ABSPATH' ) ) {
@@ -62,8 +61,14 @@
62 61 'exitTo' => admin_url( 'admin.php?page=elementor' ),
63 62 'elementorAiCurrentContext' => $this->get_elementor_ai_current_context(),
64 63 ];
65 64
65 + $connect_auth = $this->get_connect_auth();
66 +
67 + if ( $connect_auth ) {
68 + $settings['connectAuth'] = $connect_auth;
69 + }
70 +
66 71 Plugin::$instance->app->set_settings( 'site-builder', $settings );
67 72 }
68 73
69 74 private function get_elementor_ai_current_context(): array {
@@ -87,15 +92,63 @@
87 92 if ( ! $this->is_experiment_active() ) {
88 93 return null;
89 94 }
90 95
91 - $connect_auth = ( new Connect_Auth_Service() )->get_connect_auth();
96 + $connect_auth = $this->get_connect_auth();
92 97
93 98 if ( ! $connect_auth ) {
94 - return [];
99 + return null;
95 100 }
96 101
97 102 return [
98 103 'siteKey' => $connect_auth['siteKey'],
104 + ];
105 + }
106 +
107 + private function get_connect_auth(): ?array {
108 + if ( ! Plugin::instance()->common ) {
109 + return null;
110 + }
111 +
112 + $connect = Plugin::instance()->common->get_component( 'connect' );
113 +
114 + if ( ! $connect ) {
115 + return null;
116 + }
117 +
118 + $app = $connect->get_app( 'library' );
119 +
120 + if ( ! $app || ! $app->is_connected() ) {
121 + return null;
122 + }
123 +
124 + $access_token = $app->get( 'access_token' );
125 + $client_id = $app->get( 'client_id' );
126 + $home_url = trailingslashit( home_url() );
127 + $site_key = $app->get_site_key();
128 + $access_token_secret = $app->get( 'access_token_secret' );
129 +
130 + $connect_data = [
131 + 'access-token' => $access_token,
132 + 'app' => 'library',
133 + 'client-id' => $client_id,
134 + 'home-url' => $home_url,
135 + 'site-key' => $site_key,
136 + ];
137 +
138 + ksort( $connect_data );
139 +
140 + $signature = hash_hmac(
141 + 'sha256',
142 + wp_json_encode( $connect_data, JSON_NUMERIC_CHECK ),
143 + $access_token_secret
144 + );
145 +
146 + return [
147 + 'signature' => $signature,
148 + 'accessToken' => $access_token,
149 + 'clientId' => $client_id,
150 + 'homeUrl' => $home_url,
151 + 'siteKey' => $site_key,
99 152 ];
100 153 }
101 154 }