Hacklog Remote Attachment与Custom Upload Dir配合使用的方法

1.修改Custom Upload Dir插件

修改function cud_init()
注释掉两行,添加一行:

1
2
3
    //add_filter('wp_handle_upload_prefilter', 'cud_pre_upload');
    //add_filter('wp_handle_upload', 'cud_post_upload');
    add_filter('upload_dir', 'cud_custom_upload_dir');

2.再修改 Hacklog Remote Attachment插件

修改类构造函数中的第一行:

1
self::init();

1
add_action('plugins_loaded',create_function('','call_user_func_array( array("hacklogra","init"),array() );'),999);

ps:其它几个基于此的插件,如Hacklog Remote Attachment Sync , Hacklog Remote Attachment Upyun ,Hacklog Remote Attachment Upyun Sync 修改上面时注意把hacklogra替换为相应的类名。

再修改init函数,在

1
if (get_option('uploads_use_yearmonth_folders') && isset($_REQUEST['post_id']))

一行上面添加如下代码:

1
2
3
4
5
6
        if( function_exists('cud_generate_dir') )
        {
            $custom_upload_dir = cud_generate_dir();
            self::$subdir = $custom_upload_dir;
        }
        else

未做详细测试,有此需求的朋友可自行测试。

更多
2 Responses Post a comment
  1. chinawuhan

    配合起来相当好用,谢谢你!

    有个bug,就是删除时,FTP里的原始文件不会同时被删除,但缩略图可以同步正常被删除。

    不过影响不大

Leave a Reply

Note: You may use basic HTML in your comments. Your email address will not be published.

Subscribe to this comment feed via RSS