parent
1892fd78b9
commit
c32790061d
|
@ -22,9 +22,9 @@
|
|||
- [x] 支持同步历史附件到阿里云对象存储 OSS
|
||||
- [x] 支持阿里云 OSS 图片处理
|
||||
- [x] 支持上传文件自动重命名
|
||||
- [x] 支持使用 RAM 操作
|
||||
- [x] 支持使用 ECS 的 RAM 操作
|
||||
- [x] 支持原图保护
|
||||
- [x] 支持 `wp-cli` 命令上传文件
|
||||
- [x] 支持 `wp-cli` 命令上传/删除文件
|
||||
|
||||
## 安装
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
Plugin Name: OSS Aliyun
|
||||
Plugin URI: https://github.com/sy-records/aliyun-oss-wordpress
|
||||
Description: 使用阿里云对象存储 OSS 作为附件存储空间。(This is a plugin that uses Aliyun Object Storage Service for attachments remote saving.)
|
||||
Version: 1.4.14
|
||||
Version: 1.4.15
|
||||
Author: 沈唁
|
||||
Author URI: https://qq52o.me
|
||||
License: Apache2.0
|
||||
|
@ -19,7 +19,7 @@ use OSS\Credentials\CredentialsProvider;
|
|||
use AlibabaCloud\Credentials\Credential;
|
||||
use OSS\Credentials\StaticCredentialsProvider;
|
||||
|
||||
define('OSS_VERSION', '1.4.14');
|
||||
define('OSS_VERSION', '1.4.15');
|
||||
define('OSS_BASEFOLDER', plugin_basename(dirname(__FILE__)));
|
||||
|
||||
if (!function_exists('get_home_path')) {
|
||||
|
@ -75,33 +75,36 @@ function oss_set_options()
|
|||
|
||||
function oss_get_client()
|
||||
{
|
||||
$oss_opt = get_option('oss_options', true);
|
||||
$roleName = esc_attr($oss_opt['role_name'] ?? '');
|
||||
$endpoint = oss_get_bucket_endpoint($oss_opt);
|
||||
$oss_options = get_option('oss_options', true);
|
||||
$role_name = esc_attr($oss_options['role_name'] ?? '');
|
||||
$endpoint = oss_get_bucket_endpoint($oss_options);
|
||||
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? 'https://' : 'http://';
|
||||
|
||||
if (!empty($roleName)) {
|
||||
if (!empty($role_name)) {
|
||||
$ecsRamRole = new Credential([
|
||||
// 填写Credential类型,固定值为ecs_ram_role。
|
||||
'type' => 'ecs_ram_role',
|
||||
// 填写角色名称。
|
||||
'role_name' => $roleName,
|
||||
'role_name' => $role_name,
|
||||
]);
|
||||
$providerWrapper = new OSSCredentialsWrapper($ecsRamRole);
|
||||
$provider = $providerWrapper->getCredentials();
|
||||
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? 'https://' : 'http://';
|
||||
$config = ['provider' => $provider, 'endpoint'=> $protocol . $endpoint];
|
||||
return new OssClient($config);
|
||||
} else {
|
||||
$provider = new StaticCredentialsProvider(esc_attr($oss_options['accessKeyId']), esc_attr($oss_options['accessKeySecret']));
|
||||
}
|
||||
|
||||
$accessKeyId = esc_attr($oss_opt['accessKeyId']);
|
||||
$accessKeySecret = esc_attr($oss_opt['accessKeySecret']);
|
||||
return new OssClient($accessKeyId, $accessKeySecret, $endpoint);
|
||||
$config = [
|
||||
'provider' => $provider,
|
||||
'endpoint' => $protocol . $endpoint,
|
||||
'signatureVersion' => OssClient::OSS_SIGNATURE_VERSION_V4,
|
||||
'region' => str_replace('oss-', '', esc_attr($oss_options['regional'])),
|
||||
];
|
||||
return new OssClient($config);
|
||||
}
|
||||
|
||||
function oss_get_bucket_endpoint($oss_option)
|
||||
function oss_get_bucket_endpoint($oss_options)
|
||||
{
|
||||
$oss_regional = esc_attr($oss_option['regional']);
|
||||
if ($oss_option['is_internal'] == 'true') {
|
||||
$oss_regional = esc_attr($oss_options['regional']);
|
||||
if ($oss_options['is_internal'] == 'true') {
|
||||
return "{$oss_regional}-internal.aliyuncs.com";
|
||||
}
|
||||
|
||||
|
@ -110,8 +113,8 @@ function oss_get_bucket_endpoint($oss_option)
|
|||
|
||||
function oss_get_bucket_name()
|
||||
{
|
||||
$oss_opt = get_option('oss_options', true);
|
||||
return $oss_opt['bucket'];
|
||||
$oss_options = get_option('oss_options', true);
|
||||
return $oss_options['bucket'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -573,6 +576,11 @@ function oss_setting_post_thumbnail_style($html, $post_id, $post_image_id)
|
|||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* @link https://help.aliyun.com/zh/oss/user-guide/regions-and-endpoints
|
||||
* @param string $regional
|
||||
* @return void
|
||||
*/
|
||||
function oss_get_regional($regional)
|
||||
{
|
||||
$options = [
|
||||
|
|
|
@ -6,7 +6,6 @@ if (!class_exists('WP_CLI')) {
|
|||
|
||||
class OSS_CLI_Commands
|
||||
{
|
||||
|
||||
/**
|
||||
* 同步文件夹到 OSS
|
||||
*
|
||||
|
|
10
readme.txt
10
readme.txt
|
@ -5,7 +5,7 @@ Tags: oss, 阿里云, 对象存储, aliyun
|
|||
Requires at least: 4.6
|
||||
Tested up to: 6.6
|
||||
Requires PHP: 7.1
|
||||
Stable tag: 1.4.14
|
||||
Stable tag: 1.4.15
|
||||
License: Apache2.0
|
||||
License URI: http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
|
@ -27,9 +27,9 @@ License URI: http://www.apache.org/licenses/LICENSE-2.0.html
|
|||
6. 支持同步历史附件到阿里云对象存储 OSS
|
||||
7. 支持阿里云 OSS 图片处理
|
||||
8. 支持上传文件自动重命名
|
||||
9. 支持使用 RAM 操作
|
||||
9. 支持使用 ECS 的 RAM 操作
|
||||
10. 支持原图保护
|
||||
11. 支持 `wp-cli` 命令上传文件
|
||||
11. 支持 `wp-cli` 命令上传/删除文件
|
||||
12. 插件更多详细介绍和安装:[https://github.com/sy-records/aliyun-oss-wordpress](https://github.com/sy-records/aliyun-oss-wordpress)
|
||||
|
||||
## 其他插件
|
||||
|
@ -76,6 +76,10 @@ License URI: http://www.apache.org/licenses/LICENSE-2.0.html
|
|||
|
||||
== Changelog ==
|
||||
|
||||
= 1.4.15 =
|
||||
|
||||
- 将阿里云V1签名升级为V4签名
|
||||
|
||||
= 1.4.14 =
|
||||
|
||||
- 支持 `wp-cli` 命令删除文件
|
||||
|
|
Loading…
Reference in New Issue