public static function run_update() { // Prevent the code from running if the code was loaded by an older updater version. if (!isset($GLOBALS['ithemes_updater_path'])) { return; } require_once $GLOBALS['ithemes_updater_path'] . '/api.php'; require_once $GLOBALS['ithemes_updater_path'] . '/packages.php'; require_once $GLOBALS['ithemes_updater_path'] . '/keys.php'; $keys = Ithemes_Updater_Keys::get(); $legacy_keys = Ithemes_Updater_Keys::get_legacy(); if (empty($keys) && empty($legacy_keys)) { return; } Ithemes_Updater_API::get_package_details(false); }
public static function get_local_details() { require_once $GLOBALS['ithemes_updater_path'] . '/keys.php'; $all_packages = self::get_all(); $keys = Ithemes_Updater_Keys::get(); $packages = array(); foreach ($all_packages as $file => $slug) { $packages[$slug][] = $file; } foreach ($packages as $slug => $paths) { $packages[$slug] = array_unique($paths); } $details = array(); foreach ($packages as $package => $paths) { foreach ($paths as $path) { $plugin_path = preg_replace('/^' . preg_quote(WP_PLUGIN_DIR, '/') . '/', '', $path); if ($plugin_path != $path) { $type = 'plugin'; $rel_path = preg_replace('|^[/\\\\]|', '', $plugin_path); $plugin_data = get_plugin_data($path, false, false); $version = $plugin_data['Version']; $info_url = $plugin_data['PluginURI']; } else { $type = 'theme'; $dir = basename(dirname($path)); $rel_path = "{$dir}/" . basename($path); if (function_exists('wp_get_theme')) { $theme_data = wp_get_theme($dir); $version = $theme_data->get('Version'); $info_url = $theme_data->get('ThemeURI'); } else { $theme_data = get_theme($dir); $version = $theme_data['Version']; $info_url = ''; } } $details[$rel_path] = array('type' => $type, 'package' => $package, 'installed' => $version, 'info-url' => $info_url, 'key' => isset($keys[$package]) ? $keys[$package] : ''); } } return $details; }
private static function get_request_package_details($desired_packages = array()) { require_once $GLOBALS['ithemes_updater_path'] . '/packages.php'; require_once $GLOBALS['ithemes_updater_path'] . '/keys.php'; $all_packages = Ithemes_Updater_Packages::get_local_details(); reset($desired_packages); if (empty($desired_packages)) { $desired_packages = $all_packages; } else { if (is_numeric(key($desired_packages))) { $new_desired_packages = array(); foreach ($all_packages as $path => $details) { foreach ($desired_packages as $package) { if ($package != $details['package']) { continue; } $new_desired_packages[$path] = $details; break; } } $desired_packages = $new_desired_packages; } } $packages = array(); $keys = Ithemes_Updater_Keys::get(); $package_slugs = array(); foreach ($desired_packages as $data) { $package_slugs[] = $data['package']; } $legacy_keys = Ithemes_Updater_Keys::get_legacy($package_slugs); $active_themes = array('stylesheet' => get_stylesheet_directory(), 'template' => get_template_directory()); $active_themes = array_unique($active_themes); foreach ($active_themes as $index => $path) { $active_themes[$index] = basename($path); } foreach ($desired_packages as $path => $data) { $key = isset($keys[$data['package']]) ? $keys[$data['package']] : ''; $package = array('ver' => $data['installed'], 'key' => $key); if (!empty($legacy_keys[$data['package']])) { $package['old-key'] = $legacy_keys[$data['package']]; } if ('plugins' == $data['type']) { $package['active'] = (int) is_plugin_active($path); } else { $dir = dirname($path); $package['active'] = (int) in_array($dir, $active_themes); if ($package['active'] && count($active_themes) > 1) { if ($dir == $active_themes['stylesheet']) { $package['child-theme'] = 1; } else { $package['parent-theme'] = 1; } } } $package_key = $data['package']; $counter = 0; while (isset($packages[$package_key])) { $package_key = "{$data['package']} ||| " . ++$counter; } $packages[$package_key] = $package; } if (!empty($legacy_keys)) { Ithemes_Updater_Keys::delete_legacy(array_keys($legacy_keys)); } return $packages; }