wordpress过滤器

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/liu709127859/article/details/81488540

过滤器笔记

1 //文章保存之前,给文章中的“黄聪”自动加上链接
add_filter( 'content_save_pre','hc_auto_link' );
function hc_auto_link( $content ){ 
    return str_replace( "黄聪", "<a href='http://hcsem.com'>黄聪</a>", $content);

2  上传图片中文,图片无法识别

add_filter('wp_handle_upload_prefilter', 'huilang_wp_handle_upload_prefilter');
function huilang_wp_handle_upload_prefilter($file){
    $time=date("Y-m-d-");
    $file['name'] = $time."".mt_rand(1,100).".".pathinfo($file['name'] , PATHINFO_EXTENSION);
    return $file;
}

猜你喜欢

转载自blog.csdn.net/liu709127859/article/details/81488540