Starter Templates by Kadence WP - Version 1.2.8

Version Description

  • Fix: Some import issues.
Download this release

Release Info

Developer britner
Plugin Icon 128x128 Starter Templates by Kadence WP
Version 1.2.8
Comparing to
See all releases

Code changes from version 1.2.7 to 1.2.8

class-kadence-starter-templates.php CHANGED
@@ -187,7 +187,7 @@ class Starter_Templates {
187
  define( 'KADENCE_STARTER_TEMPLATES_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) );
188
  }
189
  if ( ! defined( 'KADENCE_STARTER_TEMPLATES_VERSION' ) ) {
190
- define( 'KADENCE_STARTER_TEMPLATES_VERSION', '1.2.7' );
191
  }
192
  }
193
 
187
  define( 'KADENCE_STARTER_TEMPLATES_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) );
188
  }
189
  if ( ! defined( 'KADENCE_STARTER_TEMPLATES_VERSION' ) ) {
190
+ define( 'KADENCE_STARTER_TEMPLATES_VERSION', '1.2.8' );
191
  }
192
  }
193
 
inc/class-importer.php CHANGED
@@ -178,10 +178,12 @@ class Importer {
178
  } else {
179
  add_filter( 'wxr_importer.pre_process.post_meta', array( $this, 'process_elementor_images' ), 10, 2 );
180
  add_filter( 'wxr_importer.pre_process.post', array( $this, 'process_kadence_block_css' ), 10, 4 );
 
181
  add_filter( 'wxr_importer.pre_process.post', array( $this, 'process_internal_links' ), 11, 4 );
182
  //add_action( 'wxr_importer.processed.post', array( $this, 'process_internal_links' ), 10, 5 );
183
  // Check, if we need to send another AJAX request and set the importing author to the current user.
184
  add_filter( 'wxr_importer.pre_process.post', array( $this, 'new_ajax_request_maybe' ) );
 
185
  //add_filter( 'wxr_importer.pre_process.post', array( $this, 'process_kadence_block_css' ), 10, 5 );
186
  //add_action( 'wxr_importer.processed.post', array( $this, 'process_kadence_galleries' ), 10, 5 );
187
  }
@@ -282,6 +284,34 @@ class Importer {
282
  }
283
  return $data;
284
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
285
  /**
286
  * Process Kadence Block CSS
287
  *
@@ -291,32 +321,148 @@ class Importer {
291
  * @param array $comments Raw comment data, already processed by {@see process_comments}.
292
  * @param array $terms Raw term data, already processed.
293
  */
294
- public function process_kadence_block_css( $data, $meta, $comments, $terms ) {
295
- $meta_data = wp_list_pluck( $meta, 'key' );
296
- if ( in_array( '_elementor_data', $meta_data, true ) ) {
297
- return $data;
298
- }
299
  if ( ! empty( $data['post_content'] ) ) {
300
- $content = parse_blocks( stripslashes( $data['post_content'] ) );
301
- foreach ( $content as $block ) {
302
  if ( ! empty( $block['attrs']['kadenceBlockCSS'] ) ) {
 
 
303
  $slash = str_replace( 'n ', '\n ', $block['attrs']['kadenceBlockCSS'] );
304
  $slash = str_replace( ';n', ';\n', $slash );
 
305
  $slash = str_replace( 'nselector', '\nselector', $slash );
306
  $update = str_replace( 'n ', '\\\n ', $block['attrs']['kadenceBlockCSS'] );
307
  $update = str_replace( ';n', ';\\\n', $update );
 
308
  $update = str_replace( 'nselector', '\\\nselector', $update );
309
  // $update = str_replace( 'n ', '', $block['attrs']['kadenceBlockCSS'] );
310
  // $update = str_replace( ';n', ';', $update );
311
  // $update = str_replace( 'nselector', 'selector', $update );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
312
  if ( $update !== $slash ) {
313
  $data['post_content'] = str_replace( $slash, $update, $data['post_content'] );
314
  }
315
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
316
  }
317
  }
318
  return $data;
319
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
320
  /**
321
  * Process Gallery Block
322
  *
178
  } else {
179
  add_filter( 'wxr_importer.pre_process.post_meta', array( $this, 'process_elementor_images' ), 10, 2 );
180
  add_filter( 'wxr_importer.pre_process.post', array( $this, 'process_kadence_block_css' ), 10, 4 );
181
+ //add_filter( 'wp_import_post_data_processed', array( $this, 'process_kadence_block_css_post' ), 10, 2 );
182
  add_filter( 'wxr_importer.pre_process.post', array( $this, 'process_internal_links' ), 11, 4 );
183
  //add_action( 'wxr_importer.processed.post', array( $this, 'process_internal_links' ), 10, 5 );
184
  // Check, if we need to send another AJAX request and set the importing author to the current user.
185
  add_filter( 'wxr_importer.pre_process.post', array( $this, 'new_ajax_request_maybe' ) );
186
+ //add_action( 'wxr_importer.processed.post', array( $this, 'process_kadence_block_css_processed' ), 10, 5 );
187
  //add_filter( 'wxr_importer.pre_process.post', array( $this, 'process_kadence_block_css' ), 10, 5 );
188
  //add_action( 'wxr_importer.processed.post', array( $this, 'process_kadence_galleries' ), 10, 5 );
189
  }
284
  }
285
  return $data;
286
  }
287
+ /**
288
+ * Process Kadence Block CSS
289
+ *
290
+ * @param string $content New post ID.
291
+ * @param array $data Raw data imported for the post.
292
+ */
293
+ public function process_kadence_block_css_post( $content, $data ) {
294
+ if ( ! empty( $content['post_content'] ) ) {
295
+ $post_content = parse_blocks( stripslashes( $content['post_content'] ) );
296
+ foreach ( $post_content as $block ) {
297
+ if ( ! empty( $block['attrs']['kadenceBlockCSS'] ) ) {
298
+ $slash = str_replace( 'n ', '\n ', $block['attrs']['kadenceBlockCSS'] );
299
+ $slash = str_replace( ';n', ';\n', $slash );
300
+ $slash = str_replace( 'nselector', '\nselector', $slash );
301
+ // $update = str_replace( 'n ', '\\\n ', $block['attrs']['kadenceBlockCSS'] );
302
+ // $update = str_replace( ';n', ';\\\n', $update );
303
+ // $update = str_replace( 'nselector', '\\\nselector', $update );
304
+ $update = str_replace( 'n ', '', $block['attrs']['kadenceBlockCSS'] );
305
+ $update = str_replace( ';n', ';', $update );
306
+ $update = str_replace( 'nselector', 'selector', $update );
307
+ if ( $update !== $slash ) {
308
+ $content['post_content'] = str_replace( $slash, $update, $content['post_content'] );
309
+ }
310
+ }
311
+ }
312
+ }
313
+ return $content;
314
+ }
315
  /**
316
  * Process Kadence Block CSS
317
  *
321
  * @param array $comments Raw comment data, already processed by {@see process_comments}.
322
  * @param array $terms Raw term data, already processed.
323
  */
324
+ public function process_kadence_block_css_processed( $post_id, $data, $meta, $comments, $terms ) {
 
 
 
 
325
  if ( ! empty( $data['post_content'] ) ) {
326
+ $post_content = parse_blocks( $data['post_content'] );
327
+ foreach ( $post_content as $block ) {
328
  if ( ! empty( $block['attrs']['kadenceBlockCSS'] ) ) {
329
+ //error_log( print_r( $data['post_content'], true ) );
330
+ //error_log( print_r( $block['attrs']['kadenceBlockCSS'], true ) );
331
  $slash = str_replace( 'n ', '\n ', $block['attrs']['kadenceBlockCSS'] );
332
  $slash = str_replace( ';n', ';\n', $slash );
333
+ $slash = str_replace( '; n', '; \n', $slash );
334
  $slash = str_replace( 'nselector', '\nselector', $slash );
335
  $update = str_replace( 'n ', '\\\n ', $block['attrs']['kadenceBlockCSS'] );
336
  $update = str_replace( ';n', ';\\\n', $update );
337
+ $update = str_replace( '; n', '; \\\n', $update );
338
  $update = str_replace( 'nselector', '\\\nselector', $update );
339
  // $update = str_replace( 'n ', '', $block['attrs']['kadenceBlockCSS'] );
340
  // $update = str_replace( ';n', ';', $update );
341
  // $update = str_replace( 'nselector', 'selector', $update );
342
+ $data['post_content'] = str_replace( $slash, $update, $data['post_content'] );
343
+ $data['post_content'] = str_replace( $block['attrs']['kadenceBlockCSS'], $update, $data['post_content'] );
344
+ }
345
+ }
346
+ wp_update_post(
347
+ array(
348
+ 'ID' => $post_id,
349
+ 'post_content' => $data['post_content'],
350
+ )
351
+ );
352
+ }
353
+ }
354
+ /**
355
+ * Process Kadence Block CSS
356
+ *
357
+ * @param int $post_id New post ID.
358
+ * @param array $data Raw data imported for the post.
359
+ * @param array $meta Raw meta data, already processed by {@see process_post_meta}.
360
+ * @param array $comments Raw comment data, already processed by {@see process_comments}.
361
+ * @param array $terms Raw term data, already processed.
362
+ */
363
+ public function process_kadence_block_css( $data, $meta, $comments, $terms ) {
364
+ $meta_data = wp_list_pluck( $meta, 'key' );
365
+ if ( in_array( '_elementor_data', $meta_data, true ) ) {
366
+ return $data;
367
+ }
368
+ if ( ! empty( $data['post_content'] ) ) {
369
+ $content = parse_blocks( $data['post_content'] );
370
+ foreach ( $content as $indexkey => $block ) {
371
+ if ( ! empty( $block['attrs']['kadenceBlockCSS'] ) ) {
372
+ //stripslashes( $data['post_content'] )
373
+ // $slash = str_replace( '{n ', '{\n ', $block['attrs']['kadenceBlockCSS'] );
374
+ // $slash = str_replace( ';n', ';\n', $slash );
375
+ // $slash = str_replace( '; n', '; \n', $slash );
376
+ // $slash = str_replace( '}n', '}\n', $slash );
377
+ // $slash = str_replace( 'nselector', '\nselector', $slash );
378
+ $slash = wp_json_encode( $block['attrs']['kadenceBlockCSS'] );
379
+ $update = str_replace( '\n', '\\\n', $slash );
380
+ // $update = str_replace( ';\n', ';\\\n', $update );
381
+ // $update = str_replace( '}\n', '}\\\n', $update );
382
+ // $update = str_replace( '; \n', '; \\\n', $update );
383
+ // $update = str_replace( '\nselector', '\\\nselector', $update );
384
+ // $update = str_replace( '{n ', '{\\\n ', $update );
385
+ // $update = str_replace( '}n', '}\\\n', $update );
386
+ // $update = str_replace( ';n', ';\\\n', $update );
387
+ // $update = str_replace( '; n', '; \\\n', $update );
388
+ // $update = str_replace( 'nselector', '\\\nselector', $update );
389
+ // $update = str_replace( 'n ', '', $block['attrs']['kadenceBlockCSS'] );
390
+ // $update = str_replace( ';n', ';', $update );
391
+ // $update = str_replace( 'nselector', 'selector', $update );
392
  if ( $update !== $slash ) {
393
  $data['post_content'] = str_replace( $slash, $update, $data['post_content'] );
394
  }
395
  }
396
+ // if ( 'kadence/testimonials' === $block['blockName'] ) {
397
+ // if ( isset( $block['attrs'] ) && is_array( $block['attrs'] ) ) {
398
+ // if ( ! empty( $block['attrs']['testimonials'] ) && is_array( $block['attrs']['testimonials'] ) ) {
399
+ // foreach ( $block['attrs']['testimonials'] as $test_key => $test_content ) {
400
+ // if ( ! empty( $test_content['title'] ) ) {
401
+ // $test_slash = wp_json_encode( $test_content['title'] );
402
+ // $test_update = str_replace( '\"', '\\"', $test_slash );
403
+ // $test_update = str_replace( '<\/', '<\\/', $test_update );
404
+ // $data['post_content'] = str_replace( $test_slash, $test_update, $data['post_content'] );
405
+ // }
406
+ // }
407
+ // }
408
+ // }
409
+ // }
410
+ if ( isset( $block['innerBlocks'] ) && ! empty( $block['innerBlocks'] ) && is_array( $block['innerBlocks'] ) ) {
411
+ $data['post_content'] = $this->blocks_cycle_through( $data['post_content'], $block['innerBlocks'] );
412
+ }
413
  }
414
  }
415
  return $data;
416
  }
417
+ /**
418
+ * Builds css for inner blocks
419
+ *
420
+ * @param array $inner_blocks array of inner blocks.
421
+ */
422
+ public function blocks_cycle_through( $post_content, $inner_blocks ) {
423
+ foreach ( $inner_blocks as $in_indexkey => $inner_block ) {
424
+ if ( ! empty( $inner_block['attrs']['kadenceBlockCSS'] ) ) {
425
+ // $slash = str_replace( '{n ', '{\n ', $inner_block['attrs']['kadenceBlockCSS'] );
426
+ // $slash = str_replace( ';n', ';\n', $slash );
427
+ // $slash = str_replace( '; n', '; \n', $slash );
428
+ // $slash = str_replace( 'nselector', '\nselector', $slash );
429
+ // $update = str_replace( '{\n ', '{\\\n ', $inner_block['attrs']['kadenceBlockCSS'] );
430
+ // $update = str_replace( ';\n', ';\\\n', $update );
431
+ // $update = str_replace( '; \n', '; \\\n', $update );
432
+ // $update = str_replace( '\nselector', '\\\nselector', $update );
433
+ // $update = str_replace( '{n ', '{\\\n ', $update );
434
+ // $update = str_replace( ';n', ';\\\n', $update );
435
+ // $update = str_replace( '; n', '; \\\n', $update );
436
+ // $update = str_replace( 'nselector', '\\\nselector', $update );
437
+ // $update = str_replace( 'n ', '', $block['attrs']['kadenceBlockCSS'] );
438
+ // $update = str_replace( ';n', ';', $update );
439
+ // $update = str_replace( 'nselector', 'selector', $update );
440
+ $slash = wp_json_encode( $inner_block['attrs']['kadenceBlockCSS'] );
441
+ $update = str_replace( '\n', '\\\n', $slash );
442
+ if ( $update !== $slash ) {
443
+ $post_content = str_replace( $slash, $update, $post_content );
444
+ }
445
+ }
446
+ // if ( 'kadence/testimonials' === $inner_block['blockName'] ) {
447
+ // if ( isset( $inner_block['attrs'] ) && is_array( $inner_block['attrs'] ) ) {
448
+ // if ( ! empty( $inner_block['attrs']['testimonials'] ) && is_array( $inner_block['attrs']['testimonials'] ) ) {
449
+ // foreach ( $inner_block['attrs']['testimonials'] as $test_key => $test_content ) {
450
+ // if ( ! empty( $test_content['title'] ) ) {
451
+ // $test_slash = wp_json_encode( $test_content['title'] );
452
+ // $test_update = str_replace( '\"', '\\"', $test_slash );
453
+ // $test_update = str_replace( '<\/', '<\\/', $test_update );
454
+ // $post_content = str_replace( $test_slash, $test_update, $post_content );
455
+ // }
456
+ // }
457
+ // }
458
+ // }
459
+ // }
460
+ if ( isset( $inner_block['innerBlocks'] ) && ! empty( $inner_block['innerBlocks'] ) && is_array( $inner_block['innerBlocks'] ) ) {
461
+ $post_content = $this->blocks_cycle_through( $post_content, $inner_block['innerBlocks'] );
462
+ }
463
+ }
464
+ return $post_content;
465
+ }
466
  /**
467
  * Process Gallery Block
468
  *
kadence-starter-templates.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Plugin Name: Kadence Starter Templates
4
  * Description: Choose the prebuilt website and click to import.
5
- * Version: 1.2.7
6
  * Author: Kadence WP
7
  * Author URI: https://kadencewp.com/
8
  * License: GPLv2 or later
2
  /**
3
  * Plugin Name: Kadence Starter Templates
4
  * Description: Choose the prebuilt website and click to import.
5
+ * Version: 1.2.8
6
  * Author: Kadence WP
7
  * Author URI: https://kadencewp.com/
8
  * License: GPLv2 or later
readme.txt CHANGED
@@ -108,6 +108,9 @@ Absolutely not.
108
 
109
  == Changelog ==
110
 
 
 
 
111
  = 1.2.7 =
112
  * Update: Optional subscribe.
113
 
108
 
109
  == Changelog ==
110
 
111
+ = 1.2.8 =
112
+ * Fix: Some import issues.
113
+
114
  = 1.2.7 =
115
  * Update: Optional subscribe.
116