Linux 软件免费装
Banner图

No Slug Conflicts with Trash

开发者 coffee2code
更新时间 2016年6月27日 01:01
捐献地址: 去捐款
PHP版本: 3.5 及以上
WordPress版本: 4.4
版权: GPLv2 or later
版权网址: 版权信息

标签

post coffee2code slug trash post_name

下载

1.0 1.0.1 1.0.2 1.0.3 1.0.4 1.1 1.2

详情介绍:

NOTE: WordPress 4.5 incorporated the functionality of this plugin and thus it is no longer needed unless you're still running an older version of WP. This plugin implements the belief that a trashed page or post should not in any way conflict with a new page or post when it comes to slugs. In essence, a new page or post should take precedence over anything in the trash. After all, the page/post is in the trash for a reason. By default, WordPress takes into consideration posts and pages that have been trashed when deciding if the slug for a new post is already in use. Obviously, in general, WordPress should not allow duplicate slugs because that could interfere with permalinks. The thinking behind WordPress's handling of the situation is that trashed posts/pages are still technically present, just inaccessible. It is possible that an author or admin would choose to restore a post from the trash, which WordPress feels should then occupy that same permalink as before it was trashed. If what WordPress does is unclear, here's an example to help clarify things: With this plugin, for this example, the new "About" page would get the slug "about" as one would hope. That said, the plugin tries its best to restore untrashed posts to their original slug. The only time it fails to do so is if a new page or post has claimed the trashed post's original slug, in which case the untrashed post is assigned a new slug. See other sections of the documentation for more insight into the plugin's functionality. See WP core ticket #11863 for discussion on the matter. Links: Plugin Homepage | Plugin Directory Page | Author Homepage

安装:

  1. Unzip 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)
  2. Activate the plugin through the 'Plugins' admin menu in WordPress

升级注意事项:

1.2 Recommended update: WordPress 4.5 incorporated the functionality of this plugin and thus it is no longer needed for WP 4.5+. It will perform necessary data migrations to ensure trashed slug restoration continues to work and then deactivate itself. 1.1 Minor update: added check for slugs that could result in URLs that conflict with date archives; enhanced unit tests 1.0.4 Trivial update: added explanation of plugin's methodology; documented unit tests; noted compatibility through WP 4.4+; updated copyright date (2016) 1.0.3 Trivial update: noted compatibility through WP 4.1+ and updated copyright date (2015) 1.0.2 Trivial update: noted compatibility through WP 4.0+; added plugin icon. 1.0.1 Trivial update: added version() function to return plugin's version number; noted compatibility through WP 3.8+ 1.0 Initial public release.

常见问题:

What happens if I trash a post and then restore it?

The post retains its original slug, as was always the case.

What happens if I trash a post, publish a new post with that same slug, then restore the original post?

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.

What happens if I trash a post, publish a new post with that same slug, then trash the second post and restore the original post?

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.

What slug gets assigned to a trashed post when a newer post wants to have the same slug?

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".

Why doesn't WordPress do what this plugin does by default?

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.

As a user of this plugin, what happens now that WordPress 4.5 and beyond now natively supports this functionality?

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.

Does this plugin include unit tests?

Yes.

更新日志:

1.2 (2016-05-07) Highlights: WordPress 4.5 has effectively implemented the functionality provided by this plugin, thus it is no longer needed. 1.1 (2015-12-08) Highlights: 详细信息 : 1.0.4 (2015-12-07) Highlights: Details: 1.0.3 (2015-02-11) 1.0.2 (2014-08-25) 1.0.1 1.0