本文整理汇总了PHP中Plugin_Upgrader::install_package方法的典型用法代码示例。如果您正苦于以下问题:PHP Plugin_Upgrader::install_package方法的具体用法?PHP Plugin_Upgrader::install_package怎么用?PHP Plugin_Upgrader::install_package使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plugin_Upgrader
的用法示例。
在下文中一共展示了Plugin_Upgrader::install_package方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: install_package
public function install_package($args = array())
{
global $wp_filesystem;
error_reporting(E_ALL);
ini_set('display_errors', 1);
if (empty($args['source']) || empty($args['destination'])) {
// Only run if the arguments we need are present.
return parent::install_package($args);
}
$source_files = array_keys($wp_filesystem->dirlist($args['source']));
$remote_destination = $wp_filesystem->find_folder($args['destination']);
// Locate which directory to copy to the new folder, This is based on the actual folder holding the files.
if (1 === count($source_files) && $wp_filesystem->is_dir(trailingslashit($args['source']) . $source_files[0] . '/')) {
// Only one folder? Then we want its contents.
$destination = trailingslashit($remote_destination) . trailingslashit($source_files[0]);
} elseif (0 === count($source_files)) {
// Looks like an empty zip, we'll let the default code handle this.
return parent::install_package($args);
} else {
// It's only a single file, the upgrader will use the folder name of this file as the destination folder. Folder name is based on zip filename.
$destination = trailingslashit($remote_destination) . trailingslashit(basename($args['source']));
}
if (is_dir($destination)) {
// This is an upgrade, clear the destination.
$args['clear_destination'] = true;
// Switch template strings to use upgrade terminology rather than install terminology.
$this->upgrade_strings();
// Replace default remove_old string to make the messages more meaningful.
$this->strings['installing_package'] = __('Upgrading the plugin…', 'easy-theme-and-plugin-upgrades');
$this->strings['remove_old'] = __('Backing up the old version of the plugin…', 'easy-theme-and-plugin-upgrades');
}
return parent::install_package($args);
}
示例2: array
function install_package($args = array())
{
parent::upgrade_strings();
// needed for the 'remove_old' string
$args['clear_destination'] = true;
$args['abort_if_destination_exists'] = false;
return parent::install_package($args);
}