Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Japanese cannot be used for title of register_field_group #778

Closed
Tanabebe opened this issue Dec 28, 2022 · 3 comments
Closed

Japanese cannot be used for title of register_field_group #778

Tanabebe opened this issue Dec 28, 2022 · 3 comments

Comments

@Tanabebe
Copy link

Tanabebe commented Dec 28, 2022

Hi Team

Regarding the event on the subject, This is probably the case with versions 5.11.2 and later.

For example, if you use register_field_group as below.

if(function_exists("register_field_group"))
{
    register_field_group(array (
        'id' => 'acf_annotation',
        'title' => '注釈',
        'fields' => array (
            array (
                'key' => 'field_99999f0d1406',
                'label' => '注釈',
                'name' => 'header_annotation',
                'type' => 'text',
                'default_value' => '',
                'placeholder' => '',
                'prepend' => '',
                'append' => '',
                'formatting' => 'html',
                'maxlength' => '',
            ),
        ),
        'location' => array (
            array (
                array (
                    'param' => 'post_type',
                    'operator' => '==',
                    'value' => 'post',
                    'order_no' => 0,
                    'group_no' => 0,
                ),
            )        ),
        'options' => array (
            'position' => 'normal',
            'layout' => 'no_box',
            'hide_on_screen' => array (
            ),
        ),
        'menu_order' => 1,
    ));
 }

If the string used for id title in acf_slugify (code part below) of acf-helper-functions.php contains Japanese characters, it becomes an empty string.

$slug = preg_replace( '/[^A-Za-z0-9' . preg_quote( $glue ) . ']/', '', $slug );

In versions 5.11.1 and earlier, you could use Japanese in the title, but did you intentionally allow only half-width alphanumeric characters?

@Tanabebe Tanabebe changed the title Japanese cannot be used for id of register_field_group Japanese cannot be used for title of register_field_group Dec 28, 2022
@lgladdy
Copy link
Member

lgladdy commented Dec 28, 2022

Hey @Tanabebe,

Thanks for the report. We'll look into this! It looks like if you provide a custom key for the field group in register_field_group you'll skip the acf_slugify call which is tripping us up here.

We did change the slugify function, as it is only supposed to support half-width alphanumeric characters - but we'll need to shore up the code in register_field_group to handle that and generate the ID a different way if acf_slugify returns empty.

@Tanabebe
Copy link
Author

Tanabebe commented Jan 4, 2023

Hi @lgladdy

Thank you for your quick response.

If the string used for id in acf_slugify (code part below) of acf-helper-functions.php contains Japanese characters, it becomes an empty string.

This was a mistake in the title, not the id, so I will correct it.

@polevaultweb
Copy link
Contributor

Hey @Tanabebe we've fixed this in ACF 6.0.7 just released 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants