private function set_package_details() { if (false !== $this->package_details) { return; } require_once $GLOBALS['ithemes_updater_path'] . '/packages.php'; $this->package_details = Ithemes_Updater_Packages::get_local_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; }