Compare commits

..

No commits in common. "master" and "v1.4.0" have entirely different histories.

15 changed files with 380 additions and 889 deletions

View File

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

View File

@ -1,12 +0,0 @@
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,8 +4,41 @@ on:
release: release:
types: [ published ] types: [ published ]
jobs: jobs:
deploy: tag:
uses: sy-records/.github/.github/workflows/wordpress-plugin-deploy.yaml@main name: New release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Setup PHP
uses: shivammathur/setup-php@v2
with: with:
build: true php-version: '7.0'
secrets: inherit 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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

View File

@ -1,27 +0,0 @@
{
"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.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 97 KiB

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -1,123 +0,0 @@
<?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 Contributors: shenyanzhi
Donate link: https://qq52o.me/sponsor.html Donate link: https://qq52o.me/sponsor.html
Tags: oss, 阿里云, 对象存储, aliyun Tags: oss, 阿里云, 对象存储, aliyun
Requires at least: 4.6 Requires at least: 4.2
Tested up to: 6.8 Tested up to: 6.3
Requires PHP: 7.1 Requires PHP: 7.0.0
Stable tag: 1.5.1 Stable tag: 1.4.0
License: Apache 2.0 License: Apache 2.0
License URI: http://www.apache.org/licenses/LICENSE-2.0.html 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 == == 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,12 +27,7 @@ License URI: http://www.apache.org/licenses/LICENSE-2.0.html
6. 支持同步历史附件到阿里云对象存储OSS 6. 支持同步历史附件到阿里云对象存储OSS
7. 支持阿里云OSS图片处理 7. 支持阿里云OSS图片处理
8. 支持上传文件自动重命名 8. 支持上传文件自动重命名
9. 支持使用 ECS 的 RAM 操作 9. 插件更多详细介绍和安装:[https://github.com/sy-records/aliyun-oss-wordpress](https://github.com/sy-records/aliyun-oss-wordpress)
10. 支持原图保护
11. 支持 `wp-cli` 命令上传/删除文件
12. 支持多站点
13. 支持图片裁剪编辑等操作后的上传
14. 插件更多详细介绍和安装:[https://github.com/sy-records/aliyun-oss-wordpress](https://github.com/sy-records/aliyun-oss-wordpress)
## 其他插件 ## 其他插件
@ -55,9 +50,8 @@ License URI: http://www.apache.org/licenses/LICENSE-2.0.html
== Screenshots == == Screenshots ==
1. 设置页面 1. screenshot-1.png
2. 数据库同步 2. screenshot-2.png
3. 内置的 wp-cli 命令
== Frequently Asked Questions == == Frequently Asked Questions ==
@ -78,187 +72,70 @@ License URI: http://www.apache.org/licenses/LICENSE-2.0.html
== Changelog == == 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 = = 1.4.0 =
* 支持 WordPress 6.3 版本
- 支持 WordPress 6.3 版本 * 支持 RAM 操作 OSS
- 支持 RAM 操作 OSS
= 1.3.2 = = 1.3.2 =
* 添加地域
- 添加地域
= 1.3.1 = = 1.3.1 =
* 优化代码
- 优化代码
= 1.3.0 = = 1.3.0 =
* 增加地域
- 增加地域 * 优化 isset 判断
- 优化 isset 判断 * 优化访问权限
- 优化访问权限 * 修复存在同名 path 时截取错误
- 修复存在同名 path 时截取错误 * 修改 accessKeySecret 类型为 password
- 修改 accessKeySecret 类型为 password
= 1.2.8 = = 1.2.8 =
* 支持上传文件自动重命名
- 支持上传文件自动重命名 * 优化图片处理
- 优化图片处理
= 1.2.7 = = 1.2.7 =
* 增加地域
- 增加地域
= 1.2.6 = = 1.2.6 =
* 升级 oss sdk
- 升级 oss sdk * 修复删除文件的request id异常
- 修复删除文件的 request id 异常 * 支持 WordPress 5.8 版本
- 支持 WordPress 5.8 版本
= 1.2.5 = = 1.2.5 =
* 修复当文章图片重复时导致添加多个样式
- 修复当文章图片重复时导致添加多个样式
= 1.2.4 = = 1.2.4 =
* 添加 get_home_path 方法判断
- 添加 get_home_path 方法判断 * 支持 WordPress 5.7 版本
- 支持 WordPress 5.7 版本
= 1.2.3 = = 1.2.3 =
* 支持删除非图片类型文件
- 支持删除非图片类型文件
= 1.2.2 = = 1.2.2 =
* 支持 WordPress 5.6 版本
- 支持 WordPress 5.6 版本 * 升级 OSS SDK
- 升级 OSS SDK * 修复勾选不上传缩略图删除时不会删除已存在的缩略图
- 修复勾选不上传缩略图删除时不会删除已存在的缩略图
= 1.2.1 = = 1.2.1 =
* 支持阿里云OSS图片处理
- 支持阿里云 OSS 图片处理
= 1.2.0 = = 1.2.0 =
* 优化同步上传路径获取
- 优化同步上传路径获取 * 修复多站点上传原图失败,缩略图正常问题
- 修复多站点上传原图失败,缩略图正常问题 * 优化上传路径获取
- 优化上传路径获取 * 增加数据库题图链接替换
- 增加数据库题图链接替换
= 1.1.1 = = 1.1.1 =
* 修复本地文件夹为根目录时路径错误
- 修复本地文件夹为根目录时路径错误 * 减少一次获取配置代码...
- 减少一次获取配置代码... * 增加回源说明
- 增加回源说明
= 1.1.0 = = 1.1.0 =
* 优化删除文件使用删除多个接口
- 优化删除文件使用删除多个接口 * 修复勾选不在本地保存图片后媒体库显示默认图片问题
- 修复勾选不在本地保存图片后媒体库显示默认图片问题
= 1.0.1 = = 1.0.1 =
* 修复勾选不在本地保存图片后媒体库显示默认图片问题
- 修复勾选不在本地保存图片后媒体库显示默认图片问题
= 1.0 = = 1.0 =
* First version
- First version

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

View File

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

View File

@ -1,8 +1,18 @@
<?php <?php
//防止有人恶意访问此文件,所以在没有 WP_UNINSTALL_PLUGIN 常量的情况下结束程序
if (!defined('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', ''); update_option('upload_url_path', '');
}
//移除配置
delete_option('oss_options'); delete_option('oss_options');