Веб-разработка
- 4 ответа
- 0 вопросов
2
Вклад в тег
add_filter( 'pre_post_tags_input', 'no_tags_input_create' );
add_filter( 'pre_post_tax_input', 'no_tax_input_create' );
function no_tags_input_create($tags_input) {
$output = array();
foreach( $tags_input as $tag )
if( term_exists( $tag, 'post_tag') )
$output[] = $tag;
return $output;
}
function no_tax_input_create($tax_input) {
if( !isset($tax_input['post_tag']) )
return $tax_input;
$output = array();
$tags = explode(',', $tax_input['post_tag']);
foreach( $tags as $tag )
if( term_exists( $tag, 'post_tag') )
$output[] = $tag;
$tax_input['post_tag'] = implode(',',$output);
return $tax_input;
}