PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.5.2
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.5.2
3.7.5 3.7.4 3.7.3 3.7.2 1-final 3.7.1 3.7.0 3.6.8 3.6.7 3.6.6 3.6.5 3.6.4 3.6.3 3.6.2 3.6.1 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.10 All 111 releases
← All changes | includes/Plugin.php +10 -68 3.7.13.5.2 View file →
@@ -18,9 +18,8 @@
18 18 use Templately\API\ThemeBuilderApi;
19 19 use Templately\Builder\ThemeBuilder;
20 20 use Templately\Core\Importer\FullSiteImport;
21 21 use Templately\Utils\Base;
22 -use Templately\Utils\Database;
23 22 use Templately\Utils\Enqueue;
24 23
25 24 use Templately\Core\Admin;
26 25 use Templately\Core\Module;
@@ -27,9 +26,8 @@
27 26
28 27 use Templately\API\Tags;
29 28 use Templately\API\Items;
30 29 use Templately\API\Login;
31 -use Templately\API\Checkout;
32 30 use Templately\API\SignUp;
33 31 use Templately\API\Profile;
34 32 use Templately\API\Import;
35 33 use Templately\API\MyClouds;
@@ -38,9 +36,8 @@
38 36 use Templately\API\Dependencies;
39 37 use Templately\API\TemplateTypes;
40 38 use Templately\API\SavedTemplates;
41 39 use Templately\API\Sites;
42 -use Templately\API\Tour;
43 40 use Templately\Core\Maintenance;
44 41 use Templately\Core\Migrator;
45 42 use Templately\Core\Platform\Gutenberg;
46 43 use Templately\Core\Platform\Elementor;
@@ -45,9 +42,9 @@
45 42 use Templately\Core\Platform\Gutenberg;
46 43 use Templately\Core\Platform\Elementor;
47 44
48 45 final class Plugin extends Base {
49 - public $version = '3.7.1';
46 + public $version = '3.5.2';
50 47
51 48 public $admin;
52 49 public $settings;
53 50 /**
@@ -88,9 +85,10 @@
88 85
89 86 add_action( 'plugins_loaded', [ $this, 'plugins_loaded' ] );
90 87 add_action( 'rest_api_init', [ $this, 'register_routes' ] );
91 88
92 - add_action( 'init', [ $this, 'google_login_handler' ] );
89 + add_action( 'wp_ajax_templately_google_login', [ $this, 'google_login_handler' ] );
90 + add_action( 'wp_ajax_nopriv_templately_google_login', [ $this, 'google_login_handler' ] );
93 91
94 92 /**
95 93 * Initialize.
96 94 */
@@ -192,9 +190,8 @@
192 190 Items::get_instance();
193 191 SavedTemplates::get_instance();
194 192
195 193 Login::get_instance();
196 - Checkout::get_instance();
197 194 SignUp::get_instance();
198 195 Import::get_instance();
199 196 Profile::get_instance();
200 197 MyClouds::get_instance();
@@ -199,9 +196,8 @@
199 196 Profile::get_instance();
200 197 MyClouds::get_instance();
201 198 WorkSpaces::get_instance();
202 199 Sites::get_instance();
203 - Tour::get_instance();
204 200
205 201 APISettings::get_instance();
206 202 // Note: DeveloperSettings::get_instance() is called in Developer::init_modules() when developer functionality is available and enabled
207 203 }
@@ -266,47 +262,11 @@
266 262 load_plugin_textdomain( 'templately', false, dirname( TEMPLATELY_PLUGIN_BASENAME ) . '/languages' );
267 263 }
268 264
269 265 public function google_login_handler() {
270 - // Stop if not a templately google login request
271 - if ( empty( $_GET['templately_google_login'] ) ) {
272 - return;
273 - }
266 + $redirect_url = admin_url( 'admin.php?page=templately' );
274 267
275 - if ( wp_doing_ajax() || wp_doing_cron() || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) ) {
276 - return;
277 - }
278 -
279 - // Checked before the token is consumed: the callback can land while the
280 - // auth cookie is missing (expired session, cookie not yet set), and WP
281 - // will bounce the user through wp-login and back to this same URL.
282 - // Burning the token here would fail that legitimate retry.
283 - if ( ! is_user_logged_in() ) {
284 - return;
285 - }
286 -
287 - $state = '';
288 - if ( ! empty( $_GET['templately_state'] ) ) {
289 - $state = sanitize_text_field( wp_unslash( $_GET['templately_state'] ) );
290 - } elseif ( ! empty( $_GET['state'] ) ) {
291 - $state = sanitize_text_field( wp_unslash( $_GET['state'] ) );
292 - }
293 -
294 - $state_user_id = false;
295 - if ( ! empty( $state ) ) {
296 - $state_user_id = Database::get_transient( 'google_state_' . $state );
297 - Database::delete_transient( 'google_state_' . $state );
298 - }
299 -
300 - $is_authorized = false !== $state_user_id
301 - && intval( $state_user_id ) === get_current_user_id()
302 - && current_user_can( 'delete_posts' );
303 -
304 - $redirect_url = remove_query_arg( [ 'templately_google_login', 'templately_state', 'api_key', 'error', 'state', 'redirect-to' ] );
305 -
306 - if ( ! $is_authorized ) {
307 - $error_message = __( 'This sign-in link is no longer valid. Please try signing in again.', 'templately' );
308 - } elseif ( ! empty( $_GET['error'] ) ) {
268 + if ( ! empty( $_GET['error'] ) ) {
309 269 $error_message = sanitize_text_field( $_GET['error'] );
310 270 } elseif ( ! empty( $_GET['api_key'] ) ) {
311 271 $request = new \WP_REST_Request( 'POST', '/templately/v1/login' );
312 272 $request->set_param( 'viaAPI', true );
@@ -316,33 +276,15 @@
316 276 * @var Login $login
317 277 */
318 278 $login = Login::get_instance();
319 279 $login->permission_check( $request );
320 -
321 - // login() pins the write target to the acting user itself — no pin
322 - // here, or its finally would release ours mid-request.
323 280 $response = $login->login();
324 281
325 282 if ( ! is_wp_error( $response ) && ! empty( $response['user'] ) ) {
326 - $redirect_path = ! empty( $_GET['redirect-to'] ) ? sanitize_text_field( wp_unslash( $_GET['redirect-to'] ) ) : '';
283 + $redirect_path = ! empty( $_GET['redirect-to'] ) ? sanitize_text_field( $_GET['redirect-to'] ) : '';
284 +
327 285 if ( ! empty( $redirect_path ) ) {
328 - if ( filter_var( $redirect_path, FILTER_VALIDATE_URL ) ) {
329 - $redirect_url = $redirect_path;
330 - } else {
331 - $is_templately = strpos( $redirect_url, 'page=templately' ) !== false;
332 - $is_elementor = strpos( $redirect_url, 'action=elementor' ) !== false;
333 - // Gutenberg editor usually has action=edit or is a block editor page
334 - $is_gutenberg = ( strpos( $redirect_url, 'action=edit' ) !== false || strpos( $redirect_url, 'post_type=' ) !== false ) && ! $is_elementor;
335 -
336 - if ( $is_templately || $is_elementor || $is_gutenberg ) {
337 - $redirect_url = add_query_arg( 'path', ltrim( $redirect_path, '/' ), $redirect_url );
338 -
339 - // Always open the modal in editors after google login
340 - if ( $is_elementor || $is_gutenberg ) {
341 - $redirect_url = add_query_arg( 'templately_open_modal', '1', $redirect_url );
342 - }
343 - }
344 - }
286 + $redirect_url = add_query_arg( 'path', $redirect_path, $redirect_url );
345 287 }
346 288
347 289 wp_safe_redirect( $redirect_url );
348 290 exit;
@@ -353,10 +295,10 @@
353 295 $error_message = __( 'Missing API Key.', 'templately' );
354 296 }
355 297
356 298 $redirect_url = add_query_arg( [
357 - 'templately_error' => 'login_failed',
358 - 'error_message' => urlencode( $error_message ),
299 + 'path' => 'sign-in',
300 + 'error_message' => $error_message,
359 301 ], $redirect_url );
360 302
361 303 wp_safe_redirect( $redirect_url );
362 304 exit;