示例#1
0
 /**
  * Checks if we are going to make an update and updates current framework to latest version
  */
 public static function update_init()
 {
     global $r;
     if (!isset($_GET['page'])) {
         return;
     }
     $requestedPage = strtolower(strip_tags(trim($_REQUEST['page'])));
     if ($requestedPage != 'wpzoom_update') {
         return;
     }
     $fsmethod = get_filesystem_method();
     $fs = WP_Filesystem();
     if ($fs == false) {
         function framework_update_filesystem_warning()
         {
             $method = get_filesystem_method();
             echo "<p>Failed: Filesystem preventing downloads. ({$method})</p>";
         }
         add_action('admin_notices', 'framework_update_filesystem_warning');
         return;
     }
     if (isset($_POST['wpzoom-update-do'])) {
         $action = strtolower(trim(strip_tags($_POST['wpzoom-update-do'])));
         if ($action == 'update') {
             $fwUrl = 'http://framework.wpzoom.com/wpzoom-framework.zip';
             $fwFile = download_url($fwUrl);
             if (is_wp_error($fwUrl)) {
                 $error = $fwFile->get_error_code();
                 if ($error == 'http_no_url') {
                     $r = "<p>Failed: Invalid URL Provided</p>";
                 } else {
                     $r = "<p>Failed: Upload - {$error}</p>";
                 }
                 function framework_update_warning()
                 {
                     global $r;
                     echo "<p>{$r}</p>";
                 }
                 add_action('admin_notices', 'framework_update_warning');
                 return;
             }
         }
         global $wp_filesystem;
         $to = WPZOOM::get_wpzoom_root();
         $dounzip = unzip_file($fwFile, $to);
         unlink($fwFile);
         if (is_wp_error($dounzip)) {
             $error = $dounzip->get_error_code();
             $data = $dounzip->get_error_data($error);
             if ($error == 'incompatible_archive') {
                 //The source file was not found or is invalid
                 function framework_update_no_archive_warning()
                 {
                     echo "<p>Failed: Incompatible archive</p>";
                 }
                 add_action('admin_notices', 'framework_update_no_archive_warning');
             }
             if ($error == 'empty_archive') {
                 function framework_update_empty_archive_warning()
                 {
                     echo "<p>Failed: Empty Archive</p>";
                 }
                 add_action('admin_notices', 'framework_update_empty_archive_warning');
             }
             if ($error == 'mkdir_failed') {
                 function framework_update_mkdir_warning()
                 {
                     echo "<p>Failed: mkdir Failure</p>";
                 }
                 add_action('admin_notices', 'framework_update_mkdir_warning');
             }
             if ($error == 'copy_failed') {
                 function framework_update_copy_fail_warning()
                 {
                     echo "<p>Failed: Copy Failed</p>";
                 }
                 add_action('admin_notices', 'update_copy_fail_warning');
             }
             return;
         }
         function framework_updated_success()
         {
             echo '<div class="updated fade"><p>New framework successfully downloaded, extracted and updated.</p></div>';
         }
         add_action('admin_notices', 'framework_updated_success');
         remove_action('admin_notices', array('WPZOOM', 'notification'));
         option::delete('framework_status');
         option::set('framework_last_checked', time());
     }
 }
<?php

if (!class_exists('WPZOOM')) {
    die;
}
$support_shortcodes = file_exists(WPZOOM::get_wpzoom_root() . '/assets/css/shortcodes.css');
?>
<!doctype html>
<html <?php 
language_attributes();
?>
>
<head>
    <meta charset="<?php 
bloginfo('charset');
?>
" />
</head>
<body>
<div id="wpz-dialog">

<?php 
if ($support_shortcodes) {
    ?>

<div id="wpz-options-buttons" class="clear">
    <div class="alignleft">

        <input type="button" id="wpz-btn-cancel" class="button" name="cancel" value="Cancel" accesskey="C" />

    </div>