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


PHP Plugin_Upgrader::clear_destination方法代码示例

本文整理汇总了PHP中Plugin_Upgrader::clear_destination方法的典型用法代码示例。如果您正苦于以下问题:PHP Plugin_Upgrader::clear_destination方法的具体用法?PHP Plugin_Upgrader::clear_destination怎么用?PHP Plugin_Upgrader::clear_destination使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Plugin_Upgrader的用法示例。


在下文中一共展示了Plugin_Upgrader::clear_destination方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: clear_destination

 public function clear_destination($destination)
 {
     global $wp_filesystem;
     if (!is_dir($destination)) {
         // This is an installation not an upgrade.
         return parent::clear_destination($destination);
     }
     $data = $this->caj_get_plugin_data($destination);
     if (false === $data) {
         // The existing directory is not a valid plugin, skip backup.
         return parent::clear_destination($destination);
     }
     $backup_url = $this->caj_create_backup($destination);
     if (!is_wp_error($backup_url)) {
         /* translators: 1: plugin zip URL */
         $this->skin->feedback(sprintf(__('A backup zip file of the old plugin 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 plugin to a new directory&#8230;', 'easy-theme-and-plugin-upgrades'));
     $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 plugin 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 plugin directory name */
             $this->skin->feedback(sprintf(__('Moved the old version of the plugin to a new plugin 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 plugin 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);
 }
开发者ID:JSreactor,项目名称:MarketCrater.com,代码行数:49,代码来源:custom-plugin-upgrader.php


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