What does the Wenprise Pinyin Slug plugin do?
When you add content to WordPress, the following items will be automatically converted to Pinyin or English translations, thus solving the problems of messy URLs, page 404, etc. caused by Chinese URLs.
- Chinese aliases on article pages, Chinese characters in article and page URLs
- Chinese characters in URLs of category items, tag aliases, category items, and tags
- Chinese characters in file names of attachments
When the content above is in English, it stays as is.
Main functions of the plug-in
- Convert article aliases to pinyin or English translations, support conversion during quick editing
- Convert taxonomies, tags, or custom taxonomy aliases to pinyin or English translations, with support for quick editing.
- When the alias is in English, or the Chinese alias is set manually, it stays as is.
- Automatically rename Chinese attachments to Pinyin or English when uploading Chinese attachments, avoiding the problem of garbled Chinese filenames due to the inaccessibility of file name encoding in the operating system.
- Support for customizing the conversion method to full spelling or first letter
- Support to set the interval character between pinyin
- Support intercepting the converted Pinyin or English translation to the set length.
- Support for the Gutenberg editor
Why do you need this plugin?
When Chinese is present in a URL, it is automatically transcoded, making it look like a mess of code to the uninitiated and unreadable. Although some browsers can display Chinese in the address bar, copying a Chinese URL and sharing it with others will also display a messy coded URL.
Different operating system environments, FTP transfer tools use different file name encoding, when migrating servers, if the file name encoding is changed, the Chinese file name is likely to become garbled, resulting in the file can not be accessed.
What are the circumstances to use this plugin?
This plugin is recommended if your site is for clients, as they will most likely not realize the problem of using Chinese in URLs and filenames. This plugin will automatically take care of it for them.
If the site is for your own use and you're a careful person who manually edits aliases and post names when posting content, this plugin is redundant for you. It doesn't need to be installed.
Installation
Plugin Installation in the WordPress Backend
Search for "Wenprise Pinyin Slug" on the plugin installation page, install and activate it in the search results and you are ready to use it. What is installed in this way is a normal plugin that can be disabled and uninstalled at any time.
Installation via Composer
If you use the Composer Managing your projects can be used directly in themes composer require wenprise/pinyin-slug
command. When installed this way, the plugin is automatically loaded into the theme via Composer, does not appear on the plugin list page, and cannot be disabled or uninstalled in the WordPress backend.
(express) thanks
The pinyin conversion function of the plugin uses the overtrue/pinyin project, thank you very much.
If you find bugs or have functional suggestions while using it, feel free to suggest them in the comments below.
86 thoughts on “Wenprise Pinyin Slug 插件——自动转换 WordPress URL 中的中文文章别名、分类项目别名、图片文件名称为汉语拼音或英文翻译”
Nice, replaced the two plugins I was using before with one.
Haha, have fun with it!
Nice stuff, national stuff or national understanding, quite a bit better than that so pinyin for foreigners! Thanks for the knife.
Have fun with it and feel free to give feedback if you have questions.
It's not working.
The plugin only works on posts without aliases (newly published or manually deleted existing aliases), posts with existing aliases remain as they are.
Yes, there is. Is there a way to batch convert articles and categories with "existing aliases". It only works for new ones.
Initialization patterns are not valid
Provide the PHP and WordPress version numbers.
php7.2.
wordpress5.0.4
Ok, I'll test it and if I can reproduce the problem, I'll release a new version after fixing it, just update it in the background.
How do I disable the filename conversion on upload, it conflicts with another plugin I have?
Can't disable it at the moment, it will be added in the next version.
Good plugin, image uploads are also able to convert slugs automatically.
However, I'm running into a situation with the plugin where the contributor role logging into the backend also sees the settings page of the Wenprise Pinyin Slug plugin?
Fixed, just update it in the backend.
Thanks a lot!
After installing it comes up with "The plugin does not have a valid title."
Resolved, plugin deleted and reinstalled.
The following error occurs after the installation is enabled:
"Your site has encountered a fatal error, please check your site's administrative e-mail for guidance.
Learn more about debugging in WordPress."
WordPress: version 5.3.2
PHP: PHP 7.2 (ea-php72)
WP_DISABLE_FATAL_ERROR_HANDLER is set to false, look for specific errors.
Still the same error. Try WP_DEBUG set to true, which displays the following additional message:
Fatal error: require_once(): Failed opening required '/wp-content/plugins/wpforms-lite/includes/providers/class-constant- contact. contact..php' in /wp-content/plugins/wpforms-lite/includes/class-providers.php on line 55
Your site has encountered a fatal error, please check your site's administrative e-mail address for guidance.
I don't think it has anything to do with wp_forms does it?
After looking at it, it might really be a bug in wp-forms, here is the relevant code in the wp-forms plugin that reports the error.
sanitize_file_name
The output of the function already carries a dot at the end of the result.require_once
That line, the last ".php" with another point, which led to the error report in the "class-constant-contact..php", remove the extra point, both plug-ins can be opened normally.It appears that this file is not loaded until the Wenprise pinyin slug is enabled, which can be done by enabling wp forms alone. As to why enabling the Wenprise pinyin slug plugin causes wp forms to load this file. Need to investigate further.
Yes, it's true that removing the extra dot, both plugins can be enabled normally. However, when no changes are made to wp forms and only the Wenprise pinyin slug is disabled, wp forms outputs "class-constant-contact.php" normally without this extra dot. Only when Wenprise pinyin slug is enabled, the extra dot will appear. In addition, if you change wp forms to remove the dot and then disable Wenprise pinyin slug, it will also cause wp forms to report an error, and the file "class-constant-contactphp" will not be found.
In that case, it may indeed be a problem with my plugin with modifications
sanitize_file_name
function's output, I'll test it later.Released a new version that fixes the issue, just update it in the background. Thank you for your feedback 🙏
Thank you for your selflessness and support 🙏
Is it possible to set up a batch conversion of previous posts and then tags as well?
Previously, batch conversion of articles would result in the original links not being accessible, leading to loss of weight. So this feature will not be added.
The new version of the translation doesn't work anymore
Version 1.4.13
PHP 7.3
WordPress 5.4
Using Baidu Translate, which has always worked. Now the translation is directly the first few (full spelling) or initial letters of pinyin, which used to be able to translate into English, but now it can't.
You can try re-saving the plugin settings, if it doesn't work, I'll test it and fix it in the next version.
1、Disable/Enable plug-in
2. Initial/full spelling and save changes respectively
Separate tests are not translations but titles into initials or pinyin for the first few words of the title.
I've confirmed it over and over again, so I'm begging the gods to update it as soon as possible
Add QQ, send you a new version to try.
Ditto for the new version. The translation really doesn't work. Please send me an e-mail. Thank you!
The latest version is 1.5.0, you can update it directly from the background, if the translation still can't be used after updating, add my QQ during office hours to help you check it out.
Make sure it's version 1.5.0. Select Baidu Translate to generate pinyin initials (why have this option that has no recognizable meaning).
Some sites care more about URL length and not so much about the meaning of the URL.
Already gave feedback on QQ, describing the problem again:
After repeated testing Baidu Translate is effective, but with the alias set to the length of characters related to
① For example, the title has 100 characters (that is, for example), set the alias length of 20 characters, then it will not be translated but directly display the first letter of the title, that is, we believe that the translation did not take effect;
② For example, the title is 19 characters (that is, for example), set is 20 characters alias length, then at this time Baidu Translate will be automatically translated into the cause of the text, that is, we believe that the translation is in effect.
Regardless of the formality of whether the translation was successful or not, in both modes, I confirmed that the translation was recorded in the background of Baidu Translate.
———–
But forward 2 versions, my default setting is 15 characters, no matter how long the title, will call the Baidu translation, may not be fully translated but the title specification, which is me or most of the "white people" want the function.
Ask the gods to solve this need.
A new version has been released, please update to test it.
In translation mode, the alias length should not be set too short, as this may lead to alias duplication by rounding off the last word after the alias degree limit is reached.
Upgrading to version 1.5.1 solves the problem perfectly.
Thanks to the gods for their selflessness and godly handling of the problem.
Thanks for the feedback as well.
Great plugin, wish I could add a feature:
Add a timestamp or a random code to the file name individually, to avoid the file link being guessed by others (needed by paid resource sites), and to reduce excessive resource consumption due to files with the same name (if a user uploads 100 images with the same name in "Chinese", WP will retrieve all the attachments with the same name, and then add the number tail), which is a resource-consuming process. This process is very resource-consuming, but of course, this example is quite extreme.)
Or consider adding hooks for the corresponding translation functions so that those who need them can customize the
Adding hooks to the translation function should be a better solution, consider adding it in the next release.
Thank you very much!
A new version has been released, refer to the code below.
$slug is the converted alias, $name is the pre-conversion, $type is the conversion type, and possible values are: post, term, file
Okay, thanks again.
Thanks for the advice too! Very valuable.
After testing just now, I found that your hook only works if the filename contains Chinese, and it doesn't work for filenames that don't have Chinese. So it is still recommended to add a new hook for the end of the filename translation to ensure that non-Chinese filenames can also add timestamps and so on, thank you!
If you need to add timestamps after all filenames, you can just use thesanitize_file_nameHook.
(✿◡‿◡)Suddenly I realized I'm so stupid, O(∩_∩)O haha~ It's ok, thanks!
😎
Plugin can not recognize the number, how to make him enter the title automatically converted, otherwise I am afraid to submit the URL is not correct.
Thanks for the feedback, I'll find some time to test it.
This does not automatically translate the post alias in the new category of the Custom Post Type UI plugin!
Conveniently, you can add QQ, give a test account password, help you debug a look.
How do I change my role permissions?
Right now it's only valid for administrators, if it's contributor or author access, the tag names they add are still in Chinese.
The main administrator is valid and would like to add to be available to other roles as well.
Setting post tags is done when publishing a post. The roles below the editor do not have the permission to publish posts, so they cannot realize the function of this plugin. This is the default permission setting of WordPress, this plugin will not change this setting, and it is not recommended to change it by other methods, as there may be security issues after modification.
Boss, it's working well, thanks for the tool, but I found that when I convert ǚ to yu, such as couple, after converting "qing-lyu", it should be "qing-lv", right? I hope you can correct it, thanks for your hard work.
This issue does not affect the functionality of the plugin and will not be revised, if a correction is definitely needed, you can use the
wenprise_converted_slug
Filter to replace it to achieve the effect you need.Thank you for your prompt reply, I don't know if it affects Baidu's inclusion, because the url is translated into pinyin, such as qing-lyu in Baidu is not corresponding to the "couple", and if it is "qing-lv" Baidu will know that right away! If it can be corrected whether it is more perfect, thank you boss point to use the replacement tool, I try, thank you!
By the way, boss wenprise_converted_slug Filter where to download this plugin, Baidu can not find? I can't find it on Baidu.
遇到一个问题,文章标题中带有字符例如“·”,URL中会被翻译成“-%c2%b7-”,能否去掉标题中的字符?
This plugin is very well written, and I'm here to give you advice that
Ichabod said:
2018/08/20 08:10
The plugin only works on posts without aliases (newly published or manually deleted existing aliases), posts with existing aliases remain as they are.
I hope to change it, when fast editing, manually change the alias to Chinese, save it, and then convert it to English, it is better to support batch editing and saving, the
The plugin WP Slug Baidu Translate does just that.
Now Baidu Translate doesn't work?
I don't use this feature and haven't received feedback that it doesn't work, I'll test it sometime.
Boss, why turn to pinyin such as the correct address is: http://www.touxiangpai.com/gui-mie-zhi-ren.html, but Baidu included in the home page shows www.touxiangpai.com/?p=10 ..., click Baidu snapshot into the discovery: Baidu and webpage http://www.touxiangpai.com/%3Fp%3D10280 The author of this has nothing to do with it. The address has changed again, I wonder if it has anything to do with your plugin? Thanks!
By the way, Boss, I found that both the converted pinyin address and the pre-conversion address can be accessed effectively, which results in both being indexed by Baidu. Can we just keep the converted pinyin address to avoid the one before conversion to be included, thanks!
This is not an issue that this plugin is meant to address, and you may need to find out if there is a related SEO plugin.
In Gutenberg editor mode, aliases are not displayed when you create a new article, they are only generated automatically when you write a title and save a draft or publish.
Can it be optimized to automatically generate aliases when you write the title and enter or click on the body, so that it is easy to edit the aliases twice.
Considered this approach, ran into difficulties implementing it, will keep trying when I have time.
This plugin is awesome!
In the case of conversion to English, labels are not converted always with initials instead.
Now Baidu Translate to English doesn't work? Can you update it?
Can you add a md5 random slug method?
Thanks for the suggestion, consider adding it in the next version.
When's the update coming, big guy?
Hi, is the plugin still being updated, the existing tags, when clicking on Edit and Quick Edit, do not translate, only the re-added tags do!
This is a normal feature of the plugin, for SEO security, the plugin will not convert published articles or category slugs, it will only convert the slug of the newly published content. if you need to convert the slug of the published content, you can try to delete the slug of the existing content and then save it, and it should trigger the auto-conversion operation.
Tags are structured by id, aliases and ids can be turned on, tens of thousands of articles, tens of thousands of tags, deleted in the addition is not realistic, or thousands of articles have to be changed, in fact, you can add a switch, whether or not to turn on the already existing tag conversion. There are some words will not be turned? For example, the perfect world.
Thanks for the suggestion, will consider adding this feature in subsequent releases.
Hello, I found that the new version 1.55 can't convert the Chinese name of the uploaded image instead.
Upgrading to 1.5.6 will fix it.
I want to use Baidu Translate, filled in the appid and key key effect, still default pinyin
Let's use pinyin for now, I'll test it when I have time.
Please fix it hahaha. Thanks ☺️
Manually add the category and the alias is set to English, the article is a number id.html or the alias is already set. Wouldn't the plugin automatically translate if these actions exist above?
If the alias already exists, it will not be translated automatically anymore.
目前不开放注册.