一个极其简单的wordpress插件, 让url清清爽爽, 拒绝难看的url.
<?php>
/*
* Plugin Name: no ugly url
* Plugin URI: http://lshuzhi.com/no-ugly-url/
* Description: not use ugly permalinks such as http://lshuzhi.com/%e6%a0%87%e9%a2%98/
* Description(Chinese): 避免难看的url,例如http://lshuzhi.com/%e6%a0%87%e9%a2%98/
* Version: 1.0.0
* Author: shuzhi
* Author URI: http://www.lshuzhi.com/no-ugly-url/
* License: GPL
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
add_filter( ‘wp_unique_post_slug’, ‘wp_plugin_no_ugly_url’, 0, 2);
function wp_plugin_no_ugly_url($slug, $post_ID) //, $post_status, $post_type, $post_parent, $original_slug )
{
if ( strpos($slug, ‘%’) !== false ) {
$slug = $post_ID;
}
return $slug;
}
<?>