Compare commits

...

35 Commits

Author SHA1 Message Date
Luffy 96d6861184
Update nonce handling for form submissions (#53) 2025-09-17 13:03:02 +08:00
sy-records fd39ea37af Update readme.txt
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-04-23 02:50:21 +00:00
Luffy 2d7be1839d
Bump version to 1.5.0 and enhance region handling for OSS configuration (#51) 2025-02-20 11:46:28 +08:00
Luffy 04023f72eb
Optimize uninstall code (#49) 2025-02-14 14:55:03 +08:00
Luffy f291f253aa
Fix origin_protect default value error (#47) 2024-12-14 08:25:22 +08:00
Luffy fe38540a5b
Update .distignore 2024-12-13 11:26:52 +08:00
Luffy bc9387d3ad
Fix sub-site failure to delete remote images (#46) 2024-11-22 11:06:33 +08:00
sy-records f9598e9d71 Update readme.txt
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-11-16 00:07:37 +00:00
Luffy c8981d2ced
Images processing ignore gif format (#43) 2024-08-14 10:15:01 +08:00
Luffy 28df5b05f4
Fix endpoint failed to use https (#42) 2024-08-01 08:20:11 +08:00
sy-records 69626aa636
fix comment 2024-07-24 08:21:48 +08:00
sy-records eda8511bda
Force endpoint to use https 2024-07-24 08:19:52 +08:00
Luffy c32790061d
Upgrade signature from V1 to V4 (#40) 2024-07-21 08:55:03 +08:00
sy-records 1892fd78b9 Update readme.txt
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-07-19 02:15:31 +00:00
Luffy f8976d8915
Use wp_get_mime_types instead of get_allowed_mime_types (#39) 2024-06-29 08:02:47 +08:00
Luffy 53934e9d4b
Support wp-cli commands to upload files (#38) 2024-06-07 08:12:25 +08:00
sy-records b192c22585 Update readme.txt 2024-05-28 00:29:25 +00:00
sy-records 52aa553d9e Update readme.txt 2024-05-28 00:15:58 +00:00
sy-records 30781999db Update readme.txt 2024-04-03 00:15:43 +00:00
Luffy 0ef8ef14bd
Support origin protect(#36)
* Support origin protect

* Update version
2024-03-23 09:21:59 +08:00
Luffy 30e7e6eb17
Optimize wpdb query (#34) 2024-03-07 18:41:08 +08:00
Luffy ce9cfa44e1
Fix get non-image file size error (#33) 2024-02-29 18:22:18 +08:00
Luffy 530ddf967d
Fix CSRF error (#31) 2024-02-06 16:33:24 +08:00
Luffy 7096900318
Update composer.json (#30) 2024-02-04 18:48:39 +08:00
Luffy 59c57fe976
Add Live Preview (#29) 2024-02-01 08:08:55 +08:00
Lu Fei 9852fff6c2
Fix duplicate append image style param (#26) 2023-12-14 09:55:04 +08:00
sy-records 9a9882fd96
Fix delete file and optimize image style (#25) 2023-12-06 08:22:52 +08:00
sy-records dd04d774bf Update readme.txt 2023-11-10 00:20:33 +00:00
sy-records 6c09f4057e
Fix errors when uploading PDF and other file formats 2023-10-19 10:35:23 +08:00
sy-records 48df76994b
Compatible with PHP 7.0 2023-10-19 08:37:59 +08:00
Lu Fei cb26713b32
Fix missing delete original image (#24) 2023-10-18 08:46:48 +08:00
Lu Fei 935d8c8807
Fix sync error (#23) 2023-10-13 13:25:48 +08:00
Lu Fei 7e05247e33
Optimize sync file code (#22)
* Optimize sync file code

* Update aliyun-oss-wordpress.php
2023-10-12 07:00:52 +08:00
Lu Fei 657697ad44
Support save image editor file (#21) 2023-08-16 08:24:14 +08:00
Lu Fei 98dae8c651
Update deploy ci (#20) 2023-08-12 03:34:56 +08:00
15 changed files with 890 additions and 381 deletions

View File

@ -1,6 +1,10 @@
/.git
/.github
/.distignore
/.wordpress-org
/sdk/composer.lock
/sdk/vendor/aliyuncs/oss-sdk-php/samples/
/sdk/vendor/aliyuncs/oss-sdk-php/tests/
/sdk/vendor/aliyuncs/oss-sdk-php/.coveralls.yml
*.github
*.php_cs*

12
.github/workflows/asset-update.yaml vendored Normal file
View File

@ -0,0 +1,12 @@
name: Plugin asset/readme update
on:
workflow_dispatch:
push:
branches:
- master
jobs:
update:
uses: sy-records/.github/.github/workflows/wordpress-plugin-asset-update.yaml@main
with:
skip_assets: false
secrets: inherit

View File

@ -4,41 +4,8 @@ on:
release:
types: [ published ]
jobs:
tag:
name: New release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Setup PHP
uses: shivammathur/setup-php@v2
deploy:
uses: sy-records/.github/.github/workflows/wordpress-plugin-deploy.yaml@main
with:
php-version: '7.0'
tools: composer
- name: Build
run: |
composer install -o --no-dev
working-directory: sdk
- name: Set Version
if: github.event_name == 'pull_request'
run: |
echo "VERSION=ci" >> $GITHUB_ENV
- name: WordPress Plugin Deploy
id: deploy
uses: 10up/action-wordpress-plugin-deploy@stable
with:
dry-run: ${{ github.event_name == 'pull_request' }}
generate-zip: ${{ github.event_name == 'release' }}
env:
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }}
SVN_USERNAME: ${{ secrets.SVN_USERNAME }}
SLUG: oss-aliyun
- name: Upload release asset
uses: actions/upload-release-asset@v1
if: github.event_name == 'release'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ steps.deploy.outputs.zip-path }}
asset_name: ${{ github.event.repository.name }}.zip
asset_content_type: application/zip
build: true
secrets: inherit

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -0,0 +1,27 @@
{
"landingPage": "/wp-admin/admin.php?page=oss-aliyun%2Faliyun-oss-wordpress.php",
"preferredVersions": {
"php": "latest",
"wp": "latest"
},
"phpExtensionBundles": [
"kitchen-sink"
],
"steps": [
{
"step": "login",
"username": "admin",
"password": "password"
},
{
"step": "installPlugin",
"pluginZipFile": {
"resource": "wordpress.org/plugins",
"slug": "oss-aliyun"
},
"options": {
"activate": true
}
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Before

Width:  |  Height:  |  Size: 385 KiB

After

Width:  |  Height:  |  Size: 385 KiB

View File

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

View File

@ -10,17 +10,23 @@
[![plugin installs](https://img.shields.io/wordpress/plugin/installs/oss-aliyun)](https://wordpress.org/plugins/oss-aliyun/)
[![Deploy to WordPress.org](https://github.com/sy-records/aliyun-oss-wordpress/actions/workflows/deploy.yml/badge.svg)](https://github.com/sy-records/aliyun-oss-wordpress/actions/workflows/deploy.yml)
> 使用 WordPress Playground 在线预览 [OSS Aliyun](https://wordpress.org/plugins/oss-aliyun/?preview=1) 插件
## 插件特色
* [x] 可配置是否上传缩略图和是否保留本地备份
* [x] 本地删除可同步删除阿里云对象存储OSS中的文件
* [x] 支持阿里云对象存储OSS绑定的用户域名
* [x] 支持替换数据库中旧的资源链接地址
* [x] 支持阿里云对象存储OSS完整地域使用
* [x] 支持同步历史附件到阿里云对象存储OSS
* [x] 支持阿里云OSS图片处理
* [x] 支持上传文件自动重命名
* [x] 支持使用RAM操作
- [x] 可配置是否上传缩略图和是否保留本地备份
- [x] 本地删除可同步删除阿里云对象存储 OSS 中的文件
- [x] 支持阿里云对象存储 OSS 绑定的用户域名
- [x] 支持替换数据库中旧的资源链接地址
- [x] 支持阿里云对象存储 OSS 完整地域使用
- [x] 支持同步历史附件到阿里云对象存储 OSS
- [x] 支持阿里云 OSS 图片处理
- [x] 支持上传文件自动重命名
- [x] 支持使用 ECS 的 RAM 操作
- [x] 支持原图保护
- [x] 支持 `wp-cli` 命令上传/删除文件
- [x] 支持多站点
- [x] 支持图片裁剪编辑等操作后的上传
## 安装
@ -36,16 +42,16 @@ GitHub 下载节点:[https://github.com/sy-records/aliyun-oss-wordpress/releas
## 修改配置
* 方法一:在 WordPress 插件管理页面有设置按钮,进行设置
* 方法二:在 WordPress 后台管理左侧导航栏`设置`下`阿里云OSS设置`,点击进入设置页面
- 方法一:在 WordPress 插件管理页面有设置按钮,进行设置
- 方法二:在 WordPress 后台管理左侧导航栏`设置`下`阿里云OSS设置`,点击进入设置页面
## 常见问题
* 通过文件URL访问图片无法预览而是以附件形式下载?
- 通过文件 URL 访问图片无法预览而是以附件形式下载?
因为 Bucket 是 2019 年 9 月 23 日后创建的,使用默认域名时会自动下载,需要绑定自有域名访问。具体参考[阿里云文档](https://help.aliyun.com/document_detail/142631.html)。
* 如果存在第三方插件或者主题自带上传功能,内容上传到`本地文件夹`(即默认`wp-content/uploads`)中怎么上传到oss中
- 如果存在第三方插件或者主题自带上传功能,内容上传到`本地文件夹`(即默认`wp-content/uploads`)中,怎么上传到 oss 中?
解决方案有两种,推荐使用第二种。
@ -54,6 +60,6 @@ GitHub 下载节点:[https://github.com/sy-records/aliyun-oss-wordpress/releas
## 插件截图
![设置页面](screenshot-1.png)
![设置页面](.wordpress-org/screenshot-1.png)
![update-wordpress-posts-photos.png](screenshot-2.png)
![update-wordpress-posts-photos.png](.wordpress-org/screenshot-2.png)

File diff suppressed because it is too large Load Diff

123
oss-commands.php Normal file
View File

@ -0,0 +1,123 @@
<?php
if (!class_exists('WP_CLI')) {
return;
}
class OSS_CLI_Commands
{
/**
* 同步文件夹到 OSS
*
* ## OPTIONS
*
* <path>
* : 要同步的文件夹
*
* ## EXAMPLES
*
* wp oss upload wp-content/uploads
*
* @when after_wp_load
*/
public function upload($args, $assoc_args)
{
[$path] = $args;
$dir = ABSPATH . $path;
if (!is_dir($dir)) {
WP_CLI::error("Directory not found: [{$dir}]");
}
WP_CLI::line("Uploading files from [{$dir}] to OSS...");
$files = oss_read_dir_queue(ABSPATH, $path);
if (empty($files)) {
WP_CLI::success('No files to upload.');
return;
}
foreach ($files as $file) {
$status = oss_file_upload($file['key'], $file['filepath']);
if ($status) {
WP_CLI::line("Uploaded: {$file['key']}");
} else {
WP_CLI::line("Failed: {$file['key']}");
}
}
$total = count($files);
WP_CLI::success("Uploaded {$total} files.");
}
/**
* 同步文件到 OSS
*
* ## OPTIONS
*
* <path>
* : 要同步的文件
*
* [--delete]
* : 如果设置,上传后会删除本地文件
* [--key=<key>]
* : 指定上传到 OSS key默认和文件路径一致
*
* ## EXAMPLES
*
* wp oss upload-file wp-content/uploads/2021/01/1.jpg
* wp oss upload-file wp-content/uploads/2021/01/1.jpg --delete
* wp oss upload-file wp-content/uploads/2021/01/1.jpg --key=2021/01/1.jpg
*
* @when after_wp_load
* @subcommand upload-file
*/
public function upload_file($args, $assoc_args)
{
[$path] = $args;
$file = ABSPATH . $path;
if (!is_file($file)) {
WP_CLI::error("File not found: {$file}");
}
$delete = false;
if (isset($assoc_args['delete'])) {
$delete = true;
}
$key = isset($assoc_args['key']) ? $assoc_args['key'] : $path;
WP_CLI::line("Uploading file [{$file}] to OSS with key [$key]...");
$status = oss_file_upload("/{$key}", $file, $delete);
if ($status) {
WP_CLI::success("Uploaded: {$path}");
} else {
WP_CLI::error("Failed: {$path}");
}
}
/**
* 删除 OSS 中的文件
*
* ## OPTIONS
*
* <key>
* : 需要删除 OSS 中的文件 key
*
* ## EXAMPLES
*
* wp oss 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 OSS...");
oss_delete_oss_file($key);
}
}
WP_CLI::add_command('oss', 'OSS_CLI_Commands', ['shortdesc' => 'Commands used to operate OSS.']);

View File

@ -2,20 +2,20 @@
Contributors: shenyanzhi
Donate link: https://qq52o.me/sponsor.html
Tags: oss, 阿里云, 对象存储, aliyun
Requires at least: 4.2
Tested up to: 6.3
Requires PHP: 7.0.0
Stable tag: 1.4.0
Requires at least: 4.6
Tested up to: 6.8
Requires PHP: 7.1
Stable tag: 1.5.1
License: Apache2.0
License URI: http://www.apache.org/licenses/LICENSE-2.0.html
使用阿里云对象存储 OSS 作为附件存储空间。This is a plugin that uses Aliyun Object Storage Service for attachments remote saving.
使用阿里云对象存储 OSS 作为附件存储空间。(This is a plugin that uses Aliyun Object Storage Service for attachments remote saving.)
== Description ==
使用阿里云对象存储 OSS 作为附件存储空间。This is a plugin that uses Aliyun Object Storage Service for attachments remote saving.
使用阿里云对象存储 OSS 作为附件存储空间。(This is a plugin that uses Aliyun Object Storage Service for attachments remote saving.)
* 依赖阿里云OSS服务https://www.aliyun.com/product/oss
- 依赖阿里云 OSS 服务https://www.aliyun.com/product/oss
## 插件特点
@ -27,7 +27,12 @@ License URI: http://www.apache.org/licenses/LICENSE-2.0.html
6. 支持同步历史附件到阿里云对象存储 OSS
7. 支持阿里云 OSS 图片处理
8. 支持上传文件自动重命名
9. 插件更多详细介绍和安装:[https://github.com/sy-records/aliyun-oss-wordpress](https://github.com/sy-records/aliyun-oss-wordpress)
9. 支持使用 ECS 的 RAM 操作
10. 支持原图保护
11. 支持 `wp-cli` 命令上传/删除文件
12. 支持多站点
13. 支持图片裁剪编辑等操作后的上传
14. 插件更多详细介绍和安装:[https://github.com/sy-records/aliyun-oss-wordpress](https://github.com/sy-records/aliyun-oss-wordpress)
## 其他插件
@ -50,8 +55,9 @@ License URI: http://www.apache.org/licenses/LICENSE-2.0.html
== Screenshots ==
1. screenshot-1.png
2. screenshot-2.png
1. 设置页面
2. 数据库同步
3. 内置的 wp-cli 命令
== Frequently Asked Questions ==
@ -72,70 +78,187 @@ License URI: http://www.apache.org/licenses/LICENSE-2.0.html
== Changelog ==
= 1.5.1 =
- Update nonce handling for form submissions
= 1.5.0 =
- Enhance region handling for OSS configuration
= 1.4.21 =
- Optimize uninstall code
= 1.4.20 =
- Fix origin_protect default value error
= 1.4.19 =
- Fix sub-site failure to delete remote images
- Fix `get_option` default value error
- Fix missing delete backup images
= 1.4.18 =
- Images processing ignore gif format
= 1.4.17 =
- Fix endpoint failed to use https
= 1.4.16 =
- 强制 endpoint 使用 https
= 1.4.15 =
- 将阿里云V1签名升级为V4签名
= 1.4.14 =
- 支持 `wp-cli` 命令删除文件
- Use wp_get_mime_types instead of get_allowed_mime_types
- 修复 heic 格式图片上传失败问题
= 1.4.13 =
- 支持 `wp-cli` 命令上传文件
= 1.4.12 =
- 支持原图保护
= 1.4.11 =
- 优化数据库数据替换语法
= 1.4.10 =
- 修复`不在本地保留备份`时获取不到非图片文件大小
= 1.4.9 =
- 升级 SDK
- 增加 CSRF 验证
= 1.4.8 =
- 修复图片处理参数重复添加
= 1.4.7 =
- 修复 `upload_url_path` 设置为 `.` 时删除失败
- 优化图片处理参数追加
= 1.4.6 =
- 修复 pdf 等文件格式上传时报错
= 1.4.5 =
- 兼容 PHP 7.0
= 1.4.4 =
- 修复超大文件原图上传和删除
= 1.4.3 =
- 修复同步错误
- 更新地域
= 1.4.2 =
- 优化同步代码逻辑
- 修复 webp 和 heic 格式图片上传缩略图失败问题
= 1.4.1 =
- 支持媒体库编辑图片上传
= 1.4.0 =
* 支持 WordPress 6.3 版本
* 支持 RAM 操作 OSS
- 支持 WordPress 6.3 版本
- 支持 RAM 操作 OSS
= 1.3.2 =
* 添加地域
- 添加地域
= 1.3.1 =
* 优化代码
- 优化代码
= 1.3.0 =
* 增加地域
* 优化 isset 判断
* 优化访问权限
* 修复存在同名 path 时截取错误
* 修改 accessKeySecret 类型为 password
- 增加地域
- 优化 isset 判断
- 优化访问权限
- 修复存在同名 path 时截取错误
- 修改 accessKeySecret 类型为 password
= 1.2.8 =
* 支持上传文件自动重命名
* 优化图片处理
- 支持上传文件自动重命名
- 优化图片处理
= 1.2.7 =
* 增加地域
- 增加地域
= 1.2.6 =
* 升级 oss sdk
* 修复删除文件的request id异常
* 支持 WordPress 5.8 版本
- 升级 oss sdk
- 修复删除文件的 request id 异常
- 支持 WordPress 5.8 版本
= 1.2.5 =
* 修复当文章图片重复时导致添加多个样式
- 修复当文章图片重复时导致添加多个样式
= 1.2.4 =
* 添加 get_home_path 方法判断
* 支持 WordPress 5.7 版本
- 添加 get_home_path 方法判断
- 支持 WordPress 5.7 版本
= 1.2.3 =
* 支持删除非图片类型文件
- 支持删除非图片类型文件
= 1.2.2 =
* 支持 WordPress 5.6 版本
* 升级 OSS SDK
* 修复勾选不上传缩略图删除时不会删除已存在的缩略图
- 支持 WordPress 5.6 版本
- 升级 OSS SDK
- 修复勾选不上传缩略图删除时不会删除已存在的缩略图
= 1.2.1 =
* 支持阿里云OSS图片处理
- 支持阿里云 OSS 图片处理
= 1.2.0 =
* 优化同步上传路径获取
* 修复多站点上传原图失败,缩略图正常问题
* 优化上传路径获取
* 增加数据库题图链接替换
- 优化同步上传路径获取
- 修复多站点上传原图失败,缩略图正常问题
- 优化上传路径获取
- 增加数据库题图链接替换
= 1.1.1 =
* 修复本地文件夹为根目录时路径错误
* 减少一次获取配置代码...
* 增加回源说明
- 修复本地文件夹为根目录时路径错误
- 减少一次获取配置代码...
- 增加回源说明
= 1.1.0 =
* 优化删除文件使用删除多个接口
* 修复勾选不在本地保存图片后媒体库显示默认图片问题
- 优化删除文件使用删除多个接口
- 修复勾选不在本地保存图片后媒体库显示默认图片问题
= 1.0.1 =
* 修复勾选不在本地保存图片后媒体库显示默认图片问题
- 修复勾选不在本地保存图片后媒体库显示默认图片问题
= 1.0 =
* First version
- First version

View File

@ -1,6 +1,6 @@
{
"require": {
"aliyuncs/oss-sdk-php": "^2.3",
"aliyuncs/oss-sdk-php": "^2.7",
"alibabacloud/credentials": "^1.1"
}
}

View File

@ -1,18 +1,8 @@
<?php
//防止有人恶意访问此文件,所以在没有 WP_UNINSTALL_PLUGIN 常量的情况下结束程序
if (!defined('WP_UNINSTALL_PLUGIN')) {
exit();
exit;
}
$obs_options = get_option('oss_options', true);
$upload_url_path = get_option('upload_url_path');
$oss_upload_url_path = esc_attr($obs_options['upload_url_path']);
//如果现在使用的是OSS的URL则恢复原状
if ($upload_url_path == $oss_upload_url_path) {
update_option('upload_url_path', '');
}
//移除配置
delete_option('oss_options');