我的解决方案使用3个组合挂钩wp_insert_post_data
, wp_ajax_sample-permalink
,name_save_pre
//==================DISABLE GEORGIAN + Russian SLUGS for POSTS================
//disable slug on any update
add_filter(\'wp_insert_post_data\', \'myappend_slug\', 3); function myappend_slug($data) {
$data[\'post_name\']= slug_modify($data[\'post_name\']);return $data;
}
add_action( \'wp_ajax_sample-permalink\', \'MyajaxSamplePermalink\',1); function MyajaxSamplePermalink($data) {
// check that we\'re dealing with a product, and editing the slug
$post_id = isset($_POST[\'post_id\']) ? intval($_POST[\'post_id\']) : 0;
$post_name = isset($_POST[\'new_slug\'])? $_POST[\'new_slug\'] : null;
$new_title = isset($_POST[\'new_title\'])? $_POST[\'new_title\'] : null;
$chosen = (isset($post_name) ? $post_name : $new_title );
$_POST[\'new_slug\'] = slug_modify($chosen);
}
add_filter(\'name_save_pre\', \'MyfilterNameSavePre\'); function MyfilterNameSavePre($post_name) {
// check that we\'re dealing with a product, and editing the slug
$post_id = isset($_POST[\'post_ID\']) ? intval($_POST[\'post_ID\']) : 0;
$new_slug = isset($_POST[\'post_name\']) ? $_POST[\'post_name\'] : 0;
if ($post_id) { $post_name = slug_modify($new_slug); }
return $post_name;
}
function slug_modify($slg) {return myFILTERRRRRRR($slg);}