当前位置: 首页>>代码示例>>PHP>>正文


PHP Plugin_Upgrader::install_package方法代码示例

本文整理汇总了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);
 }
开发者ID:JSreactor,项目名称:MarketCrater.com,代码行数:33,代码来源:custom-plugin-upgrader.php

示例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);
 }
开发者ID:mikevanwinkle,项目名称:cli,代码行数:8,代码来源:DestructivePluginUpgrader.php


注:本文中的Plugin_Upgrader::install_package方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。