| @@ -12,15 +12,13 @@ | ||
| 12 | 12 | |
| 13 | 13 | use Templately\Admin\API\Settings as APISettings; |
| 14 | 14 | use Templately\Admin\Settings; |
| 15 | 15 | use Templately\API\AIContent; |
| 16 | -use Templately\API\LogoGeneration; | |
| 17 | 16 | use Templately\API\Conditions; |
| 18 | 17 | use Templately\API\ThemeBuilderApi; |
| 19 | 18 | use Templately\Builder\ThemeBuilder; |
| 20 | 19 | use Templately\Core\Importer\FullSiteImport; |
| 21 | 20 | use Templately\Utils\Base; |
| 22 | -use Templately\Utils\Database; | |
| 23 | 21 | use Templately\Utils\Enqueue; |
| 24 | 22 | |
| 25 | 23 | use Templately\Core\Admin; |
| 26 | 24 | use Templately\Core\Module; |
| @@ -27,9 +25,8 @@ | ||
| 27 | 25 | |
| 28 | 26 | use Templately\API\Tags; |
| 29 | 27 | use Templately\API\Items; |
| 30 | 28 | use Templately\API\Login; |
| 31 | -use Templately\API\Checkout; | |
| 32 | 29 | use Templately\API\SignUp; |
| 33 | 30 | use Templately\API\Profile; |
| 34 | 31 | use Templately\API\Import; |
| 35 | 32 | use Templately\API\MyClouds; |
| @@ -37,10 +34,8 @@ | ||
| 37 | 34 | use Templately\API\Categories; |
| 38 | 35 | use Templately\API\Dependencies; |
| 39 | 36 | use Templately\API\TemplateTypes; |
| 40 | 37 | use Templately\API\SavedTemplates; |
| 41 | -use Templately\API\Sites; | |
| 42 | -use Templately\API\Tour; | |
| 43 | 38 | use Templately\Core\Maintenance; |
| 44 | 39 | use Templately\Core\Migrator; |
| 45 | 40 | use Templately\Core\Platform\Gutenberg; |
| 46 | 41 | use Templately\Core\Platform\Elementor; |
| @@ -45,9 +40,9 @@ | ||
| 45 | 40 | use Templately\Core\Platform\Gutenberg; |
| 46 | 41 | use Templately\Core\Platform\Elementor; |
| 47 | 42 | |
| 48 | 43 | final class Plugin extends Base { |
| 49 | - public $version = '3.7.1'; | |
| 44 | + public $version = '3.4.6'; | |
| 50 | 45 | |
| 51 | 46 | public $admin; |
| 52 | 47 | public $settings; |
| 53 | 48 | /** |
| @@ -87,11 +82,8 @@ | ||
| 87 | 82 | $this->init_developer_functionality(); |
| 88 | 83 | |
| 89 | 84 | add_action( 'plugins_loaded', [ $this, 'plugins_loaded' ] ); |
| 90 | 85 | add_action( 'rest_api_init', [ $this, 'register_routes' ] ); |
| 91 | - | |
| 92 | - add_action( 'init', [ $this, 'google_login_handler' ] ); | |
| 93 | - | |
| 94 | 86 | /** |
| 95 | 87 | * Initialize. |
| 96 | 88 | */ |
| 97 | 89 | do_action( 'templately_init' ); |
| @@ -187,21 +179,17 @@ | ||
| 187 | 179 | Tags::get_instance(); |
| 188 | 180 | ThemeBuilderApi::get_instance(); |
| 189 | 181 | |
| 190 | 182 | AIContent::get_instance(); |
| 191 | - LogoGeneration::get_instance(); | |
| 192 | 183 | Items::get_instance(); |
| 193 | 184 | SavedTemplates::get_instance(); |
| 194 | 185 | |
| 195 | 186 | Login::get_instance(); |
| 196 | - Checkout::get_instance(); | |
| 197 | 187 | SignUp::get_instance(); |
| 198 | 188 | Import::get_instance(); |
| 199 | 189 | Profile::get_instance(); |
| 200 | 190 | MyClouds::get_instance(); |
| 201 | 191 | WorkSpaces::get_instance(); |
| 202 | - Sites::get_instance(); | |
| 203 | - Tour::get_instance(); | |
| 204 | 192 | |
| 205 | 193 | APISettings::get_instance(); |
| 206 | 194 | // Note: DeveloperSettings::get_instance() is called in Developer::init_modules() when developer functionality is available and enabled |
| 207 | 195 | } |
| @@ -263,102 +251,6 @@ | ||
| 263 | 251 | * |
| 264 | 252 | */ |
| 265 | 253 | public function load_textdomain() { |
| 266 | 254 | load_plugin_textdomain( 'templately', false, dirname( TEMPLATELY_PLUGIN_BASENAME ) . '/languages' ); |
| 267 | - } | |
| 268 | - | |
| 269 | - public function google_login_handler() { | |
| 270 | - // Stop if not a templately google login request | |
| 271 | - if ( empty( $_GET['templately_google_login'] ) ) { | |
| 272 | - return; | |
| 273 | - } | |
| 274 | - | |
| 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'] ) ) { | |
| 309 | - $error_message = sanitize_text_field( $_GET['error'] ); | |
| 310 | - } elseif ( ! empty( $_GET['api_key'] ) ) { | |
| 311 | - $request = new \WP_REST_Request( 'POST', '/templately/v1/login' ); | |
| 312 | - $request->set_param( 'viaAPI', true ); | |
| 313 | - $request->set_param( 'api_key', sanitize_text_field( $_GET['api_key'] ) ); | |
| 314 | - | |
| 315 | - /** | |
| 316 | - * @var Login $login | |
| 317 | - */ | |
| 318 | - $login = Login::get_instance(); | |
| 319 | - $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 | - $response = $login->login(); | |
| 324 | - | |
| 325 | - if ( ! is_wp_error( $response ) && ! empty( $response['user'] ) ) { | |
| 326 | - $redirect_path = ! empty( $_GET['redirect-to'] ) ? sanitize_text_field( wp_unslash( $_GET['redirect-to'] ) ) : ''; | |
| 327 | - 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 | - } | |
| 345 | - } | |
| 346 | - | |
| 347 | - wp_safe_redirect( $redirect_url ); | |
| 348 | - exit; | |
| 349 | - } else { | |
| 350 | - $error_message = ( is_wp_error( $response ) ) ? $response->get_error_message() : __( 'Login failed.', 'templately' ); | |
| 351 | - } | |
| 352 | - } else { | |
| 353 | - $error_message = __( 'Missing API Key.', 'templately' ); | |
| 354 | - } | |
| 355 | - | |
| 356 | - $redirect_url = add_query_arg( [ | |
| 357 | - 'templately_error' => 'login_failed', | |
| 358 | - 'error_message' => urlencode( $error_message ), | |
| 359 | - ], $redirect_url ); | |
| 360 | - | |
| 361 | - wp_safe_redirect( $redirect_url ); | |
| 362 | - exit; | |
| 363 | 255 | } |
| 364 | 256 | } |