senlin/pinyin-slugs

Fix the ignore english character function?

vanabel opened this issue · 5 comments

I do believe that the plugin ignore the character of english is not a good option, which I try to fix it as

# in `so-pinyin-slugs/inc/functions.php`
...
}else {
            //non chinese characters will be ignored
            $strRet .= preg_replace( "/[^A-Za-z0-9\-]/", "$0", chr( $byte1st ) );
        }
...

Where I modify the second parameter of preg_replace from '' to $0, which means we do not change the character if it is alphabetic. I don't know whether this will cause other issue, But it seems work for me!!

Hi @vanabel
Thanks for your input.
What you describe is a known issue, documented in the plugin's FAQ.

I have just tested your solution and that indeed seems to work!

Before I commit this, can I ask you how well have you tested it?

Thanks,
Piet

I just test it for my newest article, which seems work for me. Since it seems an easy solution, I suspect there are some unexpected issue.

All right.

Will you be using the plugin actively for what you're currently doing?
The reason I ask is because it can be an idea to have a test period of a week or two to see if there are any negative side effects.

For example what does it do to existing slugs? We wouldn't want to start messing up people's permalinks, right ;)

If we can establish no side effects during such a testing period, then I am all for switching out the code with your discovery!

Also it would be nice to know how did you get to replace '' with $0?

Committed and released, thank you very much @vanabel