PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / 3.5.3
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! v3.5.3
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 +118 -1 3.0.93.5.3 View file →
@@ -9,8 +9,12 @@
9 9 */
10 10
11 11 namespace Templately;
12 12
13 +use Templately\Admin\API\Settings as APISettings;
14 +use Templately\Admin\Settings;
15 +use Templately\API\AIContent;
16 +use Templately\API\LogoGeneration;
13 17 use Templately\API\Conditions;
14 18 use Templately\API\ThemeBuilderApi;
15 19 use Templately\Builder\ThemeBuilder;
16 20 use Templately\Core\Importer\FullSiteImport;
@@ -31,8 +35,9 @@
31 35 use Templately\API\Categories;
32 36 use Templately\API\Dependencies;
33 37 use Templately\API\TemplateTypes;
34 38 use Templately\API\SavedTemplates;
39 +use Templately\API\Sites;
35 40 use Templately\Core\Maintenance;
36 41 use Templately\Core\Migrator;
37 42 use Templately\Core\Platform\Gutenberg;
38 43 use Templately\Core\Platform\Elementor;
@@ -37,11 +42,12 @@
37 42 use Templately\Core\Platform\Gutenberg;
38 43 use Templately\Core\Platform\Elementor;
39 44
40 45 final class Plugin extends Base {
41 - public $version = '3.0.9';
46 + public $version = '3.5.3';
42 47
43 48 public $admin;
49 + public $settings;
44 50 /**
45 51 * Enqueue class responsible for assets
46 52 * @var Enqueue
47 53 */
@@ -52,8 +58,13 @@
52 58 */
53 59 public $theme_builder;
54 60
55 61 /**
62 + * @var Developer
63 + */
64 + public $developer;
65 +
66 + /**
56 67 * Plugin constructor.
57 68 * Initializing Templately plugin.
58 69 *
59 70 * @access private
@@ -65,16 +76,24 @@
65 76 Maintenance::init();
66 77
67 78 $this->assets = Enqueue::get_instance( TEMPLATELY_URL, TEMPLATELY_PATH, $this->version );
68 79 $this->admin = Admin::get_instance();
80 + $this->settings = Settings::get_instance();
69 81 $this->theme_builder = ThemeBuilder::get_instance();
70 82
83 + // Initialize developer functionality if available
84 + $this->init_developer_functionality();
85 +
71 86 add_action( 'plugins_loaded', [ $this, 'plugins_loaded' ] );
72 87 add_action( 'rest_api_init', [ $this, 'register_routes' ] );
88 +
89 + add_action( 'init', [ $this, 'google_login_handler' ] );
90 +
73 91 /**
74 92 * Initialize.
75 93 */
76 94 do_action( 'templately_init' );
95 +
77 96 }
78 97
79 98 /**
80 99 * Cloning is forbidden.
@@ -113,8 +132,38 @@
113 132 FullSiteImport::get_instance();
114 133 }
115 134
116 135 /**
136 + * Initialize developer functionality if available
137 + *
138 + * This method safely loads developer functionality only if the developer
139 + * directory and class exist, preventing fatal errors in production builds.
140 + *
141 + * @return void
142 + */
143 + private function init_developer_functionality() {
144 + $developer_file = TEMPLATELY_PATH . 'includes/Core/Developer/Developer.php';
145 +
146 + // Check if developer file exists before attempting to load
147 + if ( file_exists( $developer_file ) ) {
148 + // Include the developer class file
149 + require_once $developer_file;
150 +
151 + // Check if the class exists after including the file
152 + if ( class_exists( '\\Templately\\Core\\Developer\\Developer' ) ) {
153 + $this->developer = \Templately\Core\Developer\Developer::get_instance();
154 + }
155 + }
156 +
157 + // If developer functionality is not available, set to null
158 + if ( ! isset( $this->developer ) ) {
159 + $this->developer = null;
160 + }
161 + }
162 +
163 +
164 +
165 + /**
117 166 * Initialize all platforms
118 167 * @return void
119 168 */
120 169 public function platforms() {
@@ -134,8 +183,10 @@
134 183 Dependencies::get_instance();
135 184 Tags::get_instance();
136 185 ThemeBuilderApi::get_instance();
137 186
187 + AIContent::get_instance();
188 + LogoGeneration::get_instance();
138 189 Items::get_instance();
139 190 SavedTemplates::get_instance();
140 191
141 192 Login::get_instance();
@@ -143,8 +194,12 @@
143 194 Import::get_instance();
144 195 Profile::get_instance();
145 196 MyClouds::get_instance();
146 197 WorkSpaces::get_instance();
198 + Sites::get_instance();
199 +
200 + APISettings::get_instance();
201 + // Note: DeveloperSettings::get_instance() is called in Developer::init_modules() when developer functionality is available and enabled
147 202 }
148 203
149 204 /**
150 205 * Register all REST API endpoints
@@ -203,6 +258,68 @@
203 258 *
204 259 */
205 260 public function load_textdomain() {
206 261 load_plugin_textdomain( 'templately', false, dirname( TEMPLATELY_PLUGIN_BASENAME ) . '/languages' );
262 + }
263 +
264 + public function google_login_handler() {
265 + // Stop if not a templately google login request
266 + if ( empty( $_GET['templately_google_login'] ) ) {
267 + return;
268 + }
269 +
270 + $redirect_url = remove_query_arg( [ 'templately_google_login', 'api_key', 'error', 'state', 'redirect-to' ] );
271 +
272 + if ( ! empty( $_GET['error'] ) ) {
273 + $error_message = sanitize_text_field( $_GET['error'] );
274 + } elseif ( ! empty( $_GET['api_key'] ) ) {
275 + $request = new \WP_REST_Request( 'POST', '/templately/v1/login' );
276 + $request->set_param( 'viaAPI', true );
277 + $request->set_param( 'api_key', sanitize_text_field( $_GET['api_key'] ) );
278 +
279 + /**
280 + * @var Login $login
281 + */
282 + $login = Login::get_instance();
283 + $login->permission_check( $request );
284 + $response = $login->login();
285 +
286 + if ( ! is_wp_error( $response ) && ! empty( $response['user'] ) ) {
287 + $redirect_path = ! empty( $_GET['redirect-to'] ) ? sanitize_text_field( wp_unslash( $_GET['redirect-to'] ) ) : '';
288 + if ( ! empty( $redirect_path ) ) {
289 + if ( filter_var( $redirect_path, FILTER_VALIDATE_URL ) ) {
290 + $redirect_url = $redirect_path;
291 + } else {
292 + $is_templately = strpos( $redirect_url, 'page=templately' ) !== false;
293 + $is_elementor = strpos( $redirect_url, 'action=elementor' ) !== false;
294 + // Gutenberg editor usually has action=edit or is a block editor page
295 + $is_gutenberg = ( strpos( $redirect_url, 'action=edit' ) !== false || strpos( $redirect_url, 'post_type=' ) !== false ) && ! $is_elementor;
296 +
297 + if ( $is_templately || $is_elementor || $is_gutenberg ) {
298 + $redirect_url = add_query_arg( 'path', ltrim( $redirect_path, '/' ), $redirect_url );
299 +
300 + // Always open the modal in editors after google login
301 + if ( $is_elementor || $is_gutenberg ) {
302 + $redirect_url = add_query_arg( 'templately_open_modal', '1', $redirect_url );
303 + }
304 + }
305 + }
306 + }
307 +
308 + wp_safe_redirect( $redirect_url );
309 + exit;
310 + } else {
311 + $error_message = ( is_wp_error( $response ) ) ? $response->get_error_message() : __( 'Login failed.', 'templately' );
312 + }
313 + } else {
314 + $error_message = __( 'Missing API Key.', 'templately' );
315 + }
316 +
317 + $redirect_url = add_query_arg( [
318 + 'templately_error' => 'login_failed',
319 + 'error_message' => urlencode( $error_message ),
320 + ], $redirect_url );
321 +
322 + wp_safe_redirect( $redirect_url );
323 + exit;
207 324 }
208 325 }