Template Kit – Import - Version 1.0.11

Version Description

  • 2021-02-02 =
  • Feature: Support for Elementor Landing Page templates
  • Feature: Elementor compatibility check
Download this release

Release Info

Developer dtbaker
Plugin Icon 128x128 Template Kit – Import
Version 1.0.11
Comparing to
See all releases

Code changes from version 1.0.10 to 1.0.11

inc/api/class-api.php CHANGED
@@ -32,18 +32,18 @@ abstract class API extends Base {
32
  return current_user_can( 'edit_posts' );
33
  }
34
 
35
- public function register_endpoint( $endpoint, $callback ){
36
  register_rest_route(
37
  ENVATO_TEMPLATE_KIT_IMPORT_API_NAMESPACE,
38
  $endpoint,
39
- [
40
- [
41
  'methods' => \WP_REST_Server::CREATABLE,
42
  'callback' => $callback,
43
- 'permission_callback' => [ $this, 'rest_permission_check' ],
44
- 'args' => [],
45
- ],
46
- ]
47
  );
48
  }
49
 
@@ -52,7 +52,7 @@ abstract class API extends Base {
52
  *
53
  * @return \WP_REST_Response
54
  */
55
- public function format_success($data) {
56
  return new \WP_REST_Response( $data, 200 );
57
  }
58
 
@@ -60,18 +60,21 @@ abstract class API extends Base {
60
  * @param $endpoint
61
  * @param $error_code
62
  * @param $error_message
63
- * @param array $additional_data
64
  *
65
  * @return \WP_REST_Response
66
  */
67
- public function format_error($endpoint, $error_code, $error_message, $additional_data = []){
68
- return new \WP_REST_Response( [
69
- 'error' => [
70
- 'context' => $endpoint,
71
- 'code' => $error_code,
72
- 'message' => $error_message,
73
- 'data' => $additional_data,
74
- ]
75
- ], 500 );
 
 
 
76
  }
77
  }
32
  return current_user_can( 'edit_posts' );
33
  }
34
 
35
+ public function register_endpoint( $endpoint, $callback ) {
36
  register_rest_route(
37
  ENVATO_TEMPLATE_KIT_IMPORT_API_NAMESPACE,
38
  $endpoint,
39
+ array(
40
+ array(
41
  'methods' => \WP_REST_Server::CREATABLE,
42
  'callback' => $callback,
43
+ 'permission_callback' => array( $this, 'rest_permission_check' ),
44
+ 'args' => array(),
45
+ ),
46
+ )
47
  );
48
  }
49
 
52
  *
53
  * @return \WP_REST_Response
54
  */
55
+ public function format_success( $data ) {
56
  return new \WP_REST_Response( $data, 200 );
57
  }
58
 
60
  * @param $endpoint
61
  * @param $error_code
62
  * @param $error_message
63
+ * @param array $additional_data
64
  *
65
  * @return \WP_REST_Response
66
  */
67
+ public function format_error( $endpoint, $error_code, $error_message, $additional_data = array() ) {
68
+ return new \WP_REST_Response(
69
+ array(
70
+ 'error' => array(
71
+ 'context' => $endpoint,
72
+ 'code' => $error_code,
73
+ 'message' => $error_message,
74
+ 'data' => $additional_data,
75
+ ),
76
+ ),
77
+ 500
78
+ );
79
  }
80
  }
inc/api/class-requirements.php CHANGED
@@ -44,10 +44,10 @@ class Requirements extends API {
44
  );
45
  }
46
 
47
- $settings_allowlist = [
48
  'elementor_disable_color_schemes' => 'yes',
49
  'elementor_disable_typography_schemes' => 'yes',
50
- ];
51
 
52
  $setting_name = $requirement['setting']['setting_name'];
53
 
@@ -57,9 +57,11 @@ class Requirements extends API {
57
  update_option( $setting_name, $settings_allowlist[ $setting_name ] );
58
 
59
  // Tell our front end it worked:
60
- return $this->format_success( [
61
- 'success' => $setting_name
62
- ] );
 
 
63
  } else {
64
  // If our front end tries to set a not allowed setting we return an error.
65
  return $this->format_error(
@@ -68,7 +70,6 @@ class Requirements extends API {
68
  'This setting is not allowed.'
69
  );
70
  }
71
-
72
  }
73
 
74
  if ( ! empty( $requirement ) && ! empty( $requirement['plugin'] ) ) {
@@ -88,9 +89,9 @@ class Requirements extends API {
88
  'installRequirement',
89
  'install_failed',
90
  'Please purchase Elementor Pro from here first',
91
- [
92
- 'url' => 'https://elementor.com/pro/?ref=2837'
93
- ]
94
  );
95
  }
96
 
@@ -103,9 +104,11 @@ class Requirements extends API {
103
  );
104
  }
105
 
106
- return $this->format_success( [
107
- 'success' => $plugin_slug
108
- ] );
 
 
109
  }
110
 
111
  if ( ! empty( $requirement ) && ! empty( $requirement['theme'] ) ) {
@@ -152,9 +155,11 @@ class Requirements extends API {
152
 
153
  switch_theme( $theme->get_stylesheet() );
154
 
155
- return $this->format_success( [
156
- 'success' => 'theme'
157
- ] );
 
 
158
  }
159
 
160
  if ( ! empty( $requirement ) && ! empty( $requirement['requiredCss'] ) ) {
@@ -173,13 +178,15 @@ class Requirements extends API {
173
 
174
  try {
175
  Template_Kits::get_instance()->install_custom_css_into_customizer( $template_kit_id, $css_filename );
176
- }catch (\Exception $e){
177
 
178
  }
179
 
180
- return $this->format_success( [
181
- 'success' => 'customCss'
182
- ] );
 
 
183
  }
184
 
185
  return $this->format_error(
@@ -191,10 +198,10 @@ class Requirements extends API {
191
 
192
  private function install_plugin( $plugin_details ) {
193
 
194
- require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
195
- require_once( ABSPATH . 'wp-admin/includes/file.php' );
196
- require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
197
- include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
198
 
199
  $all_plugins = get_plugins();
200
 
@@ -211,9 +218,9 @@ class Requirements extends API {
211
 
212
  } else {
213
 
214
- $status = [
215
  'success' => false,
216
- ];
217
 
218
  $api = plugins_api(
219
  'plugin_information',
@@ -301,10 +308,10 @@ class Requirements extends API {
301
  return $status;
302
  }
303
 
304
- require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
305
- include_once( ABSPATH . 'wp-admin/includes/theme.php' );
306
- require_once( ABSPATH . 'wp-admin/includes/file.php' );
307
- include_once( ABSPATH . 'wp-admin/includes/theme-install.php' );
308
 
309
  $api = themes_api(
310
  'theme_information',
@@ -360,6 +367,6 @@ class Requirements extends API {
360
  }
361
 
362
  public function register_api_endpoints() {
363
- $this->register_endpoint( 'installRequirement', [ $this, 'install_requirement' ] );
364
  }
365
  }
44
  );
45
  }
46
 
47
+ $settings_allowlist = array(
48
  'elementor_disable_color_schemes' => 'yes',
49
  'elementor_disable_typography_schemes' => 'yes',
50
+ );
51
 
52
  $setting_name = $requirement['setting']['setting_name'];
53
 
57
  update_option( $setting_name, $settings_allowlist[ $setting_name ] );
58
 
59
  // Tell our front end it worked:
60
+ return $this->format_success(
61
+ array(
62
+ 'success' => $setting_name,
63
+ )
64
+ );
65
  } else {
66
  // If our front end tries to set a not allowed setting we return an error.
67
  return $this->format_error(
70
  'This setting is not allowed.'
71
  );
72
  }
 
73
  }
74
 
75
  if ( ! empty( $requirement ) && ! empty( $requirement['plugin'] ) ) {
89
  'installRequirement',
90
  'install_failed',
91
  'Please purchase Elementor Pro from here first',
92
+ array(
93
+ 'url' => 'https://elementor.com/pro/?ref=2837',
94
+ )
95
  );
96
  }
97
 
104
  );
105
  }
106
 
107
+ return $this->format_success(
108
+ array(
109
+ 'success' => $plugin_slug,
110
+ )
111
+ );
112
  }
113
 
114
  if ( ! empty( $requirement ) && ! empty( $requirement['theme'] ) ) {
155
 
156
  switch_theme( $theme->get_stylesheet() );
157
 
158
+ return $this->format_success(
159
+ array(
160
+ 'success' => 'theme',
161
+ )
162
+ );
163
  }
164
 
165
  if ( ! empty( $requirement ) && ! empty( $requirement['requiredCss'] ) ) {
178
 
179
  try {
180
  Template_Kits::get_instance()->install_custom_css_into_customizer( $template_kit_id, $css_filename );
181
+ } catch ( \Exception $e ) {
182
 
183
  }
184
 
185
+ return $this->format_success(
186
+ array(
187
+ 'success' => 'customCss',
188
+ )
189
+ );
190
  }
191
 
192
  return $this->format_error(
198
 
199
  private function install_plugin( $plugin_details ) {
200
 
201
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
202
+ require_once ABSPATH . 'wp-admin/includes/file.php';
203
+ require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
204
+ include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
205
 
206
  $all_plugins = get_plugins();
207
 
218
 
219
  } else {
220
 
221
+ $status = array(
222
  'success' => false,
223
+ );
224
 
225
  $api = plugins_api(
226
  'plugin_information',
308
  return $status;
309
  }
310
 
311
+ require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
312
+ include_once ABSPATH . 'wp-admin/includes/theme.php';
313
+ require_once ABSPATH . 'wp-admin/includes/file.php';
314
+ include_once ABSPATH . 'wp-admin/includes/theme-install.php';
315
 
316
  $api = themes_api(
317
  'theme_information',
367
  }
368
 
369
  public function register_api_endpoints() {
370
+ $this->register_endpoint( 'installRequirement', array( $this, 'install_requirement' ) );
371
  }
372
  }
inc/api/class-template-kit-import.php CHANGED
@@ -45,12 +45,12 @@ class Template_Kit_Import extends API {
45
  $template_kit_id = $request->get_param( 'id' );
46
  if ( $template_kit_id === 'all' ) {
47
  // User is requesting templates from all kits.
48
- $all_template_data = [
49
  'id' => 'all',
50
  'title' => 'All Installed Kits',
51
- 'requirements' => [],
52
- 'templates' => [],
53
- ];
54
  $installed_kits = Template_Kits::get_instance()->get_installed_template_kits();
55
  foreach ( $installed_kits as $installed_kit ) {
56
  $installed_kit_data = Template_Kits::get_instance()->get_installed_template_kit( $installed_kit['id'] );
@@ -73,12 +73,13 @@ class Template_Kit_Import extends API {
73
 
74
  // Now we split the template data into groups.
75
  // This list of templates come from the "Template Kit Export" plugin:
76
- $template_types = [
77
  'single-page' => __( 'Single: Page', 'template-kit-export' ),
78
  'single-home' => __( 'Single: Home', 'template-kit-export' ),
79
  'single-post' => __( 'Single: Post', 'template-kit-export' ),
80
  'single-product' => __( 'Single: Product', 'template-kit-export' ),
81
  'single-404' => __( 'Single: 404', 'template-kit-export' ),
 
82
  'archive-blog' => __( 'Archive: Blog', 'template-kit-export' ),
83
  'archive-product' => __( 'Archive: Product', 'template-kit-export' ),
84
  'archive-search' => __( 'Archive: Search', 'template-kit-export' ),
@@ -105,17 +106,17 @@ class Template_Kit_Import extends API {
105
  'section-logo-grid' => __( 'Logo Grid', 'template-kit-export' ),
106
  'section-clients' => __( 'Clients', 'template-kit-export' ),
107
  'section-other' => __( 'Other', 'template-kit-export' ),
108
- ];
109
 
110
- $templates_grouped = [];
111
  foreach ( $all_template_data['templates'] as $template_id => $template ) {
112
  $template_group = ! empty( $template['metadata'] ) && ! empty( $template['metadata']['template_type'] ) ? $template['metadata']['template_type'] : false;
113
  if ( $template_group ) {
114
  if ( ! isset( $templates_grouped[ $template_group ] ) ) {
115
- $templates_grouped[ $template_group ] = [
116
  'title' => isset( $template_types[ $template_group ] ) ? $template_types[ $template_group ] : $template_group,
117
- 'templates' => [],
118
- ];
119
  }
120
  $templates_grouped[ $template_group ]['templates'][] = $template;
121
  } else {
@@ -128,23 +129,23 @@ class Template_Kit_Import extends API {
128
 
129
  // We report any missing default settings that are required for template kits.
130
  if ( ! isset( $all_template_data['requirements']['settings'] ) ) {
131
- $all_template_data['requirements']['settings'] = [];
132
  }
133
  // Check Elementor default colors and fonts are set.
134
  // Elementor stores the string 'yes' in the WordPress database if these options are active, and an empty string if these options are not active.
135
  $is_elementor_color_schemes_disabled_already = get_option( 'elementor_disable_color_schemes' );
136
  $is_elementor_typography_schemes_disabled_already = get_option( 'elementor_disable_typography_schemes' );
137
  if ( $is_elementor_color_schemes_disabled_already !== 'yes' ) {
138
- $all_template_data['requirements']['settings'][] = [
139
  'name' => 'Elementor default color schemes',
140
- 'setting_name' => 'elementor_disable_color_schemes'
141
- ];
142
  }
143
  if ( $is_elementor_typography_schemes_disabled_already !== 'yes' ) {
144
- $all_template_data['requirements']['settings'][] = [
145
  'name' => 'Elementor default typography schemes',
146
- 'setting_name' => 'elementor_disable_typography_schemes'
147
- ];
148
  }
149
 
150
  return $this->format_success( $all_template_data );
@@ -179,11 +180,14 @@ class Template_Kit_Import extends API {
179
  $db = \Elementor\Plugin::$instance->db;
180
  $content = $db->get_builder( $imported_template_data['imported_template_id'] );
181
  if ( ! empty( $content ) ) {
182
- $content = \Elementor\Plugin::$instance->db->iterate_data( $content, function ( $element ) {
183
- $element['id'] = \Elementor\Utils::generate_random_string();
184
-
185
- return $element;
186
- } );
 
 
 
187
  }
188
  $imported_template_data['content'] = $content;
189
  }
@@ -225,9 +229,11 @@ class Template_Kit_Import extends API {
225
  $template_data_to_return['template_kit_name'] = $template_kit_data['title'];
226
  }
227
 
228
- return $this->format_success( [
229
- 'template_data' => $template_data_to_return
230
- ] );
 
 
231
  } catch ( \Exception $e ) {
232
  return $this->format_error(
233
  'getSingleTemplateImportData',
@@ -277,9 +283,9 @@ class Template_Kit_Import extends API {
277
  try {
278
 
279
  // Core WP image handling classes:
280
- require_once( ABSPATH . '/wp-admin/includes/file.php' );
281
- require_once( ABSPATH . '/wp-admin/includes/media.php' );
282
- require_once( ABSPATH . '/wp-admin/includes/image.php' );
283
 
284
  // Elementor doesn't check if an image exists, it just imports
285
  // HTML as an image from a 404 page. Lets try to avoid that.
@@ -294,10 +300,12 @@ class Template_Kit_Import extends API {
294
  }
295
 
296
  // Reach into the Elementor plugin to use their image handling code.
297
- $attachment = \Elementor\Plugin::$instance->templates_manager->get_import_images_instance()->import( [
298
- 'id' => $image_id,
299
- 'url' => $image_url,
300
- ] );
 
 
301
 
302
  if ( $attachment && ! is_wp_error( $attachment ) ) {
303
  return $this->format_success( $attachment );
@@ -306,13 +314,12 @@ class Template_Kit_Import extends API {
306
  wp_remote_head( $error_url . '?kit=' . urlencode( $kit_name ) . '&image=' . urlencode( $image_url ) );
307
 
308
  return $this->format_success(
309
- [
310
  'id' => 1,
311
- 'message' => 'Failed to import the image: ' . $image_url
312
- ]
313
  );
314
  }
315
-
316
  } catch ( \Exception $e ) {
317
  return $this->format_error(
318
  'importElementorTemplateImage',
@@ -323,10 +330,10 @@ class Template_Kit_Import extends API {
323
  }
324
 
325
  public function register_api_endpoints() {
326
- $this->register_endpoint( 'fetchInstalledTemplateKits', [ $this, 'fetch_all_installed_template_kits' ] );
327
- $this->register_endpoint( 'fetchIndividualTemplates', [ $this, 'fetch_individual_templates' ] );
328
- $this->register_endpoint( 'importSingleTemplate', [ $this, 'import_single_template' ] );
329
- $this->register_endpoint( 'getSingleTemplateImportData', [ $this, 'get_single_template_for_import' ] );
330
- $this->register_endpoint( 'importElementorTemplateImage', [ $this, 'import_elementor_template_image' ] );
331
  }
332
  }
45
  $template_kit_id = $request->get_param( 'id' );
46
  if ( $template_kit_id === 'all' ) {
47
  // User is requesting templates from all kits.
48
+ $all_template_data = array(
49
  'id' => 'all',
50
  'title' => 'All Installed Kits',
51
+ 'requirements' => array(),
52
+ 'templates' => array(),
53
+ );
54
  $installed_kits = Template_Kits::get_instance()->get_installed_template_kits();
55
  foreach ( $installed_kits as $installed_kit ) {
56
  $installed_kit_data = Template_Kits::get_instance()->get_installed_template_kit( $installed_kit['id'] );
73
 
74
  // Now we split the template data into groups.
75
  // This list of templates come from the "Template Kit Export" plugin:
76
+ $template_types = array(
77
  'single-page' => __( 'Single: Page', 'template-kit-export' ),
78
  'single-home' => __( 'Single: Home', 'template-kit-export' ),
79
  'single-post' => __( 'Single: Post', 'template-kit-export' ),
80
  'single-product' => __( 'Single: Product', 'template-kit-export' ),
81
  'single-404' => __( 'Single: 404', 'template-kit-export' ),
82
+ 'landing-page' => __( 'Single: Landing Page', 'template-kit-export' ),
83
  'archive-blog' => __( 'Archive: Blog', 'template-kit-export' ),
84
  'archive-product' => __( 'Archive: Product', 'template-kit-export' ),
85
  'archive-search' => __( 'Archive: Search', 'template-kit-export' ),
106
  'section-logo-grid' => __( 'Logo Grid', 'template-kit-export' ),
107
  'section-clients' => __( 'Clients', 'template-kit-export' ),
108
  'section-other' => __( 'Other', 'template-kit-export' ),
109
+ );
110
 
111
+ $templates_grouped = array();
112
  foreach ( $all_template_data['templates'] as $template_id => $template ) {
113
  $template_group = ! empty( $template['metadata'] ) && ! empty( $template['metadata']['template_type'] ) ? $template['metadata']['template_type'] : false;
114
  if ( $template_group ) {
115
  if ( ! isset( $templates_grouped[ $template_group ] ) ) {
116
+ $templates_grouped[ $template_group ] = array(
117
  'title' => isset( $template_types[ $template_group ] ) ? $template_types[ $template_group ] : $template_group,
118
+ 'templates' => array(),
119
+ );
120
  }
121
  $templates_grouped[ $template_group ]['templates'][] = $template;
122
  } else {
129
 
130
  // We report any missing default settings that are required for template kits.
131
  if ( ! isset( $all_template_data['requirements']['settings'] ) ) {
132
+ $all_template_data['requirements']['settings'] = array();
133
  }
134
  // Check Elementor default colors and fonts are set.
135
  // Elementor stores the string 'yes' in the WordPress database if these options are active, and an empty string if these options are not active.
136
  $is_elementor_color_schemes_disabled_already = get_option( 'elementor_disable_color_schemes' );
137
  $is_elementor_typography_schemes_disabled_already = get_option( 'elementor_disable_typography_schemes' );
138
  if ( $is_elementor_color_schemes_disabled_already !== 'yes' ) {
139
+ $all_template_data['requirements']['settings'][] = array(
140
  'name' => 'Elementor default color schemes',
141
+ 'setting_name' => 'elementor_disable_color_schemes',
142
+ );
143
  }
144
  if ( $is_elementor_typography_schemes_disabled_already !== 'yes' ) {
145
+ $all_template_data['requirements']['settings'][] = array(
146
  'name' => 'Elementor default typography schemes',
147
+ 'setting_name' => 'elementor_disable_typography_schemes',
148
+ );
149
  }
150
 
151
  return $this->format_success( $all_template_data );
180
  $db = \Elementor\Plugin::$instance->db;
181
  $content = $db->get_builder( $imported_template_data['imported_template_id'] );
182
  if ( ! empty( $content ) ) {
183
+ $content = \Elementor\Plugin::$instance->db->iterate_data(
184
+ $content,
185
+ function ( $element ) {
186
+ $element['id'] = \Elementor\Utils::generate_random_string();
187
+
188
+ return $element;
189
+ }
190
+ );
191
  }
192
  $imported_template_data['content'] = $content;
193
  }
229
  $template_data_to_return['template_kit_name'] = $template_kit_data['title'];
230
  }
231
 
232
+ return $this->format_success(
233
+ array(
234
+ 'template_data' => $template_data_to_return,
235
+ )
236
+ );
237
  } catch ( \Exception $e ) {
238
  return $this->format_error(
239
  'getSingleTemplateImportData',
283
  try {
284
 
285
  // Core WP image handling classes:
286
+ require_once ABSPATH . '/wp-admin/includes/file.php';
287
+ require_once ABSPATH . '/wp-admin/includes/media.php';
288
+ require_once ABSPATH . '/wp-admin/includes/image.php';
289
 
290
  // Elementor doesn't check if an image exists, it just imports
291
  // HTML as an image from a 404 page. Lets try to avoid that.
300
  }
301
 
302
  // Reach into the Elementor plugin to use their image handling code.
303
+ $attachment = \Elementor\Plugin::$instance->templates_manager->get_import_images_instance()->import(
304
+ array(
305
+ 'id' => $image_id,
306
+ 'url' => $image_url,
307
+ )
308
+ );
309
 
310
  if ( $attachment && ! is_wp_error( $attachment ) ) {
311
  return $this->format_success( $attachment );
314
  wp_remote_head( $error_url . '?kit=' . urlencode( $kit_name ) . '&image=' . urlencode( $image_url ) );
315
 
316
  return $this->format_success(
317
+ array(
318
  'id' => 1,
319
+ 'message' => 'Failed to import the image: ' . $image_url,
320
+ )
321
  );
322
  }
 
323
  } catch ( \Exception $e ) {
324
  return $this->format_error(
325
  'importElementorTemplateImage',
330
  }
331
 
332
  public function register_api_endpoints() {
333
+ $this->register_endpoint( 'fetchInstalledTemplateKits', array( $this, 'fetch_all_installed_template_kits' ) );
334
+ $this->register_endpoint( 'fetchIndividualTemplates', array( $this, 'fetch_individual_templates' ) );
335
+ $this->register_endpoint( 'importSingleTemplate', array( $this, 'import_single_template' ) );
336
+ $this->register_endpoint( 'getSingleTemplateImportData', array( $this, 'get_single_template_for_import' ) );
337
+ $this->register_endpoint( 'importElementorTemplateImage', array( $this, 'import_elementor_template_image' ) );
338
  }
339
  }
inc/api/class-template-kit-install.php CHANGED
@@ -49,10 +49,12 @@ class Template_Kit_Install extends API {
49
  }
50
 
51
  // If we get here we assume the kit installed correctly.
52
- return $this->format_success( [
53
- 'templateKitId' => $error_or_template_kit_id,
54
- 'message' => 'Zip installed successfully'
55
- ] );
 
 
56
  }
57
  }
58
 
@@ -80,7 +82,7 @@ class Template_Kit_Install extends API {
80
  }
81
 
82
  public function register_api_endpoints() {
83
- $this->register_endpoint( 'uploadTemplateKitZipFile', [ $this, 'upload_template_kit_zip_file' ] );
84
- $this->register_endpoint( 'deleteTemplateKit', [ $this, 'delete_template_kit' ] );
85
  }
86
  }
49
  }
50
 
51
  // If we get here we assume the kit installed correctly.
52
+ return $this->format_success(
53
+ array(
54
+ 'templateKitId' => $error_or_template_kit_id,
55
+ 'message' => 'Zip installed successfully',
56
+ )
57
+ );
58
  }
59
  }
60
 
82
  }
83
 
84
  public function register_api_endpoints() {
85
+ $this->register_endpoint( 'uploadTemplateKitZipFile', array( $this, 'upload_template_kit_zip_file' ) );
86
+ $this->register_endpoint( 'deleteTemplateKit', array( $this, 'delete_template_kit' ) );
87
  }
88
  }
inc/backend/class-elementor-modal.php CHANGED
@@ -29,7 +29,7 @@ class Elementor_Modal extends Base {
29
  // This is for the outer Elementor editor, we need JS to add our magic button and register onclick events etc..
30
  add_action( 'elementor/editor/before_enqueue_scripts', array( $this, 'enqueue_editor_scripts' ) );
31
  // This is for the inner iframe, we only need CSS in this inner iframe:
32
- add_action( 'elementor/preview/enqueue_styles', [ $this, 'enqueue_embedded_iframe_styles' ] );
33
  }
34
 
35
  /**
@@ -43,9 +43,9 @@ class Elementor_Modal extends Base {
43
  wp_enqueue_script( 'elements-elementor-modal', ENVATO_TEMPLATE_KIT_IMPORT_URI . 'assets/elementor_modal.js', array( 'jquery' ), ENVATO_TEMPLATE_KIT_IMPORT_VER );
44
  }
45
 
46
- public function enqueue_embedded_iframe_styles(){
47
- wp_enqueue_style( 'template-kit-import-admin', ENVATO_TEMPLATE_KIT_IMPORT_URI . 'assets/main.css', [], filemtime( ENVATO_TEMPLATE_KIT_IMPORT_DIR . 'assets/main.css' ) );
48
- wp_enqueue_style( 'elements-elementor-modal', ENVATO_TEMPLATE_KIT_IMPORT_URI . 'assets/elementor_modal.css', [], ENVATO_TEMPLATE_KIT_IMPORT_VER );
49
  }
50
 
51
  }
29
  // This is for the outer Elementor editor, we need JS to add our magic button and register onclick events etc..
30
  add_action( 'elementor/editor/before_enqueue_scripts', array( $this, 'enqueue_editor_scripts' ) );
31
  // This is for the inner iframe, we only need CSS in this inner iframe:
32
+ add_action( 'elementor/preview/enqueue_styles', array( $this, 'enqueue_embedded_iframe_styles' ) );
33
  }
34
 
35
  /**
43
  wp_enqueue_script( 'elements-elementor-modal', ENVATO_TEMPLATE_KIT_IMPORT_URI . 'assets/elementor_modal.js', array( 'jquery' ), ENVATO_TEMPLATE_KIT_IMPORT_VER );
44
  }
45
 
46
+ public function enqueue_embedded_iframe_styles() {
47
+ wp_enqueue_style( 'template-kit-import-admin', ENVATO_TEMPLATE_KIT_IMPORT_URI . 'assets/main.css', array(), filemtime( ENVATO_TEMPLATE_KIT_IMPORT_DIR . 'assets/main.css' ) );
48
+ wp_enqueue_style( 'elements-elementor-modal', ENVATO_TEMPLATE_KIT_IMPORT_URI . 'assets/elementor_modal.css', array(), ENVATO_TEMPLATE_KIT_IMPORT_VER );
49
  }
50
 
51
  }
inc/backend/class-options.php CHANGED
@@ -28,8 +28,8 @@ class Options extends Base {
28
 
29
  public function __construct() {
30
  add_action( 'admin_head', array( $this, 'print_admin_env_vars' ) );
31
- add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'print_admin_env_vars' ] );
32
- add_action( 'elementor/preview/enqueue_styles', [ $this, 'print_admin_env_vars' ] );
33
  }
34
 
35
  /**
@@ -38,13 +38,13 @@ class Options extends Base {
38
  public function print_admin_env_vars() {
39
  $admin_options = array(
40
  'api_nonce' => wp_create_nonce( 'wp_rest' ),
41
- //'api_url' => admin_url( 'admin-ajax.php?action=template_kit_import&endpoint=' ),
42
  'api_url' => get_rest_url() . 'template-kit-import/v2/',
43
  'review_mode' => defined( 'ENVATO_TEMPLATE_KIT_IMPORT_DEV' ) && ENVATO_TEMPLATE_KIT_IMPORT_DEV,
44
  );
45
  ?>
46
  <script>
47
- var template_kit_import = <?php echo json_encode( $admin_options ); ?>;
48
  </script>
49
  <?php
50
  }
@@ -93,7 +93,7 @@ class Options extends Base {
93
  $options = get_option( self::OPTION_KEY, array() );
94
  $user_id = get_current_user_id();
95
  if ( $user_id ) {
96
- $options[ $user_id ] = [];
97
  update_option( self::OPTION_KEY, $options );
98
  }
99
  }
28
 
29
  public function __construct() {
30
  add_action( 'admin_head', array( $this, 'print_admin_env_vars' ) );
31
+ add_action( 'elementor/editor/before_enqueue_scripts', array( $this, 'print_admin_env_vars' ) );
32
+ add_action( 'elementor/preview/enqueue_styles', array( $this, 'print_admin_env_vars' ) );
33
  }
34
 
35
  /**
38
  public function print_admin_env_vars() {
39
  $admin_options = array(
40
  'api_nonce' => wp_create_nonce( 'wp_rest' ),
41
+ // 'api_url' => admin_url( 'admin-ajax.php?action=template_kit_import&endpoint=' ),
42
  'api_url' => get_rest_url() . 'template-kit-import/v2/',
43
  'review_mode' => defined( 'ENVATO_TEMPLATE_KIT_IMPORT_DEV' ) && ENVATO_TEMPLATE_KIT_IMPORT_DEV,
44
  );
45
  ?>
46
  <script>
47
+ var template_kit_import = <?php echo json_encode( $admin_options ); ?>;
48
  </script>
49
  <?php
50
  }
93
  $options = get_option( self::OPTION_KEY, array() );
94
  $user_id = get_current_user_id();
95
  if ( $user_id ) {
96
+ $options[ $user_id ] = array();
97
  update_option( self::OPTION_KEY, $options );
98
  }
99
  }
inc/backend/class-rest.php CHANGED
@@ -35,9 +35,9 @@ class REST extends Base {
35
  * @since 0.0.2
36
  */
37
  public function __construct() {
38
- add_action( 'rest_api_init', [ $this, 'register_routes' ] );
39
  // We also add admin-ajax because the REST API is unsuitable for a lot of hosts.
40
- add_action( 'wp_ajax_template_kit_import', [ $this, 'ajax_handler' ] );
41
  }
42
 
43
  /**
35
  * @since 0.0.2
36
  */
37
  public function __construct() {
38
+ add_action( 'rest_api_init', array( $this, 'register_routes' ) );
39
  // We also add admin-ajax because the REST API is unsuitable for a lot of hosts.
40
+ add_action( 'wp_ajax_template_kit_import', array( $this, 'ajax_handler' ) );
41
  }
42
 
43
  /**
inc/backend/class-template-kits.php CHANGED
@@ -78,7 +78,7 @@ class Template_Kits extends Base {
78
  $this->load_template_kit_library();
79
  // Reach into our included Template Kit import plugin functions to do the actual import.
80
  $uploaded_kits = \Envato_Template_Kit_Import\CPT_Kits::get_instance()->get_all_uploaded_kits();
81
- $installed_kits = [];
82
  try {
83
  foreach ( $uploaded_kits as $template_kit ) {
84
  $template_kit_id = $template_kit->ID;
@@ -87,13 +87,13 @@ class Template_Kits extends Base {
87
  if ( $template_kit_manager ) {
88
  // Grab a list of templates from this kit, so we can use the first one as a screenshot url:
89
  $template_kit_templates = $template_kit_manager->get_available_templates();
90
- $installed_kits[] = [
91
  'id' => $template_kit_id,
92
  'screenshot_url' => $template_kit_templates[0]['screenshot_url'],
93
  'title' => $template_kit->post_title,
94
  'template_count' => count( $template_kit_templates ),
95
  'uploaded' => date_i18n( 'F j, Y g:i:a', strtotime( $template_kit->post_date ) ),
96
- ];
97
  }
98
  }
99
  } catch ( \Exception $e ) {
@@ -120,16 +120,16 @@ class Template_Kits extends Base {
120
  }
121
 
122
  // Start building up template kit response
123
- $template_kit_data = [
124
  'id' => $template_kit_id,
125
  'title' => $template_kit->get_name(),
126
- 'requirements' => [
127
  'theme' => $template_kit->get_required_theme(),
128
  'plugins' => $template_kit->get_required_plugins(),
129
  'css' => $template_kit->get_required_css(),
130
- ],
131
- 'templates' => [],
132
- ];
133
 
134
  // Loop over available templates and include any additional data we might need in the UI:
135
  foreach ( $template_kit->get_available_templates() as $template_id => $template ) {
@@ -154,7 +154,7 @@ class Template_Kits extends Base {
154
  public function import_single_template( $template_kit_id, $template_id, $import_again ) {
155
  $this->load_template_kit_library();
156
 
157
- include_once( ABSPATH . 'wp-admin/includes/image.php' );
158
 
159
  $template_kit = \Envato_Template_Kit_Import\envato_template_kit_import_get_builder( $template_kit_id );
160
  if ( ! $template_kit ) {
@@ -163,27 +163,27 @@ class Template_Kits extends Base {
163
 
164
  // If the user wants to import the template again, we don't check for duplicates.
165
  if ( ! $import_again ) {
166
- $template_kit_data = $this->get_installed_template_kit( $template_kit_id );
167
-
168
- if ( ! empty( $template_kit_data['templates'] ) && ! empty( $template_kit_data['templates'][ $template_id ] ) ) {
169
- // We've found a matching template for this template kit
170
-
171
- // Check if we've already imported this template:
172
- if ( ! empty( $template_kit_data['templates'][ $template_id ]['imports'] ) ) {
173
- $latest_import = array_pop( $template_kit_data['templates'][ $template_id ]['imports'] );
174
- if ( $latest_import && ! empty( $latest_import['imported_template_id'] ) ) {
175
- $latest_import_post = get_post( $latest_import['imported_template_id'] );
176
- if ( $latest_import_post && $latest_import_post->post_status === 'publish' ) {
177
- // We've already imported this template, don't import it again.
178
- return array(
179
- 'imported_template_id' => $latest_import['imported_template_id'],
180
- 'edit_url' => $template_kit->get_imported_template_edit_url( $latest_import['imported_template_id'] ),
181
- );
 
182
  }
183
  }
184
  }
185
  }
186
- }
187
 
188
  $imported_template_id = \Envato_Template_Kit_Import\Importer::get_instance()->handle_template_import( $template_kit_id, $template_id );
189
 
@@ -191,7 +191,6 @@ class Template_Kits extends Base {
191
  return $imported_template_id;
192
  }
193
 
194
-
195
  return array(
196
  'imported_template_id' => $imported_template_id,
197
  'edit_url' => $template_kit->get_imported_template_edit_url( $imported_template_id ),
78
  $this->load_template_kit_library();
79
  // Reach into our included Template Kit import plugin functions to do the actual import.
80
  $uploaded_kits = \Envato_Template_Kit_Import\CPT_Kits::get_instance()->get_all_uploaded_kits();
81
+ $installed_kits = array();
82
  try {
83
  foreach ( $uploaded_kits as $template_kit ) {
84
  $template_kit_id = $template_kit->ID;
87
  if ( $template_kit_manager ) {
88
  // Grab a list of templates from this kit, so we can use the first one as a screenshot url:
89
  $template_kit_templates = $template_kit_manager->get_available_templates();
90
+ $installed_kits[] = array(
91
  'id' => $template_kit_id,
92
  'screenshot_url' => $template_kit_templates[0]['screenshot_url'],
93
  'title' => $template_kit->post_title,
94
  'template_count' => count( $template_kit_templates ),
95
  'uploaded' => date_i18n( 'F j, Y g:i:a', strtotime( $template_kit->post_date ) ),
96
+ );
97
  }
98
  }
99
  } catch ( \Exception $e ) {
120
  }
121
 
122
  // Start building up template kit response
123
+ $template_kit_data = array(
124
  'id' => $template_kit_id,
125
  'title' => $template_kit->get_name(),
126
+ 'requirements' => array(
127
  'theme' => $template_kit->get_required_theme(),
128
  'plugins' => $template_kit->get_required_plugins(),
129
  'css' => $template_kit->get_required_css(),
130
+ ),
131
+ 'templates' => array(),
132
+ );
133
 
134
  // Loop over available templates and include any additional data we might need in the UI:
135
  foreach ( $template_kit->get_available_templates() as $template_id => $template ) {
154
  public function import_single_template( $template_kit_id, $template_id, $import_again ) {
155
  $this->load_template_kit_library();
156
 
157
+ include_once ABSPATH . 'wp-admin/includes/image.php';
158
 
159
  $template_kit = \Envato_Template_Kit_Import\envato_template_kit_import_get_builder( $template_kit_id );
160
  if ( ! $template_kit ) {
163
 
164
  // If the user wants to import the template again, we don't check for duplicates.
165
  if ( ! $import_again ) {
166
+ $template_kit_data = $this->get_installed_template_kit( $template_kit_id );
167
+
168
+ if ( ! empty( $template_kit_data['templates'] ) && ! empty( $template_kit_data['templates'][ $template_id ] ) ) {
169
+ // We've found a matching template for this template kit
170
+
171
+ // Check if we've already imported this template:
172
+ if ( ! empty( $template_kit_data['templates'][ $template_id ]['imports'] ) ) {
173
+ $latest_import = array_pop( $template_kit_data['templates'][ $template_id ]['imports'] );
174
+ if ( $latest_import && ! empty( $latest_import['imported_template_id'] ) ) {
175
+ $latest_import_post = get_post( $latest_import['imported_template_id'] );
176
+ if ( $latest_import_post && $latest_import_post->post_status === 'publish' ) {
177
+ // We've already imported this template, don't import it again.
178
+ return array(
179
+ 'imported_template_id' => $latest_import['imported_template_id'],
180
+ 'edit_url' => $template_kit->get_imported_template_edit_url( $latest_import['imported_template_id'] ),
181
+ );
182
+ }
183
  }
184
  }
185
  }
186
  }
 
187
 
188
  $imported_template_id = \Envato_Template_Kit_Import\Importer::get_instance()->handle_template_import( $template_kit_id, $template_id );
189
 
191
  return $imported_template_id;
192
  }
193
 
 
194
  return array(
195
  'imported_template_id' => $imported_template_id,
196
  'edit_url' => $template_kit->get_imported_template_edit_url( $imported_template_id ),
inc/backend/class-welcome.php CHANGED
@@ -60,11 +60,11 @@ class Welcome extends Base {
60
  <div id="template-kit-import-app-holder"></div>
61
  <script type="text/javascript">
62
  jQuery(function(){
63
- var appHolder = document.getElementById( 'template-kit-import-app-holder' );
64
- if (appHolder && 'undefined' !== typeof window.templateKitImport) {
65
  window.templateKitImport.initBackend( appHolder );
66
- }
67
- })
68
  </script>
69
  <?php
70
  }
60
  <div id="template-kit-import-app-holder"></div>
61
  <script type="text/javascript">
62
  jQuery(function(){
63
+ var appHolder = document.getElementById( 'template-kit-import-app-holder' );
64
+ if (appHolder && 'undefined' !== typeof window.templateKitImport) {
65
  window.templateKitImport.initBackend( appHolder );
66
+ }
67
+ })
68
  </script>
69
  <?php
70
  }
inc/bootstrap.php CHANGED
@@ -25,7 +25,7 @@ spl_autoload_register(
25
  }
26
 
27
  $class = strtolower( $class );
28
- $class = str_replace([ '\\', '_' ], [ '/', '-' ], $class );
29
  $class_path = strtolower( substr( $class, $len + 1 ) );
30
  $class_name = basename( $class_path );
31
  $class_folder = dirname( $class_path );
25
  }
26
 
27
  $class = strtolower( $class );
28
+ $class = str_replace( array( '\\', '_' ), array( '/', '-' ), $class );
29
  $class_path = strtolower( substr( $class, $len + 1 ) );
30
  $class_name = basename( $class_path );
31
  $class_folder = dirname( $class_path );
inc/class-plugin.php CHANGED
@@ -35,9 +35,9 @@ class Plugin extends Base {
35
  * @access private
36
  */
37
  public function __construct() {
38
- add_action( 'admin_menu', [ $this, 'admin_menu' ] );
39
- add_action( 'admin_init', [ $this, 'admin_init' ] );
40
- add_action( 'plugins_loaded', [ $this, 'db_upgrade_check' ] );
41
  }
42
 
43
  /**
35
  * @access private
36
  */
37
  public function __construct() {
38
+ add_action( 'admin_menu', array( $this, 'admin_menu' ) );
39
+ add_action( 'admin_init', array( $this, 'admin_init' ) );
40
+ add_action( 'plugins_loaded', array( $this, 'db_upgrade_check' ) );
41
  }
42
 
43
  /**
inc/utils/class-base.php CHANGED
@@ -35,7 +35,7 @@ abstract class Base {
35
  *
36
  * @var Base
37
  */
38
- private static $instances = [];
39
 
40
  /**
41
  * Disable class cloning and throw an error on object clone.
35
  *
36
  * @var Base
37
  */
38
+ private static $instances = array();
39
 
40
  /**
41
  * Disable class cloning and throw an error on object clone.
languages/template-kit-import.pot CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (C) 2020 template-kit-import
2
  # This file is distributed under the same license as the template-kit-import package.
3
  msgid ""
4
  msgstr ""
@@ -17,16 +17,16 @@ msgstr ""
17
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
18
 
19
  #. translators: %s: PHP version
20
- #: template-kit-import.php:75
21
- msgid "Template Kit Import plugin requires PHP version %s+, plugin is currently NOT ACTIVE. Please contact the hosting provider. WordPress recommends version %s."
22
  msgstr ""
23
 
24
- #: template-kit-import.php:80
25
  msgid "7.2 or above"
26
  msgstr ""
27
 
28
  #. translators: %s: WordPress version
29
- #: template-kit-import.php:99
30
  msgid "Envato Elements requires WordPress version %s+. Because you are using an earlier version, the plugin is currently NOT ACTIVE."
31
  msgstr ""
32
 
1
+ # Copyright (C) 2021 template-kit-import
2
  # This file is distributed under the same license as the template-kit-import package.
3
  msgid ""
4
  msgstr ""
17
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
18
 
19
  #. translators: %s: PHP version
20
+ #: template-kit-import.php:77
21
+ msgid "Template Kit Import plugin requires PHP version %1$s+, plugin is currently NOT ACTIVE. Please contact the hosting provider. WordPress recommends version %2$s."
22
  msgstr ""
23
 
24
+ #: template-kit-import.php:82
25
  msgid "7.2 or above"
26
  msgstr ""
27
 
28
  #. translators: %s: WordPress version
29
+ #: template-kit-import.php:101
30
  msgid "Envato Elements requires WordPress version %s+. Because you are using an earlier version, the plugin is currently NOT ACTIVE."
31
  msgstr ""
32
 
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: envato
3
  Tags: elementor, template, templates
4
  Requires at least: 5.3
5
- Tested up to: 5.5
6
  Requires PHP: 5.6
7
- Stable tag: 1.0.10
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -36,6 +36,10 @@ Create your own "Template Kit" for others with the "[Template Kit Export](https:
36
 
37
  == Changelog ==
38
 
 
 
 
 
39
  = 1.0.10 - 2020-11-09 =
40
  * Fix: Bug where UI not updated if template kit is already imported allowing duplicate imports
41
  * Disable: WP big image size threshold to allow larger images
2
  Contributors: envato
3
  Tags: elementor, template, templates
4
  Requires at least: 5.3
5
+ Tested up to: 5.6
6
  Requires PHP: 5.6
7
+ Stable tag: 1.0.11
8
  License: GPLv3
9
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
 
36
 
37
  == Changelog ==
38
 
39
+ = 1.0.11 - 2021-02-02 =
40
+ * Feature: Support for Elementor Landing Page templates
41
+ * Feature: Elementor compatibility check
42
+
43
  = 1.0.10 - 2020-11-09 =
44
  * Fix: Bug where UI not updated if template kit is already imported allowing duplicate imports
45
  * Disable: WP big image size threshold to allow larger images
src/js/react/components/Contexts/useGlobalConfig.js CHANGED
@@ -6,10 +6,13 @@ function useGlobalConfig () {
6
 
7
  const appendToGlobalConfig = (key, objectToAppend) => {
8
  const existingItems = globalConfig[key] || []
9
- setConfigValue(key, {
10
- ...existingItems,
11
- ...objectToAppend
12
- })
 
 
 
13
  }
14
 
15
  // Downloaded items config managements:
@@ -21,11 +24,13 @@ function useGlobalConfig () {
21
  }
22
  const removeDownloadedItem = ({ importedId }) => {
23
  const downloadedHumanmeIds = Object.keys(globalConfig.downloaded_items)
24
- downloadedHumanmeIds.map(humaneId => {
25
- if (globalConfig.downloaded_items[humaneId] === importedId) {
26
- delete (globalConfig.downloaded_items[humaneId])
 
 
27
  }
28
- })
29
  }
30
 
31
  // Subscription status config management
6
 
7
  const appendToGlobalConfig = (key, objectToAppend) => {
8
  const existingItems = globalConfig[key] || []
9
+ setConfigValue(
10
+ key,
11
+ {
12
+ ...existingItems,
13
+ ...objectToAppend
14
+ }
15
+ )
16
  }
17
 
18
  // Downloaded items config managements:
24
  }
25
  const removeDownloadedItem = ({ importedId }) => {
26
  const downloadedHumanmeIds = Object.keys(globalConfig.downloaded_items)
27
+ downloadedHumanmeIds.map(
28
+ humaneId => {
29
+ if (globalConfig.downloaded_items[humaneId] === importedId) {
30
+ delete (globalConfig.downloaded_items[humaneId])
31
+ }
32
  }
33
+ )
34
  }
35
 
36
  // Subscription status config management
template-kit-import.php CHANGED
@@ -4,9 +4,11 @@
4
  * Description: Import Template Kits to WordPress
5
  * Author: Envato
6
  * Author URI: https://envato.com
7
- * Version: 1.0.10
8
  * License: GPLv3 or later
9
  * License URI: https://www.gnu.org/licenses/gpl-3.0.html
 
 
10
  *
11
  * Text Domain: template-kit-import
12
  *
@@ -28,7 +30,7 @@ if ( ! defined( 'ABSPATH' ) ) {
28
  }
29
 
30
  define( 'ENVATO_TEMPLATE_KIT_IMPORT_SLUG', 'template-kit-import' );
31
- define( 'ENVATO_TEMPLATE_KIT_IMPORT_VER', '1.0.10' );
32
  define( 'ENVATO_TEMPLATE_KIT_IMPORT_FILE', __FILE__ );
33
  define( 'ENVATO_TEMPLATE_KIT_IMPORT_DIR', plugin_dir_path( ENVATO_TEMPLATE_KIT_IMPORT_FILE ) );
34
  define( 'ENVATO_TEMPLATE_KIT_IMPORT_URI', plugins_url( '/', ENVATO_TEMPLATE_KIT_IMPORT_FILE ) );
@@ -72,8 +74,8 @@ function template_kit_import_load_plugin_textdomain() {
72
  function template_kit_import_fail_php_version() {
73
  $message = sprintf(
74
  /* translators: %s: PHP version */
75
- esc_html__( 'Template Kit Import plugin requires PHP version %s+, plugin is currently NOT ACTIVE. Please contact the hosting provider. WordPress recommends version %s.', 'template-kit-import' ),
76
- TEMPLATE_KIT_IMPORT_PHP_VERSION,
77
  sprintf(
78
  '<a href="%s" target="_blank">%s</a>',
79
  esc_url( 'https://wordpress.org/about/requirements/' ),
4
  * Description: Import Template Kits to WordPress
5
  * Author: Envato
6
  * Author URI: https://envato.com
7
+ * Version: 1.0.11
8
  * License: GPLv3 or later
9
  * License URI: https://www.gnu.org/licenses/gpl-3.0.html
10
+ * Elementor tested up to: 3.2.0
11
+ * Elementor Pro tested up to: 3.1.0
12
  *
13
  * Text Domain: template-kit-import
14
  *
30
  }
31
 
32
  define( 'ENVATO_TEMPLATE_KIT_IMPORT_SLUG', 'template-kit-import' );
33
+ define( 'ENVATO_TEMPLATE_KIT_IMPORT_VER', '1.0.11' );
34
  define( 'ENVATO_TEMPLATE_KIT_IMPORT_FILE', __FILE__ );
35
  define( 'ENVATO_TEMPLATE_KIT_IMPORT_DIR', plugin_dir_path( ENVATO_TEMPLATE_KIT_IMPORT_FILE ) );
36
  define( 'ENVATO_TEMPLATE_KIT_IMPORT_URI', plugins_url( '/', ENVATO_TEMPLATE_KIT_IMPORT_FILE ) );
74
  function template_kit_import_fail_php_version() {
75
  $message = sprintf(
76
  /* translators: %s: PHP version */
77
+ esc_html__( 'Template Kit Import plugin requires PHP version %1$s+, plugin is currently NOT ACTIVE. Please contact the hosting provider. WordPress recommends version %2$s.', 'template-kit-import' ),
78
+ ENVATO_TEMPLATE_KIT_IMPORT_PHP_VERSION,
79
  sprintf(
80
  '<a href="%s" target="_blank">%s</a>',
81
  esc_url( 'https://wordpress.org/about/requirements/' ),
vendor/template-kit-import/inc/class-builder.php CHANGED
@@ -100,7 +100,7 @@ abstract class Builder extends Base {
100
  * @return string
101
  */
102
  public function get_css_separator( $css_file ) {
103
- $css_separator = 'Template Kit CSS: ' . esc_html( $this->get_name() . ' (' . $css_file .')' );
104
  return $css_separator;
105
  }
106
 
@@ -130,7 +130,7 @@ abstract class Builder extends Base {
130
  if ( ! $has_this_css_been_installed_already ) {
131
  // The user hasn't installed this css before (or it's a fresh site with no customzer data yet).
132
  $required_css['css_preview'] = $this->get_custom_css_data( $required_css['file'] );
133
- $to_install_required[] = $required_css;
134
  }
135
  }
136
  }
@@ -152,7 +152,7 @@ abstract class Builder extends Base {
152
  foreach ( $templates as $template_index => $template ) {
153
  $templates[ $template_index ]['screenshot_url'] = $screenshot_base_url . $template['screenshot'];
154
  // Checking the additional template informatino strings for &amp; and converting to & so they display.
155
- if( ! empty( $template['metadata']['additional_template_information'] ) ) {
156
  $templates[ $template_index ]['metadata']['additional_template_information'] = array_map( 'htmlspecialchars_decode', $template['metadata']['additional_template_information'] );
157
  }
158
  // Check if the name of the template has any characters that need decoding and convert them.
100
  * @return string
101
  */
102
  public function get_css_separator( $css_file ) {
103
+ $css_separator = 'Template Kit CSS: ' . esc_html( $this->get_name() . ' (' . $css_file . ')' );
104
  return $css_separator;
105
  }
106
 
130
  if ( ! $has_this_css_been_installed_already ) {
131
  // The user hasn't installed this css before (or it's a fresh site with no customzer data yet).
132
  $required_css['css_preview'] = $this->get_custom_css_data( $required_css['file'] );
133
+ $to_install_required[] = $required_css;
134
  }
135
  }
136
  }
152
  foreach ( $templates as $template_index => $template ) {
153
  $templates[ $template_index ]['screenshot_url'] = $screenshot_base_url . $template['screenshot'];
154
  // Checking the additional template informatino strings for &amp; and converting to & so they display.
155
+ if ( ! empty( $template['metadata']['additional_template_information'] ) ) {
156
  $templates[ $template_index ]['metadata']['additional_template_information'] = array_map( 'htmlspecialchars_decode', $template['metadata']['additional_template_information'] );
157
  }
158
  // Check if the name of the template has any characters that need decoding and convert them.
vendor/template-kit-import/inc/class-cpt-kits.php CHANGED
@@ -40,7 +40,7 @@ class CPT_Kits extends CPT {
40
  parent::__construct();
41
 
42
  add_filter( 'wpseo_sitemap_exclude_post_type', array( $this, 'wpseo_sitemap_exclude_post_type' ), 10, 2 );
43
- add_filter( 'page_row_actions', [ $this, 'custom_cpt_links' ], 10, 2 );
44
  }
45
 
46
  /**
40
  parent::__construct();
41
 
42
  add_filter( 'wpseo_sitemap_exclude_post_type', array( $this, 'wpseo_sitemap_exclude_post_type' ), 10, 2 );
43
+ add_filter( 'page_row_actions', array( $this, 'custom_cpt_links' ), 10, 2 );
44
  }
45
 
46
  /**
vendor/template-kit-import/inc/class-delete.php CHANGED
@@ -32,7 +32,7 @@ class Delete extends Base {
32
  *
33
  * @since 1.0.1
34
  */
35
- public function delete_template_kit($template_kit_id) {
36
  wp_delete_post( $template_kit_id, true );
37
  }
38
 
32
  *
33
  * @since 1.0.1
34
  */
35
+ public function delete_template_kit( $template_kit_id ) {
36
  wp_delete_post( $template_kit_id, true );
37
  }
38
 
vendor/template-kit-import/inc/class-importer.php CHANGED
@@ -60,7 +60,7 @@ class Importer extends Base {
60
 
61
  global $wp_filesystem;
62
 
63
- require_once( ABSPATH . '/wp-admin/includes/file.php' );
64
  \WP_Filesystem();
65
 
66
  if ( ! $wp_filesystem instanceof \WP_Filesystem_Base ) {
60
 
61
  global $wp_filesystem;
62
 
63
+ require_once ABSPATH . '/wp-admin/includes/file.php';
64
  \WP_Filesystem();
65
 
66
  if ( ! $wp_filesystem instanceof \WP_Filesystem_Base ) {
vendor/template-kit-import/inc/class-required-plugin.php CHANGED
@@ -33,8 +33,8 @@ class Required_Plugin extends Base {
33
  */
34
  public function get_plugin_status( $plugin_details ) {
35
 
36
- //return 'install'; // uncomment this to test no plugins installed.
37
- //return 'activated'; // uncomment this to test all plugins installed & up to date.
38
 
39
  if ( empty( $plugin_details['file'] ) ) {
40
  return 'error';
33
  */
34
  public function get_plugin_status( $plugin_details ) {
35
 
36
+ // return 'install'; // uncomment this to test no plugins installed.
37
+ // return 'activated'; // uncomment this to test all plugins installed & up to date.
38
 
39
  if ( empty( $plugin_details['file'] ) ) {
40
  return 'error';