File "demo-importer-ocdi.php"
Full Path: /home/flipjqml/onlinebetsolution.com/wp-content/plugins/cyarb-toolkit/inc/demo-importer-ocdi.php
File size: 5.47 KB
MIME-type: text/x-php
Charset: utf-8
<?php
/**
* Demo Import with One Click Demo Importer Plugin
*/
if (! defined('ABSPATH')) {
exit;
}
class Demo_Importer_OCDI
{
public function __construct()
{
add_filter('pt-ocdi/import_files', array( $this, 'demo_config' ));
add_filter('pt-ocdi/after_import', array( $this, 'after_import' ));
add_filter('pt-ocdi/disable_pt_branding', '__return_true');
}
public function demo_config()
{
$demos_array = array(
'demo1' => array(
'title' => __('Cyber Security Agency', 'cyarb-toolkit'),
'page' => __('Home One', 'cyarb-toolkit'),
'screenshot' => 'https://preview.envytheme.com/cyarb-wp/assets/img/demos/home1.jpg',
'preview_link' => 'https://themes.envytheme.com/cyarb/',
),
'demo2' => array(
'title' => __('Cyber Security Consulting', 'cyarb-toolkit'),
'page' => __('Home Two', 'cyarb-toolkit'),
'screenshot' => 'https://preview.envytheme.com/cyarb-wp/assets/img/demos/home2.jpg',
'preview_link' => 'https://themes.envytheme.com/cyarb/home-two',
),
'demo3' => array(
'title' => __('Data Security Agency', 'cyarb-toolkit'),
'page' => __('Home Three', 'cyarb-toolkit'),
'screenshot' => 'https://preview.envytheme.com/cyarb-wp/assets/img/demos/home3.jpg',
'preview_link' => 'https://themes.envytheme.com/cyarb/home-three',
),
'demo4' => array(
'title' => __('Internet Security Agency', 'cyarb-toolkit'),
'page' => __('Home Four', 'cyarb-toolkit'),
'screenshot' => 'https://preview.envytheme.com/cyarb-wp/assets/img/demos/home4.jpg',
'preview_link' => 'https://themes.envytheme.com/cyarb/home-four',
),
'demo5' => array(
'title' => __('Network Security Company', 'cyarb-toolkit'),
'page' => __('Home Five', 'cyarb-toolkit'),
'screenshot' => 'https://preview.envytheme.com/cyarb-wp/assets/img/demos/home5.jpg',
'preview_link' => 'https://themes.envytheme.com/cyarb/home-five',
),
'demo6' => array(
'title' => __('Crypto Agency', 'cyarb-toolkit'),
'page' => __('Home Six', 'cyarb-toolkit'),
'screenshot' => 'https://preview.envytheme.com/cyarb-wp/assets/img/demos/home6.jpg',
'preview_link' => 'https://themes.envytheme.com/cyarb/home-six',
),
'demo7' => array(
'title' => __('Digital Forensic Company', 'cyarb-toolkit'),
'page' => __('Home Seven', 'cyarb-toolkit'),
'screenshot' => 'https://preview.envytheme.com/cyarb-wp/assets/img/demos/home7.jpg',
'preview_link' => 'https://themes.envytheme.com/cyarb/home-seven/',
),
);
$config = array();
$import_path = trailingslashit(get_template_directory()) . 'lib/sample-data/';
$redux_option = 'cyarb_opt';
foreach ($demos_array as $key => $demo) {
$config[] = array(
'import_file_id' => $key,
'import_page_name' => $demo['page'],
'import_file_name' => $demo['title'],
'local_import_file' => $import_path . 'contents.xml',
'local_import_widget_file' => $import_path . 'widgets.wie',
'local_import_customizer_file' => $import_path . 'customizer.dat',
'local_import_redux' => array(
array(
'file_path' => $import_path . 'options.json',
'option_name' => $redux_option,
),
),
'import_preview_image_url' => $demo['screenshot'],
'preview_url' => $demo['preview_link'],
);
}
return $config;
}
public function after_import($selected_import)
{
$this->assign_menu();
$this->assign_frontpage($selected_import);
$this->assign_woocommerce_pages();
$this->update_permalinks();
}
private function assign_menu()
{
$primary = get_term_by('name', 'Primary Menu', 'nav_menu');
set_theme_mod('nav_menu_locations', array(
'primary' => $primary->term_id,
));
}
private function assign_frontpage($selected_import)
{
$blog_page = get_page_by_title('Blog');
$front_page = get_page_by_title($selected_import['import_page_name']);
update_option('show_on_front', 'page');
update_option('page_on_front', $front_page->ID);
update_option('page_for_posts', $blog_page->ID);
}
private function assign_woocommerce_pages()
{
$shop = get_page_by_title('Shop');
$cart = get_page_by_title('Cart');
$checkout = get_page_by_title('Checkout');
$account = get_page_by_title('My Account');
update_option('woocommerce_shop_page_id', $shop->ID);
update_option('woocommerce_cart_page_id', $cart->ID);
update_option('woocommerce_checkout_page_id', $checkout->ID);
update_option('woocommerce_myaccount_page_id', $account->ID);
}
private function update_permalinks()
{
update_option('permalink_structure', '/%postname%/');
}
}
new Demo_Importer_OCDI;