Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added WordPress 6.3 Compatibility #9

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,059 changes: 1,058 additions & 1 deletion assets/css/app.min.css

Large diffs are not rendered by default.

Binary file added assets/images/droip-icon.webp
Binary file not shown.
1 change: 1 addition & 0 deletions assets/js/demo-importer.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
271 changes: 174 additions & 97 deletions inc/DemoImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace TUTORMATE;

use TutorLMSDroip\Helper;

defined( 'ABSPATH' ) || exit;

/**
Expand All @@ -19,62 +21,80 @@ class DemoImport {
*
* @var string
*/
private $endpoint = 'https://api.tutorlms.com/wp-json/restapi/v1/tutorpacks';

// private $endpoint = 'https://api.tutorlms.com/wp-json/restapi/v1/tutorpacks';
private $endpoint = TEMPLATE_LIST_ENDPOINT;

/**
* Public builder
*
*
* @var string
*/
public $builder = 'gutenberg';
/**
* Public Woocommerce plugin config
*
* @var array
*/
public $woocommerce = array();

/**
* Public Tutor LMS plugin config
*
* @var array
*/

/**
* Public Woocommerce plugin config
*
* @var array
*/
public $woocommerce = array();

/**
* Public Tutor LMS plugin config
*
* @var array
*/
public $tutor_lms = array();


/**
* Public Droip plugin config
*
* @var array
*/
public $droip = array();

/**
* Public Tutor Elementor Addon
*
* @var array
*/
public $tutor_elementor = array();

/**
* Public Qubely plugin config
*
* @var array
*/
public $qubely = array();

/**
* Public Elementor plugin config
*
* @var array
*/
/**
* Public Qubely plugin config
*
* @var array
*/
public $qubely = array();

/**
* Public Elementor plugin config
*
* @var array
*/
public $elementor = array();

/**
* Public is_droip
*
* @var array
*/
public $is_droip = array();

/**
* Public is_gutenberg
*
*
* @var array
*/
public $is_gutenberg = array();

/**
* Public is elementor
*
*
* @var array
*/
public $is_elementor = array();


/**
* Register Hooks of the Importer Plugin
*/
Expand All @@ -84,51 +104,62 @@ public function register() {
add_action( 'admin_enqueue_scripts', array( $this, 'tutormate_admin_enqueue_scripts' ) );
add_action( 'wp_ajax_tutormate_builder_data', array( $this, 'receive_builder_data' ) );
add_filter( 'tutormate_enable_wp_customize_save_hooks', array( $this, 'save_customizer_data' ) );

$this->woocommerce = array(
'base' => 'woocommerce',
'slug' => 'woocommerce',
'path' => 'woocommerce/woocommerce.php',
'title' => esc_html__( 'WooCommerce', 'tutormate' ),
'src' => 'repo',
'state' => PluginCheck::check_status( 'woocommerce/woocommerce.php' ),
);

$this->tutor_lms = array(
'base' => 'tutor',
'slug' => 'tutor',
'path' => 'tutor/tutor.php',
'title' => esc_html__( 'Tutor LMS', 'tutormate' ),
'src' => 'repo',
'state' => PluginCheck::check_status( 'tutor/tutor.php' ),

add_action( 'wp_ajax_import_droip_template', array( $this, 'import_droip_template' ) );

$this->woocommerce = array(
'base' => 'woocommerce',
'slug' => 'woocommerce',
'path' => 'woocommerce/woocommerce.php',
'title' => esc_html__( 'WooCommerce', 'tutormate' ),
'src' => 'repo',
'state' => PluginCheck::check_status( 'woocommerce/woocommerce.php' ),
);

$this->tutor_lms = array(
'base' => 'tutor',
'slug' => 'tutor',
'path' => 'tutor/tutor.php',
'title' => esc_html__( 'Tutor LMS', 'tutormate' ),
'src' => 'repo',
'state' => PluginCheck::check_status( 'tutor/tutor.php' ),
);

$this->droip = array(
'base' => 'droip',
'slug' => 'droip',
'path' => 'droip/droip.php',
'title' => esc_html__( 'Droip', 'tutormate' ),
'src' => 'thirdparty',
'state' => PluginCheck::check_status( 'droip/droip.php' ),
);

$this->tutor_elementor = array(
'base' => 'tutor-lms-elementor-addons',
'slug' => 'tutor-lms-elementor-addons',
'path' => 'tutor-lms-elementor-addons/tutor-lms-elementor-addons.php',
'title' => esc_html__( 'Tutor LMS Elementor Addons', 'tutormate' ),
'src' => 'repo',
'state' => PluginCheck::check_status( 'tutor-lms-elementor-addons/tutor-lms-elementor-addons.php' ),
);

$this->qubely = array(
'base' => 'qubely',
'slug' => 'qubely',
'path' => 'qubely/qubely.php',
'title' => esc_html__( 'Qubely', 'tutormate' ),
'src' => 'repo',
'state' => PluginCheck::check_status( 'qubely/qubely.php' ),
);

$this->elementor = array(
'base' => 'elementor',
'slug' => 'elementor',
'path' => 'elementor/elementor.php',
'title' => esc_html__( 'Elementor', 'tutormate' ),
'src' => 'repo',
'state' => PluginCheck::check_status( 'elementor/elementor.php' ),
);

$this->tutor_elementor = array(
'base' => 'tutor-lms-elementor-addons',
'slug' => 'tutor-lms-elementor-addons',
'path' => 'tutor-lms-elementor-addons/tutor-lms-elementor-addons.php',
'title' => esc_html__( 'Tutor LMS Elementor Addons', 'tutormate' ),
'src' => 'repo',
'state' => PluginCheck::check_status( 'tutor-lms-elementor-addons/tutor-lms-elementor-addons.php' ),
);

$this->qubely = array(
'base' => 'qubely',
'slug' => 'qubely',
'path' => 'qubely/qubely.php',
'title' => esc_html__( 'Qubely', 'tutormate' ),
'src' => 'repo',
'state' => PluginCheck::check_status( 'qubely/qubely.php' ),
);

$this->elementor = array(
'base' => 'elementor',
'slug' => 'elementor',
'path' => 'elementor/elementor.php',
'title' => esc_html__( 'Elementor', 'tutormate' ),
'src' => 'repo',
'state' => PluginCheck::check_status( 'elementor/elementor.php' ),
);
}

/**
Expand All @@ -138,6 +169,16 @@ public function receive_builder_data() {
return true;
}

/**
* Elementor plugins
*/
public function droip_plugins() {
return $this->is_droip = array(
$this->tutor_lms,
$this->droip,
);
}

/**
* Elementor plugins
*/
Expand Down Expand Up @@ -168,27 +209,63 @@ public function tutormate_admin_enqueue_scripts() {
if ( ! isset( $_GET['page'] ) || 'tutorstarter-demo-import' !== $_GET['page'] ) {
return;
}
wp_localize_script('tutormate-demo-importer', 'builderplugins',
wp_localize_script(
'tutormate-demo-importer',
'builderplugins',
array(
'droip_plugins' => $this->droip_plugins(),
'elementor_plugins' => $this->elementor_plugins(),
'gutenberg_plugins' => $this->gutenberg_plugins(),
)
);
}

/**
* Handles Theme Demo Imports for Content, Customizer and Widgets
*
* @return array $demo_list list of demos
*/
public function builder_plugin_list() {
if ( 'elementor' === $this->builder ) {
return $this->elementor_plugins();
} elseif ( 'gutenberg' === $this->builder ) {
return $this->gutenberg_plugins();
} elseif ( 'droip' === $this->builder ) {
return $this->droip_plugins();
}
}


public function import_droip_template() {
$selected_index = $_POST['selected'];
$builder = $_POST['builder'];

if ( 'droip' === $builder ) {
$template_json = file_get_contents( TEMPLATE_LIST_ENDPOINT );
$template_list = json_decode( $template_json, true );
$droip_template = $template_list[ $selected_index ];
$is_import = Helper::upload_layout_pack( $droip_template );
if ( $is_import ) {
return wp_send_json_success( array( 'message', 'droip template download successfully' ) );
} else {
return wp_send_json_error( array( 'message', 'Something went wrong' ) );
}
}
}

/**
* Handles Theme Demo Imports for Content, Customizer and Widgets
*
* @return array $demo_list list of demos
*/
public function import_theme_demo() {

$this->builder = isset( $_POST['builder'] ) ? sanitize_text_field( $_POST['builder'] ) : 'gutenberg';
$this->builder = isset( $_POST['builder'] ) ? sanitize_text_field( $_POST['builder'] ) : 'elementor';

$demo_list = array();
$packs_list = get_transient( 'tutorstarter_packs' );

if ( is_admin() && false === $packs_list ) {
if ( is_admin() && ! $packs_list ) {

try {

Expand All @@ -207,30 +284,30 @@ public function import_theme_demo() {
if ( is_array( $packs_list ) || ! empty( $packs_list ) ) {

foreach ( $packs_list as $packs ) {

$category_list = array();
foreach ( $packs['categories'] as $category ) {
array_push( $category_list, $category['name'] );
}

$builder_list = array();
foreach ( $packs['builders'] as $builder ) {
array_push( $builder_list, $builder['slug'] );
}

$list = array(
'import_file_name' => $packs['name'],
'categories' => $category_list,
'import_file_url' => 'elementor' === $this->builder ? $packs['elementor_content'] : $packs['content'],
'import_widget_file_url' => 'elementor' === $this->builder ? $packs['elementor_widget'] : $packs['widget'],
'import_customizer_file_url' => 'elementor' === $this->builder ? $packs['elementor_customizer'] : $packs['customizer'],
'import_preview_image_url' => $packs['preview_image'],
'builders' => $builder_list,
'plugins' => 'elementor' === $this->builder ? $this->elementor_plugins() : $this->gutenberg_plugins(),
'preview_url' => $packs['preview_url'],
'notice' => $packs['notices']
'import_file_name' => $packs['name'],
'categories' => $category_list,
'import_preview_image_url' => $packs['preview_image'],
'builders' => $builder_list,
'plugins' => $this->builder_plugin_list(),
'preview_url' => $packs['preview_url'],
'notice' => $packs['notices'],
);

if ( 'elementor' === $builder_list[0] ) {
$list['import_file_url'] = $packs['elementor_content'];
$list['import_widget_file_url'] = $packs['elementor_widget'];
$list['import_customizer_file_url'] = $packs['elementor_customizer'];
}
array_push( $demo_list, $list );
}
}
Expand All @@ -245,16 +322,16 @@ public function import_theme_demo() {
*/
public function assign_defaults( $selected_import ) {
// Assign menus to their locations.
$primary = get_term_by( 'name', 'Primary', 'nav_menu' );
//$secondary = get_term_by( 'name', 'Footer', 'nav_menu' );
$primary = get_term_by( 'name', 'Primary', 'nav_menu' );
// $secondary = get_term_by( 'name', 'Footer', 'nav_menu' );

set_theme_mod(
'nav_menu_locations',
array(
'primary' => $primary->term_id,
'primary' => $primary->term_id,
)
);

// Assign front page.
$front_page_id = get_page_by_title( $selected_import['import_file_name'] );
$blog_page_id = get_page_by_title( 'News' );
Expand All @@ -272,7 +349,7 @@ public function assign_defaults( $selected_import ) {

/**
* Save customizer data
*
*
* @return bool true
*/
public function save_customizer_data() {
Expand Down
Loading