admin管理员组

文章数量:1130349

Does anyone know if there is a way to change the callback function for a tag-like custom taxonomy so that it breaks terms after a semicolon instead of a comma? I realize I can rewrite the whole meta box, but I'd rather not if there's an easier way.

Does anyone know if there is a way to change the callback function for a tag-like custom taxonomy so that it breaks terms after a semicolon instead of a comma? I realize I can rewrite the whole meta box, but I'd rather not if there's an easier way.

Share Improve this question edited Apr 13, 2017 at 12:37 CommunityBot 1 asked Mar 15, 2013 at 20:07 gboonegboone 132 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 3

The tag delimiter is made translatable:

$comma = _x( ',', 'tag delimiter' );

So this can be changed with a simple filter:

add_filter( 'gettext_with_context', 't5_semicolon_tag_delimiter', 10, 4 );

function t5_semicolon_tag_delimiter( $translated, $text, $context, $domain )
{
    if ( 'default' !== $domain or 'tag delimiter' !== $context or ',' !== $text )
        return $translated;

    return ';';
}

Install as plugin; works without any side effects.

What is tricky: changing the string Separate tags with commas to say semicolon. You cannot use the same solution, because you don’t know the language of your users. Not sure how to handle that.

Does anyone know if there is a way to change the callback function for a tag-like custom taxonomy so that it breaks terms after a semicolon instead of a comma? I realize I can rewrite the whole meta box, but I'd rather not if there's an easier way.

Does anyone know if there is a way to change the callback function for a tag-like custom taxonomy so that it breaks terms after a semicolon instead of a comma? I realize I can rewrite the whole meta box, but I'd rather not if there's an easier way.

Share Improve this question edited Apr 13, 2017 at 12:37 CommunityBot 1 asked Mar 15, 2013 at 20:07 gboonegboone 132 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 3

The tag delimiter is made translatable:

$comma = _x( ',', 'tag delimiter' );

So this can be changed with a simple filter:

add_filter( 'gettext_with_context', 't5_semicolon_tag_delimiter', 10, 4 );

function t5_semicolon_tag_delimiter( $translated, $text, $context, $domain )
{
    if ( 'default' !== $domain or 'tag delimiter' !== $context or ',' !== $text )
        return $translated;

    return ';';
}

Install as plugin; works without any side effects.

What is tricky: changing the string Separate tags with commas to say semicolon. You cannot use the same solution, because you don’t know the language of your users. Not sure how to handle that.

本文标签: custom taxonomySeparate tags with semicolon