Skip to:
Content
Pages
Categories
Search
Top
Bottom

I want to limit the title max length with multibyte


  • pipipi07
    Participant

    @pipipi07

    Thank you for making it 2.6!
    However, there was a problem after the update.

    I use bbpress in Japanese.
    In ver.2.5, a code that sets the topic title to 20 characters in Japanese was added to functions.php and it worked properly.
    This is the code.

    function title_max_length ($ default) {
    $ default = 20;
    return $ default;
    }
    add_filter ('bbp_get_title_max_length', 'title_max_length');

    But after 2.6, it didn’t work.
    For example, if default = 20, only 6 characters will be reflected in the title in Japanese. If it is half-width alphanumeric characters, up to 20 characters are correctly reflected.

    I know this is a multibyte issue, but I don’t know how to deal with it. Can I change the limit on the number of characters in a title even with multibyte?
    I hope to find a good solution.

    I am not good at English. I’m sorry in terrible English. thank you for reading!

Viewing 8 replies - 1 through 8 (of 8 total)

  • Pascal Casier
    Moderator

    @casiepa

    Hi @pipipi07,
    The filter function is still the same from what I see, so let me try to find something else.


    Pascal Casier
    Moderator

    @casiepa

    Hi @pipipi07,
    First of all, there should be NO space between the dollar sign and the word ‘default’, so please make sure to change that 3 times (so $default, not $ default)

    If you put
    $default = 20;
    then how many Japanese characters were you able to put in v2.5?


    pipipi07
    Participant

    @pipipi07

    Thank you for thinking together, @casiepa!
    I’m sorry for the space after the dollar. I missed it.
    But I fixed it but it didn’t work.

    For Ver2.5, if $default = 20, you should have been able to send up to 20 characters in Japanese.


    Pascal Casier
    Moderator

    @casiepa

    If you change 20 to 21, are you able to put 7 Japanese characters?
    Just thinking of the multibyte characters, Japanese characters might be using 3 characters.

    If it works, then for now you could change from 20 to 60, but that would mean that somebody can put 60 English characters of course…

    To be honest it seems strange that this happens because of the switch of bbPress as the functions in 2.5 and 2.6 look the same. Are you sure it’s not because of a switch of WordPress to a higher version or another change?

    I have no other ideas unfortunately…


    pipipi07
    Participant

    @pipipi07

    If default=21, I was able to input 7 characters in Japanese!
    Apparently, 18-20 can be up to 6 characters, 21-23 can be up to 7 characters, 24 can be up to 8 characters in Japanese. This was a new discovery!

    When bbPress was changed to 2.6, wordpress was upgraded to 5.3 as well. As you say, it may have an impact. I will try a little more to find out what’s wrong.
    For the time being, I decided to set 60 instead of 20.

    Thank you for your cooperation!


    Pascal Casier
    Moderator

    @casiepa

    One last question @pipipi07: What was the previous version of WordPress you had?
    thx.


    John James Jacoby
    Keymaster

    @johnjamesjacoby

    bbPress 2.5.10 did fix a bug that was causing maximum title lengths to not be enforced, and this was part of 2.6 as well. It does use '8bit' encoding, but perhaps 'UTF-8' would be better. I think @casiepa is doing some digging to figure this out exactly.


    pipipi07
    Participant

    @pipipi07

    To @casiepa
    Before 5.3, we used 5.2.4 WordPress.
    bbpress is 2.5.14 is the last version.

Viewing 8 replies - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.
Skip to toolbar