本文整理汇总了PHP中Theme_Upgrader::fs_connect方法的典型用法代码示例。如果您正苦于以下问题:PHP Theme_Upgrader::fs_connect方法的具体用法?PHP Theme_Upgrader::fs_connect怎么用?PHP Theme_Upgrader::fs_connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Theme_Upgrader
的用法示例。
在下文中一共展示了Theme_Upgrader::fs_connect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: do_bulk_upgrade
private function do_bulk_upgrade($packages, $type)
{
if (!in_array($type, array('plugin', 'theme'))) {
return new WP_Error('unrecognized-bulk-upgrade-type', "An unrecognized type ({$type}) was passed to do_bulk_upgrade().");
}
Ithemes_Sync_Functions::set_time_limit(300);
$original_versions = array();
foreach ($packages as $package) {
if ('plugin' === $type) {
$file_data = Ithemes_Sync_Functions::get_file_data(WP_PLUGIN_DIR . "/{$package}");
} else {
$file_data = Ithemes_Sync_Functions::get_file_data(WP_CONTENT_DIR . "/themes/{$package}/style.css");
}
$original_versions[$package] = $file_data['version'];
}
require_once ABSPATH . 'wp-admin/includes/file.php';
require_once ABSPATH . 'wp-admin/includes/plugin.php';
require_once ABSPATH . 'wp-admin/includes/misc.php';
if ('plugin' === $type) {
$upgrader = new Plugin_Upgrader($this->skin);
$result = $upgrader->bulk_upgrade($packages);
Ithemes_Sync_Functions::refresh_plugin_updates();
} else {
$upgrader = new Theme_Upgrader($this->skin);
$result = $upgrader->bulk_upgrade($packages);
Ithemes_Sync_Functions::refresh_theme_updates();
}
if (is_wp_error($result)) {
return array('errors' => array($result->get_error_code() => $result->get_error_message()));
} else {
if (false === $result) {
if ('plugin' === $type) {
$result = $upgrader->fs_connect(array(WP_CONTENT_DIR, WP_PLUGIN_DIR));
} else {
$result = $upgrader->fs_connect(array(WP_CONTENT_DIR));
}
if (is_wp_error($result)) {
return array('errors' => array($result->get_error_code() => $result->get_error_message()));
} else {
return array('errors' => array('non-connected-filesystem' => 'Unable to update due to a non-connected filesystem.'));
}
}
}
$update_details = Ithemes_Sync_Functions::get_update_details(array('verbose' => true));
$response = array();
$update_index = "{$type}s";
foreach ($result as $package => $info) {
if (false === $info) {
$response[$package]['errors']['non-connected-filesystem'] = 'Unable to update due to a non-connected filesystem.';
} else {
if (is_wp_error($info)) {
$response[$package]['errors'][$info->get_error_code()] = $info->get_error_message();
} else {
$response[$package]['wordpress_response'] = $info;
if ('plugin' === $type) {
$file_data = Ithemes_Sync_Functions::get_file_data(WP_PLUGIN_DIR . "/{$package}");
} else {
$file_data = Ithemes_Sync_Functions::get_file_data(WP_CONTENT_DIR . "/themes/{$package}/style.css");
}
$response[$package]['current_version'] = $file_data['version'];
if (isset($original_versions[$package])) {
$response[$package]['original_version'] = $original_versions[$package];
}
if (isset($update_details[$update_index][$package])) {
if ('plugin' === $type && isset($update_details[$update_index][$package]->new_version)) {
$response[$package]['current_update_version'] = $update_details[$update_index][$package]->new_version;
} else {
if ('theme' === $type && isset($update_details[$update_index][$package]['new_version'])) {
$response[$package]['current_update_version'] = $update_details[$update_index][$package]['new_version'];
}
}
}
if (isset($this->original_update_details[$update_index][$package])) {
if ('plugin' === $type && isset($this->original_update_details[$update_index][$package]->new_version)) {
$response[$package]['original_update_version'] = $this->original_update_details[$update_index][$package]->new_version;
} else {
if ('theme' === $type && isset($this->original_update_details[$update_index][$package]['new_version'])) {
$response[$package]['original_update_version'] = $this->original_update_details[$update_index][$package]['new_version'];
}
}
}
if ('plugin' === $type) {
$removed_old_update_data = $GLOBALS['ithemes_sync_request_handler']->remove_old_update_plugins_data($package);
if (!is_null($removed_old_update_data)) {
$response[$package]['removed_old_update_data'] = $removed_old_update_data;
}
}
if (!isset($response[$package]['original_update_version'])) {
$response[$package]['errors']['no-update'] = 'No update was available.';
} else {
if (version_compare($response[$package]['current_version'], $response[$package]['original_update_version'], '>=')) {
$response[$package]['success'] = 1;
if (isset($response[$package]['current_update_version'])) {
if (version_compare($response[$package]['current_version'], $response[$package]['current_update_version'], '>=')) {
$response[$package]['errors']['old-update-remains-available'] = 'The original update is still listed despite the update working properly.';
} else {
$response[$package]['errors']['new-update-available'] = 'An update is available.';
}
}
} else {
//.........这里部分代码省略.........