Skip to content

Commit

Permalink
Add One Click Demo Import support and configuration to theme
Browse files Browse the repository at this point in the history
  • Loading branch information
francgrasso committed Jun 24, 2020
1 parent fa6f5e1 commit 24e5c3c
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
5 changes: 5 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,3 +230,8 @@ function yith_proteo_content_width() {
if ( class_exists( 'WooCommerce' ) ) {
require get_template_directory() . '/inc/woocommerce.php';
}

/**
* One Click Demo Import predefined demo configurations file
*/
require get_template_directory() . '/inc/one-click-demo-import.php';
73 changes: 73 additions & 0 deletions inc/one-click-demo-import.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php
/**
* One Click Demo Import predefined demo configurations file
*
* @package yith-proteo
*/

/**
* Predefined demo content here
*/
function yith_proteo_ocdi_import_files() {
return array(
array(
'import_file_name' => 'Classic Shop',
'categories' => array( 'Ecommerce' ),
'import_file_url' => 'https://proteo.yithemes.com/demo-content/classic-shop/proteo-wordpress-export.xml',
'import_widget_file_url' => 'https://proteo.yithemes.com/demo-content/classic-shop/proteo.yithemes.com-classic-shop-widgets.wie',
'import_customizer_file_url' => 'https://proteo.yithemes.com/demo-content/classic-shop/yith-proteo-export.dat',
'import_preview_image_url' => 'https://proteo.yithemes.com/demo-content/classic-shop/screenshot.png',
'import_notice' => __( 'After you import this demo, check WooCommerce settings to get the best from your store.', 'yith-proteo' ),
'preview_url' => 'https://proteo.yithemes.com/classic-shop/',
),
array(
'import_file_name' => 'Classic Shop',
'categories' => array( 'Ecommerce' ),
'import_file_url' => 'https://proteo.yithemes.com/demo-content/classic-shop/proteo-wordpress-export.xml',
'import_widget_file_url' => 'https://proteo.yithemes.com/demo-content/classic-shop/proteo.yithemes.com-classic-shop-widgets.wie',
'import_customizer_file_url' => 'https://proteo.yithemes.com/demo-content/classic-shop/yith-proteo-export.dat',
'import_preview_image_url' => 'https://proteo.yithemes.com/demo-content/classic-shop/screenshot.png',
'import_notice' => __( 'After you import this demo, check WooCommerce settings to get the best from your store.', 'yith-proteo' ),
'preview_url' => 'https://proteo.yithemes.com/classic-shop/',
),
);
}
add_filter( 'pt-ocdi/import_files', 'yith_proteo_ocdi_import_files' );

/**
* Set home page, blog page and menu
*/
function yith_proteo_ocdi_after_import_setup() {
if ( 'Classic Shop' === $selected_import['import_file_name'] ) {
// Assign menus to their locations.
$main_menu = get_term_by( 'name', 'Primary', 'nav_menu' );

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

// Assign front page and posts page (blog page).
$front_page_id = get_page_by_title( 'Front Page' );
$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 );

// Assign WooCommerce pages.
$shop_page_id = get_page_by_title( 'Shop' );
$cart_page_id = get_page_by_title( 'Cart' );
$checkout_page_id = get_page_by_title( 'Checkout' );
$account_page_id = get_page_by_title( 'My Account' );

update_option( 'woocommerce_shop_page_id', $shop_page_id->ID );
update_option( 'woocommerce_cart_page_id', $shop_page_id->ID );
update_option( 'woocommerce_checkout_page_id', $shop_page_id->ID );
update_option( 'woocommerce_myaccount_page_id', $shop_page_id->ID );
}
}
add_action( 'pt-ocdi/after_import', 'yith_proteo_ocdi_after_import_setup' );
6 changes: 6 additions & 0 deletions inc/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,12 @@ function yith_proteo_register_required_plugins() {
'required' => false,
),

array(
'name' => 'One Click Demo Import',
'slug' => 'one-click-demo-import',
'required' => false,
),

);

$config = array(
Expand Down

0 comments on commit 24e5c3c

Please sign in to comment.