Ejemplo n.º 1
0
 public static function process_server_response($response, $cached = false)
 {
     if (empty($response['packages'])) {
         return;
     }
     require_once $GLOBALS['ithemes_updater_path'] . '/keys.php';
     require_once $GLOBALS['ithemes_updater_path'] . '/packages.php';
     $keys = array();
     foreach ($response['packages'] as $package => $data) {
         if (isset($data['key'])) {
             $keys[$package] = $data['key'];
         } else {
             if (isset($data['status']) && 'inactive' == $data['status']) {
                 $keys[$package] = '';
             }
         }
     }
     Ithemes_Updater_Keys::set($keys);
     $details = Ithemes_Updater_Packages::get_full_details($response);
     $updates = array('update_themes' => array(), 'update_plugins' => array(), 'expiration' => $details['expiration']);
     if (!$cached) {
         $updates['timestamp'] = time();
     }
     if (isset($response['timeout_multiplier'])) {
         $updates['timeout-multiplier'] = $response['timeout_multiplier'];
     }
     if (!isset($updates['timeout-multiplier']) || $updates['timeout-multiplier'] < 1) {
         $updates['timeout-mulitplier'] = 1;
     } else {
         if ($updates['timeout-multiplier'] > 10) {
             $updates['timeout-mulitplier'] = 10;
         }
     }
     $use_ssl = $GLOBALS['ithemes-updater-settings']->get_option('use_ssl');
     foreach ($details['packages'] as $path => $data) {
         if (empty($data['package-url']) || version_compare($data['installed'], $data['available'], '>=')) {
             continue;
         }
         $force_minor_version_update = $GLOBALS['ithemes-updater-settings']->get_option('force_minor_version_update');
         $quick_releases = $GLOBALS['ithemes-updater-settings']->get_option('quick_releases');
         if (isset($data['upgrade']) && !$data['upgrade'] && !$force_minor_version_update && !$quick_releases) {
             continue;
         }
         if (!$use_ssl) {
             $data['package-url'] = preg_replace('/^https/', 'http', $data['package-url']);
         }
         if ('plugin' == $data['type']) {
             $update = array('id' => 0, 'slug' => dirname($path), 'new_version' => $data['available'], 'url' => $data['info-url'], 'package' => $data['package-url']);
             $update = (object) $update;
         } else {
             $update = array('new_version' => $data['available'], 'url' => self_admin_url('plugin-install.php?tab=plugin-information&plugin=' . dirname($path) . '&section=changelog&TB_iframe=true&width=600&height=800'), 'package' => $data['package-url']);
             $path = dirname($path);
         }
         $updates["update_{$data['type']}s"][$path] = $update;
     }
     $GLOBALS['ithemes-updater-settings']->update_options($updates);
 }
Ejemplo n.º 2
0
 public static function get_plugin_information($path)
 {
     require_once $GLOBALS['ithemes_updater_path'] . '/packages.php';
     $details = Ithemes_Updater_Packages::get_full_details();
     if (!isset($details['packages'][$path])) {
         return false;
     }
     $package = $details['packages'][$path];
     require_once $GLOBALS['ithemes_updater_path'] . '/functions.php';
     require_once $GLOBALS['ithemes_updater_path'] . '/information.php';
     $changelog = Ithemes_Updater_API::get_package_changelog($package['package'], $details['packages'][$path]['installed']);
     $info = array('name' => Ithemes_Updater_Functions::get_package_name($package['package']), 'slug' => dirname($path), 'version' => $package['available'], 'author' => '<a href="http://ithemes.com/">iThemes</a>', 'download_link' => $package['package-url'], 'sections' => array('changelog' => $changelog));
     return (object) $info;
 }
Ejemplo n.º 3
0
 public static function get_plugin_information($path)
 {
     require_once $GLOBALS['ithemes_updater_path'] . '/packages.php';
     $details = Ithemes_Updater_Packages::get_full_details();
     if (!isset($details['packages'][$path])) {
         return false;
     }
     $package = $details['packages'][$path];
     $url = "http://package-info.ithemes.com/{$package['package']}/information.json";
     $response = wp_remote_get($url);
     if (!is_wp_error($response) && isset($response['body'])) {
         $info = json_decode($response['body']);
         if (is_object($info) && !empty($info->name) && !empty($info->version)) {
             $info->slug = dirname($path);
             $info->download_link = $package['package-url'];
             return $info;
         }
     }
     require_once $GLOBALS['ithemes_updater_path'] . '/functions.php';
     require_once $GLOBALS['ithemes_updater_path'] . '/information.php';
     $changelog = Ithemes_Updater_API::get_package_changelog($package['package'], $details['packages'][$path]['installed']);
     $info = array('name' => Ithemes_Updater_Functions::get_package_name($package['package']), 'slug' => dirname($path), 'version' => $package['available'], 'author' => '<a href="http://ithemes.com/">iThemes</a>', 'download_link' => $package['package-url'], 'sections' => array('changelog' => $changelog));
     return (object) $info;
 }
Ejemplo n.º 4
0
    public function list_packages($action, $post_data)
    {
        require_once $GLOBALS['ithemes_updater_path'] . '/packages.php';
        $details = Ithemes_Updater_Packages::get_full_details();
        $packages = $details['packages'];
        $licensed = array();
        $unlicensed = array();
        $unrecognized = array();
        foreach ($packages as $path => $data) {
            $name = Ithemes_Updater_Functions::get_package_name($data['package']);
            $data['path'] = $path;
            if ('unlicensed' == $data['status']) {
                $unlicensed[$name] = $data;
            } else {
                if (in_array($data['status'], array('active', 'expired'))) {
                    $licensed[$name] = $data;
                } else {
                    $unrecognized[$name] = $data;
                }
            }
        }
        if (!empty($this->messages)) {
            foreach ($this->messages as $message) {
                echo "<div class=\"updated fade\"><p><strong>{$message}</strong></p></div>\n";
            }
        }
        if (!empty($this->errors)) {
            foreach ($this->errors as $error) {
                echo "<div class=\"error\"><p><strong>{$error}</strong></p></div>\n";
            }
        }
        if (!empty($this->soft_errors)) {
            foreach ($this->soft_errors as $error) {
                echo "<div class=\"error\"><p><strong>{$error}</strong></p></div>\n";
            }
        }
        ?>
	<div class="wrap">
		<?php 
        if (version_compare($GLOBALS['wp_version'], '3.7.10', '<=')) {
            screen_icon();
        }
        ?>
		
		<h2><?php 
        _e('iThemes Licensing', 'it-l10n-ithemes-sync');
        ?>
</h2>
		
		<?php 
        $this->list_licensed_products($licensed, $post_data, $action);
        ?>
		
		<?php 
        $this->list_unlicensed_products($unlicensed, $post_data, $action);
        ?>
		
		<?php 
        $this->list_unrecognized_products($unrecognized);
        ?>
		
		<?php 
        $this->show_settings();
        ?>
	</div>
<?php 
    }