开发者 | coffee2code |
---|---|
更新时间 | 2016年6月27日 01:01 |
捐献地址: | 去捐款 |
PHP版本: | 3.5 及以上 |
WordPress版本: | 4.4 |
版权: | GPLv2 or later |
版权网址: | 版权信息 |
no-slug-conflicts-with-trash.zip
inside the plugins directory for your site (typically /wp-content/plugins/
). Or install via the built-in WordPress plugin installer)The post retains its original slug, as was always the case.
Because the trashed post's original slug is in use by a new post at the time it gets restored from the trash, the original post would use a reassigned slug. Once an untrashed post is given a reassigned slug, it will no longer have the ability to return to its original slug without manual intervention.
Upon restoration, the original post will retain its original slug. The plugin keeps track when a trashed post's slug gets changed. It tries to restore the post's original slug if it isn't in use at the time the post gets untrashed.
When a new post gets created, WordPress tries to determine if a conflict exists. If one does, WordPress appends "-" and then a number to the slug until a unique slug is found. Therefore, if "about" is taken, then it tries "about-2". If that's taken, then it tries "about-3" and so on. Rather than let WP assign the "about-2" to the new post, this plugin flips things and gives the new post "about" and the trashed post "about-2".
It should! There is an ages-old, still open Trac ticket (ticket #11863) concerning how to handle slug conflicts with trashed posts. No consensus to change existing behavior has been reached. Feel free to chime in to the discussion there and advocate the plugin's approach if you agree with how the plugin handles things. UPDATE: The aforementioned Trac ticket has been resolved as of WordPress 4.5. Therefore, this plugin is no longer necessary.
If v1.2 of the plugin is run under WP 4.5 or later, it migrates any previously stored original slugs for trashed posts to the postmeta name recognized by WordPress. Then the plugin deactivates itself since it has no further use. At this point, feel free to delete the plugin from your site. v1.2 of the plugin will continue to work as expected for sites running a version of WP earlier than 4.5.
Yes.
get_trashed_post()
with changes to wp_unique_post_slug()
c2c_No_Slug_Conflicts_With_Trash::version()
to return version number for plugin (with unit test)