function update_theme()
 {
     if (isset($_REQUEST['page'])) {
         // Sanitize page being requested.
         $_page = esc_attr($_REQUEST['page']);
         if ('spyropress-update' == $_page) {
             //Setup Filesystem
             $method = get_filesystem_method();
             if (isset($_POST['spyropress_ftp_cred'])) {
                 $cred = spyropress_decode($_POST['spyropress_ftp_cred']);
                 $filesystem = WP_Filesystem($cred);
             } else {
                 $filesystem = WP_Filesystem();
             }
             if (false == $filesystem && 'Proceed' != $_POST['upgrade']) {
                 add_error_message(sprintf(__('Failed: Filesystem preventing downloads. (%s)', 'spyropress'), $method));
                 return;
             }
             if (isset($_REQUEST['spyropress_updater'])) {
                 // Sanitize action being requested.
                 $_action = esc_attr($_REQUEST['spyropress_updater']);
                 if ('framework' == $_action) {
                     locate_template('framework/utilities/envato/class-envato-wordpress-theme-upgrader.php', true);
                     $envato_api_key = get_option('_spyropress_envato_api_key_' . get_internal_name());
                     $envato_username = get_option('_spyropress_envato_username_' . get_internal_name());
                     $upgrader = new Envato_WordPress_Theme_Upgrader($envato_username, $envato_api_key);
                     $result = $upgrader->upgrade_theme();
                     // Successfully Updated
                     if ($result->success) {
                         $message = __('New version successfully downloaded, extracted and updated.', 'spyropress');
                         $message .= '<script type="text/javascript">
                             //<![CDATA[
                                 window.location.replace("' . admin_url('admin.php?page=spyropress-update') . '");
                             //]]>
                         </script>';
                         add_success_message($message);
                     } else {
                         add_error_message($result->errors[0]);
                     }
                 }
             }
         }
         // END UPDATE HERE
     }
 }
示例#2
0
/**
 * Restore SpyroPress Panel Options
 */
function spyropress_import_options_ajax()
{
    global $spyropress;
    // Security
    check_ajax_referer('spyropress-update-options', 'security');
    // Generate Option Key
    $key = 'spyropress_' . $_POST['setting_panel_name'];
    // Check for define
    if (!isset($GLOBALS[$key])) {
        _e('false', 'spyropress');
        die;
    }
    // Doing import
    $data = $_POST['settings'];
    $data = spyropress_decode($data);
    update_option($key . $spyropress->lang, $data);
    // Allow developer to perform actions
    do_action('spyropress_import_' . $_POST['setting_panel_name']);
    // Refresh page
    echo 'window.location = "' . $_SERVER['HTTP_REFERER'] . '";';
    // Exit
    die;
}
delete_transient('_spyropress_api_framework_updater');
// Theme Log
$theme_log = spyropress_get_theme_changelog();
$is_theme_updateable = is_theme_updateable();
$theme_name = $spyropress->theme_name;
$theme_version = $spyropress->theme_version;
// Framework Log
$framework_log = spyropress_get_framework_changelog();
// Getting Filesystem intact
$method = get_filesystem_method();
$to = ABSPATH . 'wp-content/themes/' . get_option('template');
if (isset($_POST['password'])) {
    $cred = $_POST;
    $filesystem = WP_Filesystem($cred);
} elseif (isset($_POST['spyropress_ftp_cred'])) {
    $cred = spyropress_decode($_POST['spyropress_ftp_cred']);
    $filesystem = WP_Filesystem($cred);
} else {
    $filesystem = WP_Filesystem();
}
$url = admin_url('admin.php?page=spyropress-update');
?>


<div class="wrap spyropress-wrap abs-badge">
<?php 
if (false == $filesystem) {
    request_filesystem_credentials($url);
} else {
    if (!$is_theme_updateable) {
        get_spyropress_badge();
示例#4
0
 function save_options($option_file)
 {
     if (!$option_file || !file_exists($option_file)) {
         return;
     }
     @(include_once $option_file);
     // Doing import
     $data = spyropress_decode($dummy_data);
     $this->backfill_builder_urls($data);
     update_option($this->key, $data);
 }