| 1 |
<?php |
| 2 |
/** |
| 3 |
* WPOSS 插件卸载脚本 |
| 4 |
* 恢复 WordPress 上传路径为默认值,� |
| 5 |
�容旧版 upload_information 及新版 backup_url_path |
| 6 |
*/ |
| 7 |
if (!defined('WP_UNINSTALL_PLUGIN')) { |
| 8 |
// 如果 uninstall 不是从 WordPress 调用,则退出 |
| 9 |
exit(); |
| 10 |
} |
| 11 |
|
| 12 |
$wposs_options = get_option('wposs_options'); |
| 13 |
|
| 14 |
if (is_array($wposs_options)) { |
| 15 |
// 恢复为 WordPress 默认本地存储(空字符串表示使用 wp-content/uploads) |
| 16 |
$upload_path = ''; |
| 17 |
$upload_url_path = ''; |
| 18 |
|
| 19 |
// 优� |
| 20 |
�使用 backup_url_path(停用时保存的当前 upload_url_path) |
| 21 |
if (!empty($wposs_options['backup_url_path'])) { |
| 22 |
$upload_url_path = $wposs_options['backup_url_path']; |
| 23 |
} |
| 24 |
// � |
| 25 |
�容旧版本:若存在 upload_information.original 则使用� |
| 26 |
�保存的原始值 |
| 27 |
if (!empty($wposs_options['upload_information']['original']['upload_path'])) { |
| 28 |
$upload_path = $wposs_options['upload_information']['original']['upload_path']; |
| 29 |
} |
| 30 |
if (empty($upload_url_path) && isset($wposs_options['upload_information']['original']['upload_url_path'])) { |
| 31 |
$upload_url_path = $wposs_options['upload_information']['original']['upload_url_path']; |
| 32 |
} |
| 33 |
|
| 34 |
update_option('upload_path', $upload_path); |
| 35 |
update_option('upload_url_path', $upload_url_path); |
| 36 |
} |
| 37 |
|
| 38 |
// 从 options 表删除选项 |
| 39 |
delete_option('wposs_options'); |
| 40 |
|