fetch_attachments = true;
$upload_dir = wp_upload_dir();
if (is_writable($upload_dir['path'])) {
ob_start();
$import->import($_POST['filename']);
$text = ob_get_contents();
ob_end_clean();
$response = array(
'status' => 'success',
'text' => $text
);
die(json_encode($response));
} else {
$response = array(
'status' => 'error',
'text' => __('Wordpress upload dir permission denied. Please temporally set permissions "777" for "wp-content/upload/".', 'artwork-lite')
);
die(json_encode($response));
}
}
add_action('wp_ajax_start_import', 'theme_import_dummy');
add_action('wp_ajax_nopriv_start_import', 'theme_import_dummy');
/**
* Theme_Admin_Setup_Wizard class
*/
class Theme_Admin_Setup_Wizard {
/** @var string Currenct Step */
private $step = '';
/** @var array Steps for the setup wizard */
private $steps = array();
/**
* Hook in tabs.
*/
public function __construct() {
add_action('admin_menu', array($this, 'theme_admin_menus'));
add_action('admin_init', array($this, 'theme_setup_wizard'));
}
/**
* Add admin menus/screens.
*/
public function theme_admin_menus() {
add_theme_page(__('Theme Wizard', 'artwork-lite'), __('Theme Wizard', 'artwork-lite'), 'manage_options', 'theme-setup', 'theme_setup_wizard');
//call register settings function
add_action('admin_init', array($this, 'theme_register_post_type_name_settings'));
}
public function theme_register_post_type_name_settings() {
register_setting('theme-work-settings-group', 'theme_post_type_name');
register_setting('theme-work-settings-group', 'theme_post_type_slug');
}
public function theme_posttype_name_sanitize_text($txt) {
$txt = strip_tags($txt, '');
$txt = preg_replace("/[^a-zA-Z0-9-]+/", "", $txt);
$txt = substr(strtolower($txt), 0, 19);
return wp_kses_post(force_balance_tags($txt));
}
function theme_post_type_name_page() {
$theme_post_type_name = get_option('theme_post_type_name');
$theme_post_type_slug = $this->theme_posttype_name_sanitize_text(get_option('theme_post_type_slug'));
if (empty($theme_post_type_name)) {
$theme_post_type_name = __("Works", 'artwork-lite');
}
if (empty($theme_post_type_slug)) {
$theme_post_type_slug = "works";
}
?>
steps = array(
'introduction' => array(
'name' => __('Start', 'artwork-lite'),
'view' => array($this, 'theme_setup_introduction'),
'handler' => ''
),
'customizer' => array(
'name' => __('Customizer', 'artwork-lite'),
'view' => array($this, 'theme_setup_customizer'),
'handler' => ''
),
'section' => array(
'name' => __('Front Page', 'artwork-lite'),
'view' => array($this, 'theme_setup_section'),
'handler' => ''
),
'pages' => array(
'name' => __('Pages', 'artwork-lite'),
'view' => array($this, 'theme_setup_pages'),
'handler' => ''
),
'install_pages' => array(
'name' => __('Install Pages', 'artwork-lite'),
'view' => array($this, 'theme_setup_install_pages'),
'handler' => ''
),
'templates' => array(
'name' => __('Templates', 'artwork-lite'),
'view' => array($this, 'theme_setup_page_templates'),
'handler' => ''
),
'plugins' => array(
'name' => __('Plugins', 'artwork-lite'),
'view' => array($this, 'theme_setup_plugins'),
'handler' => ''
),
'install_plugins' => array(
'name' => __('Install Plugins', 'artwork-lite'),
'view' => array($this, 'theme_setup_install_plugins'),
'handler' => ''
),
'import_dummy' => array(
'name' => __('Sample Content', 'artwork-lite'),
'view' => array($this, 'theme_setup_import'),
'handler' => ''
),
'post_type_name' => array(
'name' => __('Post Type', 'artwork-lite'),
'view' => array($this, 'theme_setup_post_type_name'),
'handler' => ''
),
'ready' => array(
'name' => __('Ready', 'artwork-lite'),
'view' => array($this, 'theme_setup_ready'),
'handler' => ''
)
);
$this->step = isset($_GET['step']) ? sanitize_key($_GET['step']) : current(array_keys($this->steps));
wp_enqueue_style('bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css', array(), '3.3.5', 'all');
wp_enqueue_style('main', get_template_directory_uri() . '/css/artwork-style.min.css', array('bootstrap'), '1.0', 'all');
add_thickbox();
wp_enqueue_script('theme-importer', get_template_directory_uri() . '/js/importer.min.js', array('jquery',));
wp_register_script('thickbox', get_template_directory_uri() . '/wp-includes/js/thickbox/thickbox.js', array('jquery'));
wp_localize_script('theme-importer', 'sysvar', array('adminajax' => admin_url('admin-ajax.php'),));
if (!empty($_POST['save_step']) && isset($this->steps[$this->step]['handler'])) {
call_user_func($this->steps[$this->step]['handler']);
}
ob_start();
$this->theme_setup_wizard_header();
$this->theme_setup_wizard_steps();
$this->theme_setup_wizard_content();
$this->theme_setup_wizard_footer();
exit;
}
public function theme_get_next_step_link() {
$keys = array_keys($this->steps);
return add_query_arg('step', $keys[array_search($this->step, array_keys($this->steps)) + 1], remove_query_arg('translation_updated'));
}
public function theme_get_before_step_link($step) {
$keys = array_keys($this->steps);
return add_query_arg('step', $keys[array_search($this->step, array_keys($this->steps)) - $step], remove_query_arg('translation_updated'));
}
public function theme_setup_post_type_name() {
?>
theme_post_type_name_page();
?>
steps;
?>
$step) : ?>
';
call_user_func($this->steps[$this->step]['view']);
echo '';
}
/**
* Introduction step
*/
public function theme_setup_introduction() {
?>
Theme Wizard menu.', 'artwork-lite'); ?>
Customize to change logo, website title, contact information, colors, menu items and so on. Once you are happy with your changes, click Save&Publish to reflect them on your live site.', 'artwork-lite'); ?>
theme_checkPages()) : ?>
steps);
$url = add_query_arg('step', $keys[array_search($this->step, array_keys($this->steps)) + 3], remove_query_arg('translation_updated'));
?>
Works.', 'artwork-lite'); ?>
Works', 'artwork-lite'); ?>
theme_checkPages()) : ?>
steps);
$url = add_query_arg('step', $keys[array_search($this->step, array_keys($this->steps)) + 3], remove_query_arg('translation_updated'));
?>
theme_checkPlugins()) : ?>
steps);
$url = add_query_arg('step', $keys[array_search($this->step, array_keys($this->steps)) + 3], remove_query_arg('translation_updated'));
?>
theme_checkPlugins()) : ?>
steps);
$url = add_query_arg('step', $keys[array_search($this->step, array_keys($this->steps)) + 3], remove_query_arg('translation_updated'));
?>
theme_check_import()):
?>
get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'publish' AND post_name = %s LIMIT 1;", $slug));
if ($page_found)
return true;
return false;
}
/**
* Setup plugin
*/
public function theme_setup_plugins() {
$installed_plugins = get_plugins();
if ($this->theme_checkPlugins()) :
wp_redirect(esc_url(home_url('/wp-admin/admin.php?page=theme-setup')));
else:
?>
0) {
if (array_key_exists("about", $array)) {
echo '';
echo __('About page', 'artwork-lite');
echo ' ';
theme_create_page();
}
} else {
wp_redirect(esc_url(home_url('/wp-admin/admin.php?page=theme-setup')));
}
?>
theme_checkPages()) :
wp_redirect(esc_url(home_url('/wp-admin/admin.php?page=theme-setup')));
else:
?>
0) {
require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
if (array_key_exists("mp_artwork_install", $array) || array_key_exists("mp_artwork_activate", $array)) {
echo __('Works for Artwork theme ', 'artwork-lite');
}
if (array_key_exists("mp_artwork_install", $array)) {
$plugin = 'mp-artwork';
$url = get_template_directory_uri() . '/assets/mp-artwork.zip';
theme_install_plugin($plugin, $url);
$plugin_path = 'mp-artwork/mp-artwork.php';
$plugin_name = __('Works for Artwork theme', 'artwork-lite');
echo '' . sprintf(__('Activating %s plugin...', 'artwork-lite'), $plugin_name) . '
';
theme_activate_plugin($plugin_name, $plugin_path);
echo ' ';
}
if (array_key_exists("mp_artwork_activate", $array)) {
$plugin_path = 'mp-artwork/mp-artwork.php';
$plugin_name = __('Works for Artwork theme', 'artwork-lite');
echo '' . sprintf(__('Activating %s plugin...', 'artwork-lite'), $plugin_name) . '
';
theme_activate_plugin($plugin_name, $plugin_path);
echo ' ';
}
if (array_key_exists("motopress_lite_install", $array) || array_key_exists("motopress_lite_activate", $array)) {
echo __('MotoPress Content Editor Lite ', 'artwork-lite');
}
if (array_key_exists("motopress_lite_install", $array)) {
$plugin = 'motopress-content-editor-lite';
$url = 'https://downloads.wordpress.org/plugin/motopress-content-editor-lite.zip';
theme_install_plugin($plugin, $url);
$plugin_path = 'motopress-content-editor-lite/motopress-content-editor.php';
$plugin_name = __('MotoPress Content Editor Lite', 'artwork-lite');
echo '' . sprintf( __('Activating %s plugin...', 'artwork-lite' ), $plugin_name) . '
';
theme_activate_plugin($plugin_name, $plugin_path);
echo ' ';
}
if (array_key_exists("motopress_lite_activate", $array)) {
$plugin_path = 'motopress-content-editor-lite/motopress-content-editor.php';
$plugin_name = __('MotoPress Content Editor Lite', 'artwork-lite' );
echo '' . sprintf( __('Activating %s plugin...', 'artwork-lite' ), $plugin_name). '
';
theme_activate_plugin($plugin_name, $plugin_path);
echo ' ';
}
if (array_key_exists("importer_install", $array) || array_key_exists("importer_activate", $array)) {
echo __('WordPress Importer ', 'artwork-lite');
}
if (array_key_exists("importer_install", $array)) {
$plugin = 'wordpress-importer';
$url = 'https://downloads.wordpress.org/plugin/wordpress-importer.0.6.1.zip';
theme_install_plugin($plugin, $url);
$plugin_path = 'wordpress-importer/wordpress-importer.php';
$plugin_name = __('WordPress Importer', 'artwork-lite');
echo '' . sprintf(__('Activating %s plugin...', 'artwork-lite'), $plugin_name) . '
';
theme_activate_plugin($plugin_name, $plugin_path);
echo ' ';
}
if (array_key_exists("importer_activate", $array)) {
$plugin_path = 'wordpress-importer/wordpress-importer.php';
$plugin_name = __('WordPress Importer', 'artwork-lite');
echo '' . sprintf(__('Activating %s plugin...', 'artwork-lite'), $plugin_name) . '
';
theme_activate_plugin($plugin_name, $plugin_path);
echo ' ';
}
if (array_key_exists("regenerate_thumbnails_install", $array) || array_key_exists("regenerate_thumbnails_activate", $array)) {
echo __('Regenerate Thumbnails ', 'artwork-lite');
}
if (array_key_exists("regenerate_thumbnails_install", $array)) {
$plugin = 'regenerate-thumbnails';
$url = 'https://downloads.wordpress.org/plugin/regenerate-thumbnails.zip';
theme_install_plugin($plugin, $url);
$plugin_path = 'regenerate-thumbnails/regenerate-thumbnails.php';
$plugin_name = __('Regenerate Thumbnails', 'artwork-lite');
echo '' . sprintf(__('Activating %s plugin...', 'artwork-lite'), $plugin_name) . '
';
theme_activate_plugin($plugin_name, $plugin_path);
echo ' ';
}
if (array_key_exists("regenerate_thumbnails_activate", $array)) {
$plugin_path = 'regenerate-thumbnails/regenerate-thumbnails.php';
$plugin_name = __('Regenerate Thumbnails', 'artwork-lite');
echo '' . sprintf(__('Activating %s plugin...', 'artwork-lite'), $plugin_name) . '
';
theme_activate_plugin($plugin_name, $plugin_path);
echo ' ';
}
} else {
wp_redirect(esc_url(home_url('/wp-admin/admin.php?page=theme-setup')));
}
?>
>
Theme Quick Guided Tour
install($url);
//Flush plugins cache so we can make sure that the installed plugins list is always up to date
wp_cache_flush();
}
function theme_activate_plugin($plugin_name, $plugin_path) {
$result = activate_plugin($plugin_path);
if (is_wp_error($result)) {
echo '' . $plugin_name . ' ' . __('plugin is not activated', 'artwork-lite') . '
';
} else {
echo '' . $plugin_name . ' ' . __('plugin is activated', 'artwork-lite') . '
';
}
}
function theme_create_page() {
global $wpdb;
echo '' . __('Creating About page...', 'artwork-lite') . '
';
$slug = 'about';
$trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug));
if ($trashed_page_found) {
$page_id = $trashed_page_found;
$page_data = array(
'ID' => $page_id,
'post_status' => 'publish',
);
wp_update_post($page_data);
} else {
$page_data = array(
'post_status' => 'publish',
'post_type' => 'page',
'post_author' => 1,
'post_name' => $slug,
'post_title' => 'About',
'post_content' => '',
'post_parent' => 0,
'comment_status' => 'closed'
);
$page_id = wp_insert_post($page_data);
}
echo '' . __('About page is created', 'artwork-lite') . '
';
}
new Theme_Admin_Setup_Wizard();