本文整理汇总了PHP中Theme_Upgrader::clear_destination方法的典型用法代码示例。如果您正苦于以下问题:PHP Theme_Upgrader::clear_destination方法的具体用法?PHP Theme_Upgrader::clear_destination怎么用?PHP Theme_Upgrader::clear_destination使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Theme_Upgrader
的用法示例。
在下文中一共展示了Theme_Upgrader::clear_destination方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clear_destination
public function clear_destination($destination)
{
global $wp_filesystem;
if (!is_dir($destination) || !file_exists("{$destination}/style.css")) {
// This is an installation not an upgrade.
return parent::clear_destination($destination);
}
$backup_url = $this->create_backup($destination);
if (!is_wp_error($backup_url)) {
/* translators: 1: theme zip URL */
$this->skin->feedback(sprintf(__('A backup zip file of the old theme version can be downloaded <a href="%1$s">here</a>.', 'easy-theme-and-plugin-upgrades'), $backup_url));
// Restore default strings and display the original remove_old message.
$this->upgrade_strings();
$this->skin->feedback('remove_old');
return parent::clear_destination($destination);
}
$this->skin->error($backup_url);
$this->skin->feedback(__('Moving the old version of the theme to a new directory…', 'easy-theme-and-plugin-upgrades'));
$headers = array('version' => 'Version');
$data = get_file_data("{$destination}/style.css", $headers);
$new_name = basename($destination) . "-{$data['version']}";
$directory = dirname($destination);
for ($x = 0; $x < 20; $x++) {
$test_name = $new_name . '-' . $this->get_random_characters(10, 20);
if (!is_dir("{$directory}/{$test_name}")) {
$new_name = $test_name;
break;
}
}
if (is_dir("{$directory}/{$new_name}")) {
// We gave it our best effort. Time to give up on the idea of having a backup.
$this->skin->error(__('Unable to find a new directory name to move the old version of the theme to. No backup will be created.', 'easy-theme-and-plugin-upgrades'));
} else {
$result = $wp_filesystem->move($destination, "{$directory}/{$new_name}");
if ($result) {
/* translators: 1: new theme directory name */
$this->skin->feedback(sprintf(__('Moved the old version of the theme to a new theme directory named %1$s. This directory should be backed up and removed from the site.', 'easy-theme-and-plugin-upgrades'), "<code>{$new_name}</code>"));
} else {
$this->skin->error(__('Unable to move the old version of the theme to a new directory. No backup will be created.', 'easy-theme-and-plugin-upgrades'));
}
}
// Restore default strings and display the original remove_old message.
$this->upgrade_strings();
$this->skin->feedback('remove_old');
return parent::clear_destination($destination);
}