ThemeGrill Demo Importer - Version 1.7.3

Version Description

  • 08-10-2021 =
  • Tweak - Support eLearning theme.
  • Tweak - Disable Masteriyo setup wizard.
  • Tweak - Setup Masteriyo pages properly after demo import.
Download this release

Release Info

Developer themegrilldev
Plugin Icon 128x128 ThemeGrill Demo Importer
Version 1.7.3
Comparing to
See all releases

Code changes from version 1.7.2 to 1.7.3

includes/class-themegrill-demo-importer.php CHANGED
@@ -20,7 +20,7 @@ final class ThemeGrill_Demo_Importer {
20
  *
21
  * @var string
22
  */
23
- public $version = '1.7.2';
24
 
25
  /**
26
  * Theme single instance of this class.
@@ -123,7 +123,7 @@ final class ThemeGrill_Demo_Importer {
123
  * @return array
124
  */
125
  private function get_core_supported_themes() {
126
- $core_themes = array( 'spacious', 'colormag', 'flash', 'estore', 'ample', 'accelerate', 'colornews', 'foodhunt', 'fitclub', 'radiate', 'freedom', 'himalayas', 'esteem', 'envince', 'suffice', 'explore', 'masonic', 'cenote', 'zakra', 'webshop' );
127
  // Check for official core themes pro version.
128
  $pro_themes = array_diff( $core_themes, array( 'explore', 'masonic' ) );
129
  if ( ! empty( $pro_themes ) ) {
20
  *
21
  * @var string
22
  */
23
+ public $version = '1.7.3';
24
 
25
  /**
26
  * Theme single instance of this class.
123
  * @return array
124
  */
125
  private function get_core_supported_themes() {
126
+ $core_themes = array( 'spacious', 'colormag', 'flash', 'estore', 'ample', 'accelerate', 'colornews', 'foodhunt', 'fitclub', 'radiate', 'freedom', 'himalayas', 'esteem', 'envince', 'suffice', 'explore', 'masonic', 'cenote', 'zakra', 'webshop', 'elearning' );
127
  // Check for official core themes pro version.
128
  $pro_themes = array_diff( $core_themes, array( 'explore', 'masonic' ) );
129
  if ( ! empty( $pro_themes ) ) {
includes/functions-demo-importer.php CHANGED
@@ -11,6 +11,9 @@ defined( 'ABSPATH' ) || exit;
11
  // Include core functions (available in both admin and frontend).
12
  require_once TGDM_ABSPATH . 'includes/functions-demo-update.php';
13
 
 
 
 
14
  /**
15
  * Ajax handler for installing a required plugin.
16
  *
@@ -35,6 +38,7 @@ function tg_ajax_install_required_plugin() {
35
 
36
  $slug = sanitize_key( wp_unslash( $_POST['slug'] ) );
37
  $plugin = plugin_basename( sanitize_text_field( wp_unslash( $_POST['plugin'] ) ) );
 
38
  $status = array(
39
  'install' => 'plugin',
40
  'slug' => sanitize_key( wp_unslash( $_POST['slug'] ) ),
@@ -394,6 +398,113 @@ function tg_set_wc_pages( $demo_id ) {
394
  }
395
  }
396
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
397
  /**
398
  * Prints the JavaScript templates for install admin notices.
399
  *
11
  // Include core functions (available in both admin and frontend).
12
  require_once TGDM_ABSPATH . 'includes/functions-demo-update.php';
13
 
14
+ // Disable Masteriyo setup wizard.
15
+ add_filter( 'masteriyo_enable_setup_wizard', '__return_false' );
16
+
17
  /**
18
  * Ajax handler for installing a required plugin.
19
  *
38
 
39
  $slug = sanitize_key( wp_unslash( $_POST['slug'] ) );
40
  $plugin = plugin_basename( sanitize_text_field( wp_unslash( $_POST['plugin'] ) ) );
41
+
42
  $status = array(
43
  'install' => 'plugin',
44
  'slug' => sanitize_key( wp_unslash( $_POST['slug'] ) ),
398
  }
399
  }
400
 
401
+ /**
402
+ * After demo imported AJAX action.
403
+ *
404
+ * @see tg_set_masteriyo_pages()
405
+ */
406
+ add_action( 'themegrill_ajax_demo_imported', 'tg_set_masteriyo_pages' );
407
+
408
+ /**
409
+ * Set Masteriyo pages properly and disable setup wizard redirect.
410
+ *
411
+ * After importing demo data filter out duplicate Masteriyo pages and set them properly.
412
+ * Happens when the user run default Masteriyo setup wizard during installation.
413
+ *
414
+ * Note: Masteriyo pages ID are stored in an option and slug are modified to remove any numbers.
415
+ *
416
+ * @param string $demo_id
417
+ */
418
+ function tg_set_masteriyo_pages( $demo_id ) {
419
+
420
+ if ( function_exists( 'masteriyo' ) ) {
421
+
422
+ global $wpdb;
423
+ $masteriyo_pages = apply_filters(
424
+ 'themegrill_masteriyo_' . $demo_id . '_pages',
425
+ array(
426
+ 'courses' => array(
427
+ 'name' => 'courses',
428
+ 'title' => 'Courses',
429
+ 'setting_name' => 'courses_page_id',
430
+ ),
431
+ 'account' => array(
432
+ 'name' => 'account',
433
+ 'title' => 'Account',
434
+ 'setting_name' => 'account_page_id',
435
+ ),
436
+ 'checkout' => array(
437
+ 'name' => 'checkout',
438
+ 'title' => 'Checkout',
439
+ 'setting_name' => 'checkout_page_id',
440
+ ),
441
+ 'learn' => array(
442
+ 'name' => 'learn',
443
+ 'title' => 'Learn',
444
+ 'setting_name' => 'learn_page_id',
445
+ ),
446
+ 'terms_conditions' => array(
447
+ 'name' => 'terms-and-conditions',
448
+ 'title' => 'Terms and Conditions',
449
+ 'setting_name' => 'terms_conditions_page_id',
450
+ ),
451
+ )
452
+ );
453
+
454
+ // Set Masteriyo pages properly.
455
+ foreach ( $masteriyo_pages as $key => $masteriyo_page ) {
456
+
457
+ // Get the ID of every page with matching name or title.
458
+ $page_ids = $wpdb->get_results( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE (post_name = %s OR post_title = %s) AND post_type = 'page' AND post_status = 'publish'", $masteriyo_page['name'], $masteriyo_page['title'] ) );
459
+
460
+ if ( ! is_null( $page_ids ) ) {
461
+
462
+ $page_id = 0;
463
+ $delete_ids = array();
464
+
465
+ // Retrieve page with greater id and delete others.
466
+ if ( sizeof( $page_ids ) > 1 ) {
467
+
468
+ foreach ( $page_ids as $page ) {
469
+ if ( $page->ID > $page_id ) {
470
+ if ( $page_id ) {
471
+ $delete_ids[] = $page_id;
472
+ }
473
+
474
+ $page_id = $page->ID;
475
+ } else {
476
+ $delete_ids[] = $page->ID;
477
+ }
478
+ }
479
+ } else {
480
+ $page_id = $page_ids[0]->ID;
481
+ }
482
+
483
+ // Delete posts.
484
+ foreach ( $delete_ids as $delete_id ) {
485
+ wp_delete_post( $delete_id, true );
486
+ }
487
+
488
+ // Update Masteriyo page.
489
+ if ( $page_id > 0 ) {
490
+ wp_update_post(
491
+ array(
492
+ 'ID' => $page_id,
493
+ 'post_name' => sanitize_title( $masteriyo_page['name'] ),
494
+ )
495
+ );
496
+
497
+ $setting_name = $masteriyo_page['setting_name'];
498
+
499
+ function_exists( 'masteriyo_set_setting' ) && masteriyo_set_setting( "advance.pages.{$setting_name}", $page_id );
500
+ }
501
+ }
502
+ }
503
+
504
+ delete_transient( '_masteriyo_activation_redirect' );
505
+ }
506
+ }
507
+
508
  /**
509
  * Prints the JavaScript templates for install admin notices.
510
  *
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: ThemeGrill, shivapoudel
3
  Tags: themegrill, theme demos, demo, importer, one click import
4
  Requires at least: 4.7
5
- Tested up to: 5.7.2
6
- Stable tag: 1.7.2
7
  License: GPLv3 or later
8
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
9
 
@@ -72,8 +72,13 @@ Yes you can! Join in on our [GitHub repository](https://github.com/themegrill/th
72
  3. Finally, Import the Demo with just one click.
73
 
74
  == Changelog ==
 
 
 
 
 
75
  = 1.7.2 - 25-06-2021 =
76
- Fix - Value (Legacy) of Parallax Type option from SiteOrigin plugin changing after demo import.
77
 
78
  = 1.7.1 - 18-01-2021 =
79
  * Remove - Admin notice for `Plugin Review`.
2
  Contributors: ThemeGrill, shivapoudel
3
  Tags: themegrill, theme demos, demo, importer, one click import
4
  Requires at least: 4.7
5
+ Tested up to: 5.8
6
+ Stable tag: 1.7.3
7
  License: GPLv3 or later
8
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
9
 
72
  3. Finally, Import the Demo with just one click.
73
 
74
  == Changelog ==
75
+ = 1.7.3 - 08-10-2021 =
76
+ * Tweak - Support eLearning theme.
77
+ * Tweak - Disable Masteriyo setup wizard.
78
+ * Tweak - Setup Masteriyo pages properly after demo import.
79
+
80
  = 1.7.2 - 25-06-2021 =
81
+ * Fix - Value (Legacy) of Parallax Type option from SiteOrigin plugin changing after demo import.
82
 
83
  = 1.7.1 - 18-01-2021 =
84
  * Remove - Admin notice for `Plugin Review`.
themegrill-demo-importer.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: ThemeGrill Demo Importer
4
  * Plugin URI: https://themegrill.com/demo-importer/
5
  * Description: Import ThemeGrill official themes demo content, widgets and theme settings with just one click.
6
- * Version: 1.7.2
7
  * Author: ThemeGrill
8
  * Author URI: https://themegrill.com
9
  * License: GPLv3 or later
3
  * Plugin Name: ThemeGrill Demo Importer
4
  * Plugin URI: https://themegrill.com/demo-importer/
5
  * Description: Import ThemeGrill official themes demo content, widgets and theme settings with just one click.
6
+ * Version: 1.7.3
7
  * Author: ThemeGrill
8
  * Author URI: https://themegrill.com
9
  * License: GPLv3 or later