File: /var/www/vhosts/miroglu.net/httpdocs/wp-content/themes/the-landscaper/inc/demo-content-import.php
<?php
/**
* One click demo import functions
*
* @package the-landscaper-wp
*/
/**
* Define all files that need to be imported
*/
function thelandscaper_import_files() {
return array(
array(
'import_file_name' => 'The Landscaper (SiteOrigin Page Builder)',
'local_import_file' => get_theme_file_path( 'inc/demo-files/content.xml' ),
'local_import_widget_file' => get_theme_file_path( 'inc/demo-files/widgets.json' ),
'local_import_customizer_file' => get_theme_file_path( 'inc/demo-files/customizer.dat' ),
'import_preview_image_url' => get_theme_file_uri( 'inc/demo-files/elementor/thumb-siteorigin.jpg' ),
'import_notice' => sprintf( esc_html__( 'Please use the importer only on a clean WordPress installation. You can use the %1s plugin to delete all existing content.', 'the-landscaper-wp' ), '<a href="https://wordpress.org/plugins/wp-reset/" target="_blank">WP Reset</a>' ),
'preview_url' => 'https://demos.qreativethemes.com/thelandscaper',
),
array(
'import_file_name' => 'The Landscaper (Elementor Page Builder)',
'local_import_file' => get_theme_file_path( 'inc/demo-files/elementor/content.xml' ),
'local_import_widget_file' => get_theme_file_path( 'inc/demo-files/elementor/widgets.json' ),
'local_import_customizer_file' => get_theme_file_path( 'inc/demo-files/elementor/customizer.dat' ),
'import_preview_image_url' => get_theme_file_uri( 'inc/demo-files/elementor/thumb-elementor.jpg' ),
'import_notice' => sprintf( esc_html__( 'Please use the importer only on a clean WordPress installation. You can use the %1s plugin to delete all existing content.', 'the-landscaper-wp' ), '<a href="https://wordpress.org/plugins/wp-reset/" target="_blank">WP Reset</a>' ),
'preview_url' => 'https://demos.qreativethemes.com/thelandscaper',
),
);
}
add_filter( 'ocdi/import_files', 'thelandscaper_import_files' );
/**
* Register Elementor Page Builder plugin for second import demo
*/
function thelandscaper_register_plugins( $plugins ) {
$theme_plugins = array();
if ( isset( $_GET['step'] ) && $_GET['step'] === 'import' && isset( $_GET['import'] ) ) {
if ( $_GET['import'] === '0' ) {
$theme_plugins = [
[
'name' => 'Page Builder by SiteOrigin',
'slug' => 'siteorigin-panels',
'required' => true,
],
[
'name' => 'Black Studio TinyMCE Widget',
'slug' => 'black-studio-tinymce-widget',
'required' => true,
],
[
'name' => 'Easy Fancybox',
'slug' => 'easy-fancybox',
'required' => true,
],
];
}
if ( $_GET['import'] === '1' ) {
$theme_plugins = [
[
'name' => 'Elementor Website Builder',
'slug' => 'elementor',
'required' => true,
],
];
}
}
return array_merge( $plugins, $theme_plugins );
}
add_filter( 'ocdi/register_plugins', 'thelandscaper_register_plugins' );
/**
* Filters
*/
add_filter( 'ocdi/regenerate_thumbnails_in_content_import', '__return_false' );
/**
* After import setup
*/
function thelandscaper_after_import_setup( $selected_import ) {
// Menus to Import and assign - you can remove or add as many as you want
$footer_menu = get_term_by( 'name', 'Footer Menu', 'nav_menu' );
$main_menu = get_term_by( 'name', 'Primary Navigation', 'nav_menu' );
$services_menu = get_term_by( 'name', 'Services Menu', 'nav_menu' );
set_theme_mod( 'nav_menu_locations', array(
'primary' => $main_menu->term_id,
'services-menu' => $services_menu->term_id,
'footer-menu' => $footer_menu->term_id
) );
// Set the front page and blog page
$front_page_id = get_page_by_title( 'Home' );
$blog_page_id = get_page_by_title( 'Blog' );
update_option( 'show_on_front', 'page' );
update_option( 'page_on_front', $front_page_id->ID );
update_option( 'page_for_posts', $blog_page_id->ID );
// Set 404 image in the customizer on import
set_theme_mod( 'qt_404_page_image', get_theme_file_uri( '/assets/images/404_image.png' ) );
// Disable the Font Awesome 4 shim for new demo imports
set_theme_mod( 'qt_fontawesome_fallback', 'disable' );
// Empty default breadcrumbs seperator
if ( function_exists( 'bcn_display' ) ) {
add_option( 'bcn_options', array( 'hseparator' => '' ) );
}
// Assign pages for WooCommerce
if ( thelandscaper_woocommerce_active() ) {
$shop_page_id = get_page_by_title( 'Shop' );
$cart_page_id = get_page_by_title( 'Cart' );
$checkout_page_id = get_page_by_title( 'Checkout' );
update_option( 'woocommerce_shop_page_id', $shop_page_id->ID );
update_option( 'woocommerce_cart_page_id', $cart_page_id->ID );
update_option( 'woocommerce_checkout_page_id', $checkout_page_id->ID );
}
// After import settings for Elementor demo
if ( 'The Landscaper (Elementor Page Builder)' === $selected_import['import_file_name'] ) {
// Change default Elementor Site Settings
if ( did_action( 'elementor/loaded' ) ) {
// If Elementor demo is selected deactivate SiteOrigin Page Builder plugin if activated
if ( class_exists( 'SiteOrigin_Panels' ) ) {
deactivate_plugins( 'siteorigin-panels/siteorigin-panels.php' );
}
// Disable optimized DOM output
update_option( 'elementor_experiment-e_dom_optimization', 'inactive' );
// Disable default color schemes
update_option( 'elementor_disable_color_schemes', 'yes' );
// Diable default font schemes
update_option( 'elementor_disable_typography_schemes', 'yes' );
// Enable page builder for CPT gallery
$cpt_support = get_option( 'elementor_cpt_support' );
if ( ! $cpt_support ) {
$cpt_support = array( 'page', 'post', 'portfolio' );
update_option( 'elementor_cpt_support', $cpt_support );
} else if ( ! in_array( 'portfolio', $cpt_support ) ) {
$cpt_support[] = 'portfolio';
update_option( 'elementor_cpt_support', $cpt_support );
}
// Elementor Page Builder - change default kit values
$kit = \Elementor\Plugin::$instance->kits_manager->get_active_kit();
$kit->update_settings( [
'container_width' => array(
'size' => 1140,
),
'space_between_widgets' => array(
'size' => 0,
),
'viewport_mobile' => 768,
'viewport_tablet' => 992,
'stretched_section_container' => '.content',
] );
}
}
// After import settings for SiteOrigin demo
if ( 'The Landscaper (SiteOrigin Page Builder)' === $selected_import['import_file_name'] ) {
// If SiteOrigin demo is selected deactivate Elementor Page Builder plugin if activated
if ( did_action( 'elementor/loaded' ) ) {
deactivate_plugins( 'elementor/elementor.php' );
}
}
}
add_action( 'ocdi/after_import', 'thelandscaper_after_import_setup' );