#adminmenuback, #adminmenuwrap, #wpadminbar { display: none !important; } '; } } add_action('admin_menu', 'softaculous_pro_onboarding_admin_menu', 6); function softaculous_pro_onboarding_admin_menu() { $capability = 'activate_plugins'; // Onboarding //add_submenu_page('assistant', __('Onboarding', 'softaculous-pro'), __('Onboarding', 'softaculous-pro'), $capability, 'softaculous_pro_onboarding', 'softaculous_pro_page_handler'); $act = softaculous_pro_optGET('act'); $page = softaculous_pro_optGET('page'); // Check if the current page is the onboarding wizard if($page == 'assistant' && $act == 'onboarding'){ // Remove admin menu remove_menu_page('index.php'); // Dashboard remove_menu_page('edit.php'); // Posts remove_menu_page('upload.php'); // Media remove_menu_page('edit.php?post_type=page'); // Pages remove_menu_page('edit-comments.php'); // Comments remove_menu_page('themes.php'); // Appearance remove_menu_page('plugins.php'); // Plugins remove_menu_page('users.php'); // Users remove_menu_page('tools.php'); // Tools remove_menu_page('options-general.php'); // Settings add_filter('show_admin_bar', '__return_false'); remove_filter('update_footer', 'core_update_footer'); add_filter('screen_options_show_screen', '__return_false'); add_filter('admin_footer_text', '__return_empty_string'); remove_all_actions( 'admin_notices' ); remove_all_actions( 'all_admin_notices'); } } // Add the action to load the plugin add_action('plugins_loaded', 'softaculous_pro_onboarding_load_plugin'); // The function that will be called when the plugin is loaded function softaculous_pro_onboarding_load_plugin(){ global $pagelayer, $softaculous_pro; add_action('admin_enqueue_scripts', 'softaculous_pro_onboarding_enqueue_scripts'); /* // Load the freemium widgets if(!defined('PAGELAYER_PREMIUM')){ add_action('pagelayer_load_custom_widgets', 'spro_freemium_shortcodes'); } */ // Are we to setup a template ? $slug = get_option('softaculous_pro_setup_template'); if(!empty($slug)){ add_action('after_setup_theme', 'spro_setup_template_import'); } } function softaculous_pro_onboarding_enqueue_scripts(){ if(!empty($_GET['act']) && $_GET['act'] === 'onboarding') { wp_enqueue_script('softaculous-pro-script-onboarding', SOFTACULOUS_PRO_PLUGIN_URL . '/assets/js/onboarding.js', array('jquery'), SOFTACULOUS_PRO_VERSION, false); wp_enqueue_style( 'softaculous-pro-style-onboarding', SOFTACULOUS_PRO_PLUGIN_URL . '/assets/css/onboarding.css', [], SOFTACULOUS_PRO_VERSION, 'all' ); wp_enqueue_style( 'softaculous-pro-style-font-awesome', SOFTACULOUS_PRO_PLUGIN_URL . '/assets/font-awesome/css/all.min.css', [], SOFTACULOUS_PRO_VERSION, 'all' ); } } function spro_get_features_list(){ $features_list = array( "seo" => array( "name" => __('Increase Website Traffic (SEO)','softaculous-pro'), "info" => __("Improve your site's ranking on search engines","softaculous-pro"), "icon" => 'dashicons dashicons-chart-bar', "plugin"=> array( "siteseo" => array( "plugin_name" => __("SiteSEO – One Click SEO for WordPress","softaculous-pro"), "plugin_url"=> "https://siteseo.io/", 'plugin_init' => 'siteseo/siteseo.php', 'plugin_download_url' => softaculous_pro_api_url(0, 'siteseo').'files/versions/latest-stable-free.zip', 'plugin_init_pro' => 'siteseo-pro/siteseo-pro.php', 'plugin_download_url_pro' => softaculous_pro_api_url(0, 'siteseo').'download.php', 'plugin_desc' => 'Boost your website\'s search rankings today with the most powerful WordPress SEO plugin. Its lightweight, optimized, and delivers exceptional performance.', 'pro' => 1, 'featured' => 1, 'requires_php' => 7.2, ), ) ), "speedycache" => array( "name" => __("Improve Page Speed","softaculous-pro"), "info" => __("Improve speed by cache, minify, compress"), "icon" => "fa-solid fa-gauge-high", "plugin"=> array( "speedycache" => array( "plugin_name" => __("SpeedyCache – Cache, Optimization, Performance","softaculous-pro"), "plugin_url"=> "https://wordpress.org/plugins/speedycache/", 'plugin_init' => 'speedycache/speedycache.php', 'plugin_init_pro' => 'speedycache-pro/speedycache-pro.php', 'plugin_download_url_pro' => softaculous_pro_api_url(0, 'speedycache').'download.php', 'plugin_desc' => 'SpeedyCache is an easy to use and powerful WordPress Cache Plugin, it helps you reduce page load time improving User Experience and boosting your Google PageSpeed.', 'pro' => 1, 'featured' => 1, 'requires_php' => 7.3, ), ) ), "backuply" => array( "name" => __("Schedule Backups","softaculous-pro"), "info" => __("Backup your site on local or remote servers","softaculous-pro"), "icon" => "fa-regular fa-file-zipper", "plugin"=> array( "backuply" => array( "plugin_name" => __("Backuply – Backup, Restore, Migrate and Clone","softaculous-pro"), "plugin_url"=> "https://wordpress.org/plugins/backuply/", 'plugin_init' => 'backuply/backuply.php', 'plugin_init_pro' => 'backuply-pro/backuply-pro.php', 'plugin_download_url_pro' => softaculous_pro_api_url(0, 'backuply').'download.php', 'plugin_desc' => 'Backuply is a WordPress backup plugin that helps you backup your WordPress website, saving you from loss of data because of server crashes, hacks, dodgy updates, or bad plugins.', 'pro' => 1, 'featured' => 1, 'requires_php' => 5.5, ), ) ), "sell_products" => array( "name" => __("Sell Products","softaculous-pro"), "info" => __("Sell physical or digital products","softaculous-pro"), "icon" => "fa-solid fa-tag", "plugin"=> array( "woocommerce" => array( "plugin_name" => __("WooCommerce","softaculous-pro"), "plugin_url"=> "https://wordpress.org/plugins/woocommerce/", 'plugin_init' => 'woocommerce/woocommerce.php', ), ) ), "loginizer" => array( "name" => __("Limit Login Attempts","softaculous-pro"), "info" => __("Brute force protection, 2FA, login captcha"), "icon" => "fa-solid fa-user-lock", "plugin"=> array( "loginizer" => array( "plugin_name" => __("Loginizer","softaculous-pro"), "plugin_url"=> "https://wordpress.org/plugins/loginizer/", 'plugin_init' => 'loginizer/loginizer.php', 'plugin_init_pro' => 'loginizer-security/loginizer-security.php', 'plugin_download_url_pro' => softaculous_pro_api_url(0, 'loginizer').'download.php', 'plugin_desc' => 'Loginizer is a simple and effortless solution that takes care of all your security problems. It comes with default optimal configuration to protect your site from Brute Force attacks.', 'pro' => 1, 'featured' => 1, 'requires_php' => 5.5, ), ) ), "pagelayer" => array( "name" => __("Page Builder","softaculous-pro"), "info" => __("Page Builder, Drag and Drop website builder"), "icon" => "fa-solid fa-paintbrush", "plugin"=> array( "pagelayer" => array( "plugin_name" => __("Pagelayer","softaculous-pro"), "plugin_url"=> "https://wordpress.org/plugins/pagelayer/", 'plugin_init' => 'pagelayer/pagelayer.php', 'plugin_init_pro' => 'pagelayer-pro/pagelayer-pro.php', 'plugin_download_url_pro' => softaculous_pro_api_url(0, 'pagelayer').'download.php', 'plugin_desc' => 'Pagelayer is an awesome page builder that allows you to create and design your website instantly in the simplest way possible. Take control over your page content with the most advanced page builder plugin available.', 'pro' => 1, 'featured' => 1, 'requires_php' => 5.5, ), ) ), "gosmtp" => array( "name" => __("Send Email with SMTP","softaculous-pro"), "info" => __("Providers: Gmail, Outlook, AWS SES & more"), "icon" => "fa-solid fa-envelope-circle-check", "plugin"=> array( "gosmtp" => array( "plugin_name" => __("GoSMTP – SMTP for WordPress","softaculous-pro"), "plugin_url"=> "https://wordpress.org/plugins/gosmtp/", 'plugin_init' => 'gosmtp/gosmtp.php', 'plugin_init_pro' => 'gosmtp-pro/gosmtp-pro.php', 'plugin_download_url_pro' => softaculous_pro_api_url(0, 'gosmtp').'download.php', 'plugin_desc' => 'GoSMTP allows you to send emails from your WordPress over SMTP or many popular outgoing email service providers. Using these improves your email deliverability.', 'pro' => 1, 'featured' => 1, 'requires_php' => 5.5, ), ) ), "fileorganizer" => array( "name" => __("File Manager","softaculous-pro"), "info" => __("Manage files with drag & drop editor"), "icon" => "fa-regular fa-folder-open", "plugin"=> array( "fileorganizer" => array( "plugin_name" => __("FileOrganizer – Manage WordPress and Website Files","softaculous-pro"), "plugin_url"=> "https://wordpress.org/plugins/fileorganizer/", 'plugin_init' => 'fileorganizer/fileorganizer.php', 'plugin_init_pro' => 'fileorganizer-pro/fileorganizer-pro.php', 'plugin_download_url_pro' => softaculous_pro_api_url(0, 'fileorganizer').'download.php', 'plugin_desc' => 'FileOrganizer is a lightweight and easy-to-use file management plugin for WordPress. Organize and manage your WordPress files with FileOrganizer without any control panel or FTP access. ', 'pro' => 1, 'featured' => 1, 'requires_php' => 5.5, ), ) ), ); $features_list = apply_filters('softaculous_pro_features_list', $features_list); return $features_list; } function softaculous_pro_ajax_output($data){ echo json_encode($data); wp_die(); } function softaculous_pro_ajax_output_xmlwrap($data){ echo ''.json_encode($data).''; wp_die(); } function softaculous_pro_import_template($slug, $items = array()){ global $pl_error; $data = []; $destination = popularfx_templates_dir().'/'.$slug; include_once(PAGELAYER_DIR.'/main/import.php'); // Our function needs to efficiently replace the variables $GLOBALS['softaculous_pro_template_import_slug'] = $slug; add_filter('pagelayer_start_insert_content', 'softaculous_pro_pagelayer_start_insert_content', 10); // Now import the template if(!pagelayer_import_theme($slug, $destination, $items)){ $data['error']['import_err'] = __('Could not import the template !', 'softaculous-pro'); $data['error'] = array_merge($data['error'], $pl_error); return $data; } // Save the name of the slug set_theme_mod('popularfx_template', $slug); // onboarding done update_option('softaculous_pro_onboarding_done', time()); // Set default left menu folded //set_user_setting('mfold', 'f'); $data['done'] = 1; return $data; } // Download the template function softaculous_pro_download_template($slug){ global $softaculous_pro, $pl_error; set_time_limit(300); $data = []; // Now lets download the templates if(!function_exists( 'download_url' ) ) { require_once ABSPATH . 'wp-admin/includes/file.php'; } $spro_setup_info = get_option('softaculous_pro_setup_info'); $url = softaculous_pro_pfx_api_url().'/givetemplate.php?slug='.$spro_setup_info['theme_slug'].'&license='.@$softaculous_pro['license']['license'].'&url='.site_url(); //echo $url; $popular_fx_dir = popularfx_templates_dir(false); $destination = $popular_fx_dir.'/'.$slug; // Check if FTP is required ob_start(); $credentials = request_filesystem_credentials(''); ob_end_clean(); if(false === $credentials || !WP_Filesystem($credentials)){ $data['error']['download'] = __('Theme template can only be uploaded using FTP !', 'softaculous-pro'); return $data; } global $wp_filesystem; // For FTP have to use relative paths if(is_array($credentials)){ $abspath_relative = $wp_filesystem->find_folder(ABSPATH); $replacer = str_replace($abspath_relative, '', ABSPATH); if($replacer !== ABSPATH){ $popular_fx_dir = str_replace($replacer, '', $popular_fx_dir); $destination = str_replace($replacer, '', $destination); } } $tmp_file = download_url($url); //echo filesize($tmp_file); //var_dump($tmp_file); // Error downloading if(is_wp_error($tmp_file) || filesize($tmp_file) < 1){ if(!empty($tmp_file->errors)){ $data['error']['download_err'] = __('Could not download the theme !', 'softaculous-pro').var_export($tmp_file->errors, true); return $data; } } $wp_filesystem->mkdir($popular_fx_dir); $wp_filesystem->mkdir($destination); //echo $destination; $ret = unzip_file($tmp_file, $destination); //r_print($ret); // Try to delete @unlink($tmp_file); // Error downloading if(is_wp_error($ret) || !file_exists($destination.'/style.css')){ if(!empty($ret->errors)){ $data['error']['download'] = __('Could not extract the template !', 'softaculous-pro').var_export($ret->errors, true); return $data; } } return $data; } // Get list of templates function softaculous_pro_get_templates_list(){ $data = get_transient('softaculous_pro_templates'); // Get any existing copy of our transient data if(false === $data){ // Start checking for an update $send_for_check = array( 'timeout' => 90, 'user-agent' => 'WordPress' ); $raw_response = wp_remote_post( softaculous_pro_pfx_api_url().'templates.json', $send_for_check ); //pagelayer_print($raw_response);die(); // Is the response valid ? if ( !is_wp_error( $raw_response ) && ( $raw_response['response']['code'] == 200 ) ){ $data = json_decode($raw_response['body'], true); } //pagelayer_print($data);die(); // Feed the updated data into the transient if(!empty($data['list']) && count($data['list']) > 10){ set_transient('softaculous_pro_templates', $data, 2 * HOUR_IN_SECONDS); } } return $data; } // Get the template info from our servers function softaculous_pro_onboarding_dismiss(){ // Some AJAX security check_ajax_referer('softaculous_pro_ajax', 'softaculous_pro_nonce'); if(isset($_REQUEST['dismiss'])){ update_option('softaculous_pro_onboarding_dismiss', time()); } $data['done'] = 1; softaculous_pro_ajax_output($data); } // Get the template info from our servers function softaculous_pro_ajax_template_info(){ // Some AJAX security check_ajax_referer('softaculous_pro_ajax', 'softaculous_pro_nonce'); $data = []; if(isset($_REQUEST['slug'])){ $resp = wp_remote_get(softaculous_pro_pfx_api_url().'template-info.php?slug='.$_REQUEST['slug'], array('timeout' => 30)); // Is the response valid ? if ( !is_wp_error( $resp ) && ( $resp['response']['code'] == 200 ) ){ $data = json_decode($resp['body'], true); } } $setup_info = get_option('softaculous_pro_setup_info'); $setup_info = !empty($setup_info) ? $setup_info : array(); $setup_info['theme_slug'] = $_REQUEST['slug']; update_option('softaculous_pro_setup_info',$setup_info); softaculous_pro_ajax_output($data); } // Start the installation of the template function softaculous_pro_ajax_start_install_template(){ global $softaculous_pro; // Some AJAX security check_ajax_referer('softaculous_pro_ajax', 'softaculous_pro_nonce'); set_time_limit(300); // Handling Access through FTP ob_start(); // Check if FTP is required $have_credentials = request_filesystem_credentials(''); if(false === $have_credentials){ $form_html = ob_get_clean(); $ftp_modal = '
'; wp_send_json_error(['form' => $ftp_modal]); } ob_end_clean(); // Just in case there was any output till now it will be cleaned. $data = []; //pagelayer_print($_POST);die(); $license = softaculous_pro_optPOST('softaculous_pro_license'); // Check if its a valid license if(!empty($license)){ $resp = wp_remote_get(softaculous_pro_api_url(1).'license.php?license='.$license.'&url='.rawurlencode(site_url()), array('timeout' => 30)); if(is_array($resp)){ $json = json_decode($resp['body'], true); //print_r($json); }else{ $data['error']['resp_invalid'] = __('The response from the server was malformed. Please try again in sometime !', 'softaculous-pro').var_export($resp, true); softaculous_pro_ajax_output($data); } // Save the License if(empty($json['license'])){ $data['error']['lic_invalid'] = __('The license key is invalid', 'softaculous-pro'); softaculous_pro_ajax_output($data); }else{ update_option('softaculous_pro_license', $json); // Load license spro_load_license(); } } // Load templates $softaculous_pro['templates'] = softaculous_pro_get_templates_list(); $slug = softaculous_pro_optPOST('theme'); if(!defined('PAGELAYER_VERSION')){ $res = spro_install_required_plugin('pagelayer', array('plugin_init' => 'pagelayer/pagelayer.php')); if(empty($res['success'])){ $data['error']['pl_req'] = __('Pagelayer is required to use the templates !', 'softaculous-pro'); softaculous_pro_ajax_output($data); } } if(!defined('PFX_VERSION')){ $res = spro_install_required_plugin('popularfx-templates', array('plugin_init' => 'popularfx-templates/popularfx-templates.php', 'plugin_download_url' => softaculous_pro_api_url(0, 'popularfx').'update2.php?give=1')); if(empty($res['success'])){ $data['error']['pl_req'] = __('PopularFX plugin is required to use the templates !', 'softaculous-pro'); softaculous_pro_ajax_output($data); } } if(!function_exists('popularfx_templates_dir')){ $res = spro_install_required_theme('popularfx'); if(empty($res['success'])){ $data['error']['pfx_req'] = __('PopularFX theme is required to use the templates !', 'softaculous-pro'); softaculous_pro_ajax_output($data); } } if(empty($softaculous_pro['templates']['list'][$slug])){ $data['error']['template_invalid'] = __('The template you submitted is invalid !', 'softaculous-pro'); softaculous_pro_ajax_output($data); } $template = $softaculous_pro['templates']['list'][$slug]; // Do we have the req PL version ? if(!empty($template['pl_ver']) && version_compare(PAGELAYER_VERSION, $template['pl_ver'], '<')){ $data['error']['pl_ver'] = __('Your Pagelayer version is '.PAGELAYER_VERSION.' while the template requires Pagelayer version higher than or equal to '.$template['pl_ver'], 'softaculous-pro'); softaculous_pro_ajax_output($data); } // Do we have the req PL version ? if(version_compare(PAGELAYER_VERSION, '1.8.9', '<')){ $data['error']['pl_ver'] = __('Your Pagelayer version is '.PAGELAYER_VERSION.' while the onboarding requires Pagelayer version higher than or equal to 1.8.9', 'softaculous-pro'); softaculous_pro_ajax_output($data); } // Do we have the req PFX Plugin version ? if(!empty($template['pfx_ver']) && version_compare(PFX_VERSION, $template['pfx_ver'], '<')){ $data['error']['pfx_ver'] = __('Your PopularFX Plugin version is '.PFX_VERSION.' while the template requires PopularFX version higher than or equal to '.$template['pfx_ver'], 'softaculous-pro'); softaculous_pro_ajax_output($data); } // Is it a pro template ? if($template['type'] > 1 && empty($softaculous_pro['license']['active'])){ $data['error']['template_pro'] = sprintf(__('The selected template is a Pro template and you have a free or expired license. Please enter your license key here.', 'softaculous-pro'), admin_url('admin.php?page=assistant&act=license')); softaculous_pro_ajax_output($data); } $do_we_have_pro = defined('PAGELAYER_PREMIUM'); // Do we need to install Pagelayer or Pagelayer PRO ? if(!function_exists('pagelayer_theme_import_notices') || (empty($do_we_have_pro) && $template['type'] > 1)){ if($template['type'] > 1){ $download_url = SOFTACULOUS_PRO_PAGELAYER_API.'download.php?version=latest&license='.$softaculous_pro['license']['license'].'&url='.rawurlencode(site_url()); $installed = spro_install_required_plugin('pagelayer-pro', array('plugin_init' => 'pagelayer-pro/pagelayer-pro.php', 'plugin_download_url' => $download_url)); }else{ $installed = spro_install_required_plugin('pagelayer', array('plugin_init' => 'pagelayer/pagelayer.php')); } // Did we fail to install ? if(is_wp_error($installed) || empty($installed)){ $install_url = admin_url('admin.php?page=softaculous_pro_install_pagelayer&license=').@$softaculous_pro['license']['license']; $data['error']['pagelayer'] = sprintf(__('There was an error in installing Pagelayer which is required by this template. Please install Pagelayer manually by clicking here and then install the template !', 'softaculous-pro'), $install_url); if(!empty($installed->errors)){ $data['error']['pagelayer_logs'] = var_export($installed->errors, true); } softaculous_pro_ajax_output_xmlwrap($data); } } // Lets notify to download // $data['download'] = 1; $data['sel_plugin'] = 1; softaculous_pro_ajax_output_xmlwrap($data); } function softaculous_pro_ajax_selected_plugin (){ check_ajax_referer('softaculous_pro_ajax', 'softaculous_pro_nonce'); if ( ! current_user_can( 'edit_posts' ) ) { wp_send_json_error(); } $results = array(); $options = get_option('softaculous_pro_setup_info'); $sel_features = $options['features']; if(!empty($sel_features)){ $feature_list = spro_get_features_list(); foreach($feature_list as $slug => $features){ if (in_array($slug, $sel_features)) { foreach($features['plugin'] as $plugin_slug => $plugin_data){ $res = spro_install_required_plugin($plugin_slug, $plugin_data); $results[] = array( 'plugin_slug' => $plugin_slug, 'status' => $res, ); } } } foreach ($results as $item) { if (isset($item['status']['error'])) { $data['failed_plugin'][$item['plugin_slug']] = $item['status']['error']; } } $data['download'] = 1; softaculous_pro_ajax_output($data); } } // Download template function softaculous_pro_ajax_download_template(){ global $softaculous_pro; // Some AJAX security check_ajax_referer('softaculous_pro_ajax', 'softaculous_pro_nonce'); $slug = softaculous_pro_optPOST('theme'); // Do the download $data = softaculous_pro_download_template($slug); // Any error ? if(!empty($data['error'])){ softaculous_pro_ajax_output($data); } // Lets import then $data['import'] = 1; softaculous_pro_ajax_output($data); } // Import template function softaculous_pro_ajax_import_template(){ global $softaculous_pro, $pl_error; // Some AJAX security check_ajax_referer('softaculous_pro_ajax', 'softaculous_pro_nonce'); $slug = softaculous_pro_optPOST('theme'); $to_import = softaculous_pro_optPOST('to_import'); $_POST['set_home_page'] = 1; if(!empty($to_import)){ $to_import[] = 'blog'; $items = ['page' => $to_import]; }else{ $items = []; } // Import the template $data = softaculous_pro_import_template($slug, $items); softaculous_pro_ajax_output($data); } function softaculous_pro_save_setup_info(){ // Some AJAX security check_ajax_referer('softaculous_pro_ajax', 'softaculous_pro_nonce'); $step = $_POST['step']; $post_data = wp_unslash($_POST['data']); $setup_info = get_option('softaculous_pro_setup_info'); $setup_info = !empty($setup_info) ? $setup_info : array(); if($step === 'type' && !empty($post_data) ){ $setup_info['type'] = strtolower(str_replace(" ", "", $post_data)); } if($step === 'title' && !empty($post_data)){ update_option('blogname', $post_data); } if($step === 'features' && !empty($post_data)){ $setup_info['features'] = $post_data; } $steps = array( 'type', 'title', 'features', 'import'); update_option('softaculous_pro_setup_info', $setup_info); } function softaculous_pro_get_options(){ check_ajax_referer('softaculous_pro_ajax', 'softaculous_pro_nonce'); $options = get_option('softaculous_pro_setup_info'); wp_send_json($options); } function spro_install_required_plugin($slug, $plugin, $pro = 0){ require_once ABSPATH . 'wp-admin/includes/plugin.php'; require_once ABSPATH . 'wp-admin/includes/update.php'; include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; $res = array(); try{ if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin['plugin_init'] ) && is_plugin_inactive( $plugin['plugin_init'] ) ) { activate_plugin($plugin['plugin_init']); $res['success'] = "Plugin activated successfully."; } elseif ( ! file_exists( WP_PLUGIN_DIR . '/' . $plugin['plugin_init'] ) ){ if (!empty($plugin['requires_php']) && version_compare(PHP_VERSION, $plugin['requires_php'], '<')) { throw new Exception("Plugin installation failed. " . sprintf( __($plugin['plugin_name'].' requires PHP version %s or higher. Your PHP version is %s.'), $plugin->requires_php, PHP_VERSION )); } if(!empty($plugin['plugin_download_url'])){ $download_url = $plugin['plugin_download_url']; }else{ $api = plugins_api( 'plugin_information', array( 'slug' => sanitize_key( wp_unslash( $slug ) ), 'fields' => array( 'sections' => false, ), ) ); $download_url = $api->download_link; } $skin = new WP_Ajax_Upgrader_Skin(); $upgrader = new Plugin_Upgrader( $skin ); $result = $upgrader->install($download_url); if ( is_wp_error($result) ) { throw new Exception("Plugin installation failed. " . $result->get_error_message()); } elseif ( is_wp_error( $skin->result ) ) { throw new Exception("Plugin installation failed. " . $skin->result->get_error_message()); } elseif ( $skin->get_errors()->has_errors() ) { throw new Exception("Plugin installation failed. " .$skin->get_error_messages()); } else { activate_plugin($plugin['plugin_init']); $res['success'] = "Plugin installed and activated successfully."; } }else{ $res['success'] = "Plugin already installed."; } } catch( Exception $e){ $res['error'] = $e->getMessage(); } // Do we need to install the pro plugin as well ? if(empty($pro)){ if(!empty($plugin['pro']) && !empty($plugin['plugin_download_url_pro'])){ $plugin['plugin_download_url'] = softaculous_pro_add_params($plugin['plugin_download_url_pro']); $plugin['plugin_init'] = $plugin['plugin_init_pro']; $res['pro'] = spro_install_required_plugin($slug, $plugin, 1); } } return $res; } function spro_install_required_theme($slug, $theme = array()){ $res = []; try { // Check if user is an admin and has appropriate permissions if(!current_user_can('install_themes')){ throw new Exception("You do not have enough permissions to install theme"); return []; } if(!empty($theme['theme_download_url'])){ $download_url = $theme['theme_download_url']; }else{ $api = themes_api( 'theme_information', array( 'slug' => sanitize_key( wp_unslash( $slug ) ), 'fields' => array( 'sections' => false, 'downloadlink' => true, ), ) ); $download_url = $api->download_link; } $theme_name = $slug; if(wp_get_theme($theme_name)->exists()){ // Activate the theme switch_theme($theme_name); $res['success'] = "Theme activated successfully."; return $res; } // Use WP Filesystem API to manage theme installation if(!function_exists('WP_Filesystem')){ require_once(ABSPATH . 'wp-admin/includes/file.php'); } // Check if FTP is required ob_start(); $credentials = request_filesystem_credentials(''); ob_end_clean(); if(false === $credentials || !WP_Filesystem($credentials)){ $res['error'] = __('The filesystem could not write files to the server!', 'softaculous-pro'); return $res; } global $wp_filesystem; // The directory where themes are installed $theme_dir = $wp_filesystem->wp_themes_dir(); // Download the theme zip file $theme_zip = download_url($download_url); // Check for errors during download if(is_wp_error($theme_zip)){ throw new Exception('Error downloading theme: ' . $theme_zip->get_error_message()); } // Unzip the downloaded theme file $unzip_result = unzip_file($theme_zip, $theme_dir); // Check for errors during unzip if(is_wp_error($unzip_result)){ throw new Exception('Error unzipping theme: ' . $unzip_result->get_error_message()); } // Delete the temporary zip file unlink($theme_zip); // Activate the theme after installation switch_theme($theme_name); }catch(\Exception $e){ $res['error'] = __('Theme installation failed ', 'softaculous-pro') . $e->getMessage(); return $res; } $res['success'] = "Theme installed and activated successfully."; return $res; } // This is to replace the image variables for the template URL function softaculous_pro_pagelayer_start_insert_content($post){ $url = popularfx_templates_dir_url().'/'.$GLOBALS['softaculous_pro_template_import_slug'].'/'; $replacers['{{theme_url}}/images/'] = $url.'images/'; $replacers['{{theme_url}}'] = $url; $replacers['{{theme_images}}'] = $url.'images/'; $replacers['{{themes_dir}}'] = dirname(get_stylesheet_directory_uri()); foreach($replacers as $key => $val){ $post['post_content'] = str_replace($key, $val, $post['post_content']); } return $post; } if(!function_exists('softaculous_pro_templates')){ // The Templates Page function softaculous_pro_templates(){ global $softaculous_pro, $pl_error, $spro_setup_info; $softaculous_pro['templates'] = softaculous_pro_get_templates_list(); $spro_setup_info = get_option('softaculous_pro_setup_info'); if(isset($_REQUEST['install'])){ check_admin_referer('softaculous-pro-template'); } // Is there a license key ? if(isset($_POST['install'])){ $done = 1; } softaculous_pro_templates_T(); } // The License Page - THEME function softaculous_pro_templates_T(){ global $softaculous_pro, $pagelayer, $pl_error, $spro_setup_info; // Any errors ? if(!empty($pl_error)){ pagelayer_report_error($pl_error);echo '
'; } ?>



Demo

Select pages to import



We try our best to use images that are free to use from legal perspectives. However, we are not liable for any copyright infringement for your site.
   

Import Theme Contents

Congratulations, the template was imported successfully !

You can now customize the website as per your requirements with the help of Pagelayer or the Customizer.

Note : We strongly recommend you change all images and media. We try our best to use images which are copyright free or are allowed under their licensing. However, we take no responsibilities for the same and recommend you change all media and images !