set_vars( $config );
$this->init();
}
/**
* Set some settings
* @since 1.0.0
* @param $config Our config parameters
*/
public function set_vars( $config ) {
// require_once trailingslashit( WHIZZIE_DIR ) . 'tgm/class-tgm-plugin-activation.php';
require_once trailingslashit( WHIZZIE_DIR ) . 'tgm/tgm.php';
// require_once trailingslashit( WHIZZIE_DIR ) . 'widgets/class-ti-widget-importer.php';
if( isset( $config['page_slug'] ) ) {
$this->page_slug = esc_attr( $config['page_slug'] );
}
if( isset( $config['page_title'] ) ) {
$this->page_title = esc_attr( $config['page_title'] );
}
if( isset( $config['steps'] ) ) {
$this->config_steps = $config['steps'];
}
$this->plugin_path = trailingslashit( dirname( __FILE__ ) );
$relative_url = str_replace( get_template_directory(), '', $this->plugin_path );
$this->plugin_url = trailingslashit( get_template_directory_uri() . $relative_url );
$current_theme = wp_get_theme();
$this->theme_title = $current_theme->get( 'Name' );
$this->theme_name = strtolower( preg_replace( '#[^a-zA-Z]#', '', $current_theme->get( 'Name' ) ) );
$this->page_slug = apply_filters( $this->theme_name . '_theme_setup_wizard_page_slug', $this->theme_name . '-wizard' );
$this->parent_slug = apply_filters( $this->theme_name . '_theme_setup_wizard_parent_slug', '' );
}
/*
* Hooks and filters
* @since 1.0.0
*/
public function init() {
// add_action( 'after_switch_theme', array( $this, 'redirect_to_wizard' ) );
if ( class_exists( 'TGM_Plugin_Activation' ) && isset( $GLOBALS['tgmpa'] ) ) {
add_action( 'init', array( $this, 'get_tgmpa_instance' ), 30 );
add_action( 'init', array( $this, 'set_tgmpa_url' ), 40 );
}
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_action( 'admin_menu', array( $this, 'menu_page' ) );
add_action( 'admin_init', array( $this, 'get_plugins' ), 30 );
add_filter( 'tgmpa_load', array( $this, 'tgmpa_load' ), 10, 1 );
add_action( 'wp_ajax_setup_plugins', array( $this, 'setup_plugins' ) );
add_action( 'wp_ajax_setup_widgets', array( $this, 'setup_widgets' ) );
}
public function enqueue_scripts($hook) {
wp_enqueue_style( 'theme-wizard-style', get_template_directory_uri() . '/theme-wizard/assets/css/theme-wizard-style.css');
wp_register_script( 'theme-wizard-script', get_template_directory_uri() . '/theme-wizard/assets/js/theme-wizard-script.js', array( 'jquery' ), time() );
wp_localize_script(
'theme-wizard-script',
'architecture_construction_whizzie_params',
array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'wpnonce' => wp_create_nonce( 'whizzie_nonce' ),
'verify_text' => esc_html( 'verifying', 'architecture-construction' )
)
);
wp_enqueue_script( 'theme-wizard-script' );
}
public static function get_instance() {
if ( ! self::$instance ) {
self::$instance = new self;
}
return self::$instance;
}
public function tgmpa_load( $status ) {
return is_admin() || current_user_can( 'install_themes' );
}
/**
* Get configured TGMPA instance
*
* @access public
* @since 1.1.2
*/
public function get_tgmpa_instance() {
$this->tgmpa_instance = call_user_func( array( get_class( $GLOBALS['tgmpa'] ), 'get_instance' ) );
}
/**
* Update $tgmpa_menu_slug and $tgmpa_parent_slug from TGMPA instance
*
* @access public
* @since 1.1.2
*/
public function set_tgmpa_url() {
$this->tgmpa_menu_slug = ( property_exists( $this->tgmpa_instance, 'menu' ) ) ? $this->tgmpa_instance->menu : $this->tgmpa_menu_slug;
$this->tgmpa_menu_slug = apply_filters( $this->theme_name . '_theme_setup_wizard_tgmpa_menu_slug', $this->tgmpa_menu_slug );
$tgmpa_parent_slug = ( property_exists( $this->tgmpa_instance, 'parent_slug' ) && $this->tgmpa_instance->parent_slug !== 'themes.php' ) ? 'admin.php' : 'themes.php';
$this->tgmpa_url = apply_filters( $this->theme_name . '_theme_setup_wizard_tgmpa_url', $tgmpa_parent_slug . '?page=' . $this->tgmpa_menu_slug );
}
/**
* Make a modal screen for the wizard
*/
public function menu_page() {
add_theme_page( esc_html( $this->page_title ), esc_html( $this->page_title ), 'manage_options', $this->page_slug, array( $this, 'architecture_construction_setup_wizard' ) );
}
/**
* Make an interface for the wizard
*/
public function wizard_page() {
tgmpa_load_bulk_installer();
// install plugins with TGM.
if ( ! class_exists( 'TGM_Plugin_Activation' ) || ! isset( $GLOBALS['tgmpa'] ) ) {
die( 'Failed to find TGM' );
}
$url = wp_nonce_url( add_query_arg( array( 'plugins' => 'go' ) ), 'whizzie-setup' );
// copied from TGM
$method = ''; // Leave blank so WP_Filesystem can populate it as necessary.
$fields = array_keys( $_POST ); // Extra fields to pass to WP_Filesystem.
if ( false === ( $creds = request_filesystem_credentials( esc_url_raw( $url ), $method, false, false, $fields ) ) ) {
return true; // Stop the normal page form from displaying, credential request form will be shown.
}
// Now we have some credentials, setup WP_Filesystem.
if ( ! WP_Filesystem( $creds ) ) {
// Our credentials were no good, ask the user for them again.
request_filesystem_credentials( esc_url_raw( $url ), $method, true, false, $fields );
return true;
}
/* If we arrive here, we have the filesystem */ ?>
';
// The wizard is a list with only one item visible at a time
$steps = $this->get_steps();
echo '';
echo '
';
foreach( $steps as $step ) {
if( isset( $step['icon'] ) && $step['icon'] ) {
echo '- ';
if (isset($step['icon1'])) {
require_once $step['icon1'];
} else {
echo '';
}
echo '
';
}
}
echo '
';
?>
false, 'msg' => 'Something Went Wrong!');
wp_send_json($response);
exit;
} else {
$response_body = wp_remote_retrieve_body( $response );
$response_body = json_decode($response_body);
if ( $response_body->is_suspended == 1 ) {
} else {
}
if ($response_body->status === false) {
$response = array('status' => false, 'msg' => $response_body->msg);
wp_send_json($response);
exit;
} else {
$response = array('status' => true, 'msg' => 'Theme Activated Successfully!');
wp_send_json($response);
exit;
}
}
}
public function architecture_construction_setup_wizard() {
?>
config_steps;
$steps = array(
'intro' => array(
'id' => 'intro',
'title' => __( 'Welcome to ', 'architecture-construction' ) . $this->theme_title,
'icon' => 'dashboard',
'icon1' => get_template_directory() . '/theme-wizard/assets/images/svg/Icon-01.svg',
'view' => 'get_step_intro', // Callback for content
'callback' => 'do_next_step', // Callback for JS
'button_text' => __( 'Start Now', 'architecture-construction' ),
'can_skip' => false // Show a skip button?
),
'plugins' => array(
'id' => 'plugins',
'title' => __( 'Plugins', 'architecture-construction' ),
'icon' => 'admin-plugins',
'icon1' => get_template_directory() . '/theme-wizard/assets/images/svg/Icon-02.svg',
'view' => 'get_step_plugins',
'callback' => 'install_plugins',
'button_text' => __( 'Install Plugins', 'architecture-construction' ),
'can_skip' => true
),
'widgets' => array(
'id' => 'widgets',
'title' => __( 'Demo Importer', 'architecture-construction' ),
'icon' => 'welcome-widgets-menus',
'icon1' => get_template_directory() . '/theme-wizard/assets/images/svg/Icon-03.svg',
'view' => 'get_step_widgets',
'callback' => 'install_widgets',
'button_text' => __( 'Import Demo', 'architecture-construction' ),
'can_skip' => true
),
'done' => array(
'id' => 'done',
'title' => __( 'All Done', 'architecture-construction' ),
'icon' => 'yes',
'icon1' => get_template_directory() . '/theme-wizard/assets/images/svg/Icon-04.svg',
'view' => 'get_step_done',
'callback' => ''
)
);
// Iterate through each step and replace with dev config values
if( $dev_steps ) {
// Configurable elements - these are the only ones the dev can update from config.php
$can_config = array( 'title', 'icon', 'button_text', 'can_skip' );
foreach( $dev_steps as $dev_step ) {
// We can only proceed if an ID exists and matches one of our IDs
if( isset( $dev_step['id'] ) ) {
$id = $dev_step['id'];
if( isset( $steps[$id] ) ) {
foreach( $can_config as $element ) {
if( isset( $dev_step[$element] ) ) {
$steps[$id][$element] = $dev_step[$element];
}
}
}
}
}
}
return $steps;
}
/**
* Print the content for the intro step
*/
public function get_step_intro() { ?>
get_plugins();
$content = array(); ?>
';
$plugins['all'] = $this->moveArrayPosition($plugins['all'], 'woocommerce', 0);
// Add each plugin into a list
foreach( $plugins['all'] as $slug=>$plugin ) {
$content['detail'] .= '' . esc_html( $plugin['name'] ) . '';
$keys = array();
if ( isset( $plugins['install'][ $slug ] ) ) {
$keys[] = 'Installation';
}
if ( isset( $plugins['update'][ $slug ] ) ) {
$keys[] = 'Update';
}
if ( isset( $plugins['activate'][ $slug ] ) ) {
$keys[] = 'Activation';
}
$content['detail'] .= implode( ' and ', $keys ) . ' required';
$content['detail'] .= '';
}
$content['detail'] .= '';
return $content;
}
function moveArrayPosition(&$array, $key, $new_position) {
if (!array_key_exists($key, $array)) {
return $array;
}
$item = $array[$key];
unset($array[$key]);
$result = [];
$position_added = false;
foreach ($array as $current_key => $current_value) {
if (!$position_added && $new_position === count($result)) {
$result[$key] = $item;
$position_added = true;
}
$result[$current_key] = $current_value;
}
if (!$position_added) {
$result[$key] = $item;
}
$array = $result;
return $array;
}
/**
* Print the content for the widgets step
* @since 1.1.0
*/
public function get_step_widgets() { ?>
array(),
'install' => array(),
'update' => array(),
'activate' => array()
);
foreach( $instance->plugins as $slug=>$plugin ) {
if( $instance->is_plugin_active( $slug ) && false === $instance->does_plugin_have_update( $slug ) ) {
// Plugin is installed and up to date
continue;
} else {
$plugins['all'][$slug] = $plugin;
if( ! $instance->is_plugin_installed( $slug ) ) {
$plugins['install'][$slug] = $plugin;
} else {
if( false !== $instance->does_plugin_have_update( $slug ) ) {
$plugins['update'][$slug] = $plugin;
}
if( $instance->can_plugin_activate( $slug ) ) {
$plugins['activate'][$slug] = $plugin;
}
}
}
}
return $plugins;
}
/**
* Get the widgets.wie file from the /content folder
* @return Mixed Either the file or false
* @since 1.1.0
*/
public function setup_plugins() {
if ( ! check_ajax_referer( 'whizzie_nonce', 'wpnonce' ) || empty( $_POST['slug'] ) ) {
wp_send_json_error( array( 'error' => 1, 'message' => esc_html__( 'No Slug Found','architecture-construction' ) ) );
}
$json = array();
// send back some json we use to hit up TGM
$plugins = $this->get_plugins();
// what are we doing with this plugin?
foreach ( $plugins['activate'] as $slug => $plugin ) {
if ( $_POST['slug'] == $slug ) {
$json = array(
'url' => admin_url( $this->tgmpa_url ),
'plugin' => array( $slug ),
'tgmpa-page' => $this->tgmpa_menu_slug,
'plugin_status' => 'all',
'_wpnonce' => wp_create_nonce( 'bulk-plugins' ),
'action' => 'tgmpa-bulk-activate',
'action2' => - 1,
'message' => esc_html__( 'Activating Plugin','architecture-construction' ),
);
break;
}
}
foreach ( $plugins['update'] as $slug => $plugin ) {
if ( $_POST['slug'] == $slug ) {
$json = array(
'url' => admin_url( $this->tgmpa_url ),
'plugin' => array( $slug ),
'tgmpa-page' => $this->tgmpa_menu_slug,
'plugin_status' => 'all',
'_wpnonce' => wp_create_nonce( 'bulk-plugins' ),
'action' => 'tgmpa-bulk-update',
'action2' => - 1,
'message' => esc_html__( 'Updating Plugin','architecture-construction' ),
);
break;
}
}
foreach ( $plugins['install'] as $slug => $plugin ) {
if ( $_POST['slug'] == $slug ) {
$json = array(
'url' => admin_url( $this->tgmpa_url ),
'plugin' => array( $slug ),
'tgmpa-page' => $this->tgmpa_menu_slug,
'plugin_status' => 'all',
'_wpnonce' => wp_create_nonce( 'bulk-plugins' ),
'action' => 'tgmpa-bulk-install',
'action2' => - 1,
'message' => esc_html__( 'Installing Plugin','architecture-construction' ),
);
break;
}
}
if ( $json ) {
$json['hash'] = md5( serialize( $json ) ); // used for checking if duplicates happen, move to next plugin
wp_send_json( $json );
} else {
wp_send_json( array( 'done' => 1, 'message' => esc_html__( 'Success','architecture-construction' ) ) );
}
exit;
}
public static function get_page_id_by_title($pagename){
$args = array(
'post_type' => 'page',
'posts_per_page' => 1,
'post_status' => 'publish',
'title' => $pagename
);
$query = new WP_Query( $args );
$page_id = '1';
if (isset($query->post->ID)) {
$page_id = $query->post->ID;
}
return $page_id;
}
public function create_theme_nav_menu(){
// ------- Create Nav Menu --------
$menuname = 'Primary Menu';
$bpmenulocation = 'primary';
$menu_exists = wp_get_nav_menu_object( $menuname );
if( !$menu_exists){
$menu_id = wp_create_nav_menu($menuname);
wp_update_nav_menu_item($menu_id, 0, array(
'menu-item-title' => __('Home','architecture-construction'),
'menu-item-classes' => 'home-page',
'menu-item-url' => home_url( '/' ),
'menu-item-status' => 'publish'));
wp_update_nav_menu_item($menu_id, 0, array(
'menu-item-title' => __('About','architecture-construction'),
'menu-item-classes' => 'about',
'menu-item-url' => get_permalink(Whizzie::get_page_id_by_title('About')),
'menu-item-status' => 'publish',
));
wp_update_nav_menu_item($menu_id, 0, array(
'menu-item-title' => __('Exhibitions','architecture-construction'),
'menu-item-classes' => 'exhibitions',
'menu-item-url' => get_permalink(Whizzie::get_page_id_by_title('Exhibitions')),
'menu-item-status' => 'publish',
));
wp_update_nav_menu_item($menu_id, 0, array(
'menu-item-title' => __('Shop','architecture-construction'),
'menu-item-classes' => 'shop',
'menu-item-url' => get_permalink(Whizzie::get_page_id_by_title('Shop')),
'menu-item-status' => 'publish',
));
wp_update_nav_menu_item($menu_id, 0, array(
'menu-item-title' => __('Blog','architecture-construction'),
'menu-item-classes' => 'blog',
'menu-item-url' => get_permalink(Whizzie::get_page_id_by_title('Blog')),
'menu-item-status' => 'publish',
));
wp_update_nav_menu_item($menu_id, 0, array(
'menu-item-title' => __('Contact','architecture-construction'),
'menu-item-classes' => 'contact',
'menu-item-url' => get_permalink(Whizzie::get_page_id_by_title('Contact')),
'menu-item-status' => 'publish',
));
if( !has_nav_menu( $bpmenulocation ) ){
$locations = get_theme_mod('nav_menu_locations');
$locations[$bpmenulocation] = $menu_id;
set_theme_mod( 'nav_menu_locations', $locations );
}
}
}
public function setup_widgets() {
$architecture_construction_home_content = '';
// Create a front page and assigned the template
$home_title = 'Home';
$home_check = get_page_by_title($home_title);
$home = array(
'post_type' => 'page',
'post_title' => $home_title,
'post_content' => $architecture_construction_home_content,
'post_status' => 'publish',
'post_author' => 1,
'post_slug' => 'home'
);
$home_id = wp_insert_post($home);
//Set the home page template
add_post_meta( $home_id, '_wp_page_template', '/template-home.php' );
//Set the static front page
update_option( 'page_on_front', $home_id );
update_option( 'show_on_front', 'page' );
// Create a terms page and assign the template (Blogs page)
$terms_title = 'About';
$terms_check = get_page_by_title($terms_title);
$terms = array(
'post_type' => 'page',
'post_title' => $terms_title,
'post_status' => 'publish',
'post_author' => 1,
'post_slug' => 'about',
'post_content' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
);
$terms_id = wp_insert_post($terms);
// Create a terms page and assigned the template
$terms_title = 'Exhibitions';
$terms_check = get_page_by_title($terms_title);
$terms = array(
'post_type' => 'page',
'post_title' => $terms_title,
'post_status' => 'publish',
'post_author' => 1,
'post_slug' => 'exhibitions',
'post_content' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
);
$terms_id = wp_insert_post($terms);
//Set the blog with right sidebar template
add_post_meta( $about_id, '_wp_page_template', 'page-template/about.php' );
// Create a terms page and assigned the template
$terms_title = 'Shop';
$terms_check = get_page_by_title($terms_title);
$terms = array(
'post_type' => 'page',
'post_title' => $terms_title,
'post_status' => 'publish',
'post_author' => 1,
'post_slug' => 'shop',
'post_content' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
);
$terms_id = wp_insert_post($terms);
//Set the blog with right sidebar template
add_post_meta( $about_id, '_wp_page_template', 'page-template/about.php' );
// Create a terms page and assigned the template
$terms_title = 'Blog';
$terms_check = get_page_by_title($terms_title);
$terms = array(
'post_type' => 'page',
'post_title' => $terms_title,
'post_status' => 'publish',
'post_author' => 1,
'post_slug' => 'blog',
'post_content' => '',
);
$terms_id = wp_insert_post($terms);
// Set the Blogs page as the posts page
update_option( 'page_for_posts', $terms_id );
//Set the blog with right sidebar template
add_post_meta( $about_id, '_wp_page_template', 'page-template/about.php' );
// Create a terms page and assigned the template
$terms_title = 'Contact';
$terms_check = get_page_by_title($terms_title);
$terms = array(
'post_type' => 'page',
'post_title' => $terms_title,
'post_status' => 'publish',
'post_author' => 1,
'post_slug' => 'contact',
'post_content' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
);
$terms_id = wp_insert_post($terms);
//Set the blog with right sidebar template
add_post_meta( $about_id, '_wp_page_template', 'page-template/about.php' );
/*--- Header Start---*/
set_theme_mod( 'architecture_construction_header_setting', true);
set_theme_mod( 'architecture_construction_header_line', 'We will go through all the stages of construction');
set_theme_mod( 'architecture_construction_header_email', 'Construction@example.com');
set_theme_mod( 'architecture_construction_header_phone', '+123 456 7890');
set_theme_mod( 'architecture_construction_header_location', 'Mumbai1234yourlocation');
set_theme_mod( 'architecture_construction_header_btn_text', 'MAKE AN APPOINTMENT');
set_theme_mod( 'architecture_construction_header_btn_url', '#');
/*--- Header End---*/
/* Social Icon Start */
set_theme_mod( 'architecture_construction_social_icon_setting', true);
set_theme_mod( 'architecture_construction_social_link_1', '#');
set_theme_mod( 'architecture_construction_social_link_2', '#');
set_theme_mod( 'architecture_construction_social_link_3', '#');
set_theme_mod( 'architecture_construction_social_link_4', '#');
/* Social Icon End */
/*--- Slider Start---*/
set_theme_mod( 'architecture_construction_slider_setting', true);
set_theme_mod( 'architecture_construction_slider_button_setting', true);
$architecture_construction_latest_post_category = wp_create_category('Slider Post');
set_theme_mod( 'architecture_construction_blog_slide_category', 'Slider Post' );
for($i=1; $i<=3; $i++) {
$title = array(
'WE CREATE MEGA CONSTRUCTION FOR YOUR BETTER LIFE',
'Building Dreams with Strong Foundations',
'Innovative Architecture That Inspires Modern Living'
);
$content = 'Lorem Ipsum has been the industrys standard dummy text ever since the 1500 when an unknown printer took a galley of type and scrambled it to make a type specimen book Lorem Ipsum has been the industrys standard dummy text ever since the 1500';
// Create post object
$architecture_construction_my_post = array(
'post_title' => wp_strip_all_tags($title[$i-1]),
'post_content' => $content,
'post_status' => 'publish',
'post_type' => 'post',
'post_category' => array($architecture_construction_latest_post_category)
);
// Insert the post into the database
$architecture_construction_post_id = wp_insert_post( $architecture_construction_my_post );
$architecture_construction_image_url = get_template_directory_uri().'/theme-wizard/assets/images/slider'.$i.'.png';
$architecture_construction_image_name= 'slider'.$i.'.png';
$architecture_construction_upload_dir = wp_upload_dir();
// Set upload folder
$architecture_construction_image_data = file_get_contents($architecture_construction_image_url);
// Get image data
$architecture_construction_unique_file_name = wp_unique_filename( $architecture_construction_upload_dir['path'], $architecture_construction_image_name );
// Generate unique name
$filename= basename( $architecture_construction_unique_file_name );
// Create image file name
// Check folder permission and define file location
if( wp_mkdir_p( $architecture_construction_upload_dir['path'] ) ) {
$file = $architecture_construction_upload_dir['path'] . '/' . $filename;
} else {
$file = $architecture_construction_upload_dir['basedir'] . '/' . $filename;
}
// Create the image file on the server
if ( ! function_exists( 'WP_Filesystem' ) ) {
require_once( ABSPATH . 'wp-admin/includes/file.php' );
}
WP_Filesystem();
global $wp_filesystem;
if ( ! $wp_filesystem->put_contents( $file, $architecture_construction_image_data, FS_CHMOD_FILE ) ) {
wp_die( 'Error saving file!' );
}
$architecture_construction_wp_filetype = wp_check_filetype( $filename, null );
$architecture_construction_attachment = array(
'post_mime_type' => $architecture_construction_wp_filetype['type'],
'post_title' => sanitize_file_name( $filename ),
'post_content' => '',
'post_type' => 'post',
'post_status' => 'inherit'
);
$architecture_construction_attach_id = wp_insert_attachment( $architecture_construction_attachment, $file, $architecture_construction_post_id );
require_once(ABSPATH . 'wp-admin/includes/image.php');
$architecture_construction_attach_data = wp_generate_attachment_metadata( $architecture_construction_attach_id, $file );
wp_update_attachment_metadata( $architecture_construction_attach_id, $architecture_construction_attach_data );
set_post_thumbnail( $architecture_construction_post_id, $architecture_construction_attach_id );
}
/*--- Slider End---*/
/* About Us Section Start */
set_theme_mod( 'architecture_construction_about_setting', true );
set_theme_mod( 'architecture_construction_featured_mission_section_text', 'LOREM IPSUM DOLOR' );
set_theme_mod( 'architecture_construction_featured_mission_section_title', 'WHAT WE DO' );
set_theme_mod( 'architecture_construction_work_tab_title', 'How It Work' );
set_theme_mod( 'architecture_construction_work_tab_step_1', 'Field Analysis' );
set_theme_mod( 'architecture_construction_work_tab_step_2', 'Condition Experiment' );
set_theme_mod( 'architecture_construction_work_tab_step_3', 'Final Output' );
$num_items = 5;
set_theme_mod( 'architecture_construction_number_of_featured_mission_items', $num_items );
$architecture_construction_tab_titles = array(
'Renovation',
'Architect',
'Roofing',
'Painting',
'Plumbing'
);
$architecture_construction_page_titles = array(
'Renovation',
'Architect',
'Roofing',
'Painting',
'Plumbing'
);
$architecture_construction_page_content = 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.';
for ( $i = 1; $i <= $num_items; $i++ ) {
$title = $architecture_construction_page_titles[ $i - 1 ];
$page = get_page_by_title( $title );
if ( ! $page ) {
$page_id = wp_insert_post( array(
'post_title' => wp_strip_all_tags( $title ),
'post_content' => $architecture_construction_page_content,
'post_status' => 'publish',
'post_type' => 'page',
) );
if ( ! is_wp_error( $page_id ) ) {
$image_url = get_template_directory_uri() . '/theme-wizard/assets/images/about' . $i . '.png';
$image_id = media_sideload_image( $image_url, $page_id, null, 'id' );
if ( ! is_wp_error( $image_id ) ) {
set_post_thumbnail( $page_id, $image_id );
}
set_theme_mod( 'architecture_construction_featured_mission_post_' . $i, $page_id );
}
} else {
$page_id = $page->ID;
set_theme_mod( 'architecture_construction_featured_mission_post_' . $i, $page_id );
}
set_theme_mod( 'architecture_construction_featured_mission_section_tab_' . $i, $architecture_construction_tab_titles[ $i - 1 ] );
}
/* About Us Section End */
/*--- Logo Start---*/
$image_url = get_template_directory_uri().'/theme-wizard/assets/images/logo.png';
$image_name = 'logo.png';
$upload_dir = wp_upload_dir();
// Set upload folder
$image_data_1 = file_get_contents(esc_url($image_url));
// Get image data
$unique_file_name = wp_unique_filename($upload_dir['path'], $image_name);
// Generate unique name
$filename = basename($unique_file_name);
// Create image file name
// Check folder permission and define file location
if (wp_mkdir_p($upload_dir['path'])) {
$file = $upload_dir['path'].'/'.$filename;
} else {
$file = $upload_dir['basedir'].'/'.$filename;
}
// Create the image file on the server
if ( ! function_exists( 'WP_Filesystem' ) ) {
require_once( ABSPATH . 'wp-admin/includes/file.php' );
}
WP_Filesystem();
global $wp_filesystem;
if ( ! $wp_filesystem->put_contents( $file, $image_data_1, FS_CHMOD_FILE ) ) {
wp_die( 'Error saving file!' );
}
// Check image file type
$wp_filetype = wp_check_filetype($filename, null);
// Set attachment data
$attachment = array(
'post_mime_type' => $wp_filetype['type'],
'post_title' => sanitize_file_name($filename),
'post_type' => '',
'post_status' => 'inherit',
);
// Create the attachment
$attach_id = wp_insert_attachment($attachment, $file);
set_theme_mod( 'custom_logo', $attach_id );
/*--- Logo End---*/
$this->create_theme_nav_menu();
}
}