Hacklog Remote Attachment与Custom Upload Dir配合使用的方法 » 荒野无灯weblog

Keep It Simple, Stupid.

荒野无灯weblog

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

1.修改Custom Upload Dir插件

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

    //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插件

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

self::init();

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函数,在

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

一行上面添加如下代码:

        if( function_exists('cud_generate_dir') )
        {
            $custom_upload_dir = cud_generate_dir();
            self::$subdir = $custom_upload_dir;
        }
        else 

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

Tagged in :

All Comments (0)
Gravatar image
No Comments