WordPress.org

Plugin Directory

Changeset 1783011


Ignore:
Timestamp:
12/08/17 01:36:23 (6 weeks ago)
Author:
playes
Message:

3.2

  • 继续优化兼容逻辑
  • 上传附带默认函数
Location:
oss-upload/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • oss-upload/trunk/oss-upload.php

    r1782681 r1783011  
    22/* 
    33 * Plugin Name: OSS Upload 
    4  * Version: 3.1 
     4 * Version: 3.2 
    55 * Description: Upload with Aliyun OSS, with modified OSS Wrapper and fully native image edit function support. 
    66 * Plugin URI: https://www.xiaomac.com/2016121895.html 
     
    3131    if(in_array($action, array('upload-plugin', 'upload-theme'))) return $param; 
    3232    if(ouop('oss') && ouop('oss_path') && ouop('oss_url')){ 
     33        if(empty($param['default'])) $param['default'] = $param; 
    3334        $param['basedir'] = trim(ouop('oss_path'), '/'); 
    3435        $param['path'] = $param['basedir'] . $param['subdir']; 
     
    4950    register_setting('oss_upload_admin_options_group', 'ouop'); 
    5051    add_action('wp_ajax_image-editor', 'oss_upload_dir_loader', 1); 
     52    add_action('wp_ajax_query-attachments', 'oss_upload_dir_loader', 1); 
    5153} 
    5254 
     
    151153function oss_upload_attachment_url($url, $id){ 
    152154    if(ouop('oss') && ouop('oss_url') && ouop('oss_path')){ 
    153         $upload = wp_get_upload_dir(); 
    154         $upload_new = oss_upload_dir($upload); 
    155         $oss = oss_upload_get_attachment_oss($id, $upload); 
    156         if(empty($oss)){ 
    157             $url = str_replace($upload_new['baseurl'], $upload['baseurl'], $url); 
     155        $upload = oss_upload_dir(wp_get_upload_dir()); 
     156        $oss = oss_upload_get_attachment_oss($id, $upload['default']); 
     157        if($oss === '0'){ 
     158            $url = str_replace($upload['baseurl'], $upload['default']['baseurl'], $url); 
    158159        }else{ 
    159             $url = str_replace($upload['baseurl'], $upload_new['baseurl'], $url); 
     160            $url = str_replace($upload['default']['baseurl'], $upload['baseurl'], $url); 
    160161        } 
    161162    } 
     
    167168function oss_upload_attached_file($file, $id){ 
    168169    if(ouop('oss') && ouop('oss_path')){ 
    169         $upload = wp_get_upload_dir(); 
    170         $upload_new = oss_upload_dir($upload); 
    171         $oss = oss_upload_get_attachment_oss($id, $upload); 
    172         if(empty($oss)){ 
    173             $file = str_replace($upload_new['basedir'], $upload['basedir'], $file); 
     170        $upload = oss_upload_dir(wp_get_upload_dir()); 
     171        $oss = oss_upload_get_attachment_oss($id, $upload['default']); 
     172        if($oss === '0'){ 
     173            $file = str_replace($upload['basedir'], $upload['default']['basedir'], $file); 
    174174        }else{ 
    175             $file = str_replace($upload['basedir'], $upload_new['basedir'], $file); 
     175            $file = str_replace($upload['default']['basedir'], $upload['basedir'], $file); 
    176176        } 
    177177    } 
     
    182182    $oss = get_post_meta($id, 'oss_upload', true); 
    183183    if($oss != '') return $oss; 
    184     if(has_filter('upload_dir', 'oss_upload_dir')) return '1'; 
    185184    $url = get_the_guid($id); 
    186185    if(!$upload) $upload = wp_get_upload_dir(); 
    187     if(false !== strpos($url, $upload['baseurl'])){ 
     186    if(false !== stripos($upload['basedir'], 'wp-content/uploads') && false !== strpos($url, $upload['baseurl'])){ 
    188187        $file = get_attached_file($id, true); 
    189188        if(@file_exists($file)) $local = 1; 
    190189    } 
    191190    update_post_meta($id, 'oss_upload', empty($local) ? '1' : '0'); 
    192     return empty($local); 
     191    return empty($local) ? '1' : '0'; 
    193192} 
    194193 
     
    197196    if(!ouop('oss') || empty($meta['sizes'])) return $sources; 
    198197    if(ouop('oss_thumbnail', 1)) return array(); 
    199     $upload = wp_get_upload_dir(); 
    200     $upload_new = oss_upload_dir($upload); 
    201     $oss = oss_upload_get_attachment_oss($id, $upload); 
     198    $upload = oss_upload_dir(wp_get_upload_dir()); 
     199    $oss = oss_upload_get_attachment_oss($id, $upload['default']); 
    202200    foreach ($sources as $k => $v){ 
    203         if(empty($oss)){ 
    204             $url = str_replace($upload_new['baseurl'], $upload['baseurl'], $sources[$k]['url']); 
     201        if($oss === '0'){ 
     202            $url = str_replace($upload['baseurl'], $upload['default']['baseurl'], $sources[$k]['url']); 
    205203        }else{ 
    206             $url = str_replace($upload['baseurl'], $upload_new['baseurl'], $sources[$k]['url']); 
     204            $url = str_replace($upload['default']['baseurl'], $upload['baseurl'], $sources[$k]['url']); 
    207205        } 
    208206        if(basename($meta['file']) == basename($url) && ouop('oss_default_style')) $url .= ouop('oss_default_style'); 
  • oss-upload/trunk/readme.txt

    r1782681 r1783011  
    55Tags: aliyun, oss, upload, storage 
    66Tested up to: 4.9.1 
    7 Stable tag: 3.1 
     7Stable tag: 3.2 
    88License: GPLv2 or later 
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     
    3939 
    4040== Changelog == 
     41 
     42= 3.2 = 
     43* 继续优化兼容逻辑 
     44* 上传附带默认函数 
    4145 
    4246= 3.1 = 
Note: See TracChangeset for help on using the changeset viewer.