Skip to content

Commit

Permalink
Support delete file using wp-cli command (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
sy-records committed Jun 22, 2024
1 parent 3d10054 commit 9c8590a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 7 deletions.
23 changes: 23 additions & 0 deletions cos-commands.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,29 @@ public function upload_file($args, $assoc_args)
WP_CLI::error("Failed: {$path}");
}
}

/**
* 删除 COS 中的文件
*
* ## OPTIONS
*
* <key>
* : 需要删除 COS 中的文件 key
*
* ## EXAMPLES
*
* wp cos delete-file 2021/01/1.jpg
*
* @when after_wp_load
* @subcommand delete-file
*/
public function delete_file($args, $assoc_args)
{
[$key] = $args;
WP_CLI::line("Deleting file [{$key}] from COS...");

cos_delete_cos_file($key);
}
}

WP_CLI::add_command('cos', 'COS_CLI_Commands', ['shortdesc' => 'Commands used to operate COS.']);
6 changes: 3 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tags: COS, 腾讯云, 对象存储, Tencent, Qcloud
Requires at least: 4.6
Tested up to: 6.5
Requires PHP: 7.2
Stable tag: 2.5.6
Stable tag: 2.5.7
License: Apache2.0
License URI: http://www.apache.org/licenses/LICENSE-2.0.html

Expand Down Expand Up @@ -103,8 +103,8 @@ License URI: http://www.apache.org/licenses/LICENSE-2.0.html

= Stable =

- Optimize chart display, you can set constants to be turned off.
- Support wp-cli commands to upload files.
- Fix upload heic format file error.
- Support delete file using `wp-cli` command.

= Other =

Expand Down
8 changes: 4 additions & 4 deletions sync-qcloud-cos.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Sync QCloud COS
Plugin URI: https://qq52o.me/2518.html
Description: 使用腾讯云对象存储服务 COS 作为附件存储空间。(Using Tencent Cloud Object Storage Service COS as Attachment Storage Space.)
Version: 2.5.6
Version: 2.5.7
Author: 沈唁
Author URI: https://qq52o.me
License: Apache2.0
Expand All @@ -27,7 +27,7 @@
use SyncQcloudCos\Monitor\DataPoints;
use SyncQcloudCos\Object\Head;

define('COS_VERSION', '2.5.6');
define('COS_VERSION', '2.5.7');
define('COS_PLUGIN_SLUG', 'sync-qcloud-cos');
define('COS_PLUGIN_PAGE', plugin_basename(dirname(__FILE__)) . '%2F' . basename(__FILE__));

Expand Down Expand Up @@ -857,7 +857,7 @@ function cos_get_regional($regional)
*/
function cos_get_url_scheme($separator = '://')
{
$isHttps = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443;
$isHttps = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443);
$scheme = $isHttps ? 'https' : 'http';

return $scheme . $separator;
Expand Down Expand Up @@ -1828,7 +1828,7 @@ function cos_setting_page()
<?php endif; ?>
<hr>
<p>优惠活动:<a href="https://qq52o.me/welfare.html#qcloud" target="_blank">腾讯云优惠</a> / <a href="https://go.qq52o.me/a/cos" target="_blank">腾讯云COS资源包优惠</a>;</p>
<p>限时推广:<a href="https://cloud.tencent.com/developer/support-plan?invite_code=cqidlih5bagj" target="_blank">技术博客可以加入腾讯云云+社区定制周边礼品等你来拿</a>;</p>
<p>限时推广:<a href="https://cloud.tencent.com/developer/support-plan?invite_code=cqidlih5bagj" target="_blank">满足条件的自媒体,入驻腾讯云开发者社区,可分享总价值百万资源包</a>;</p>
</div>
<?php
}
Expand Down

0 comments on commit 9c8590a

Please sign in to comment.