This plugin adds “← Previous” and “Next →” links to the “Edit Post” admin page if a previous and next post are present, respectively.
如果存在上一个帖子和下一个帖子,则此插件将“←上一个”和“下一个→”链接添加到“编辑帖子”管理页面。
The link titles (visible when hovering over the links) reveal the title of the previousext post.
链接标题(将鼠标悬停在链接上时可见)显示上一个/下一个帖子的标题。
The links link to the “Edit Post” admin page for the previousext posts so that you may edit them.
链接链接到上一个/下一个帖子的“编辑帖子”管理页面,以便您可以对其进行编辑。 p>
By default, a previousext post is determined by the next lower/higher valid post based on the date the post was created and which is also a post the user can edit.
默认情况下,上一个/下一个帖子由下一个较低/较高的有效帖子确定,具体取决于该帖子的创建日期,并且也是用户可以编辑的帖子。
Other post criteria such as post type (draft, pending, etc), publish date, post author, category, etc, are not taken into consideration when determining the previous or next post.
确定上一个或下一个帖子时,不会考虑其他帖子条件,例如帖子类型(草稿,待审等),发布日期,帖子作者,类别等。 p>
Users can customize how post navigation ordering is handled via the “Screen Options” panel available at the top of every page when editing a post.
在编辑帖子时,用户可以通过每个页面顶部的“屏幕选项”面板自定义如何处理帖子导航顺序。
A dropdown presents options to order navigation by: ‘ID’, ‘menu_order’, ‘post_date’, ‘post_modified’, ‘post_name’, and ‘post_title’.
下拉菜单显示了用于按以下顺序进行导航的选项:“ ID”,“ menu_order”,“ post_date”,“ post_modified”,“ post_name”和“ post_title”。
Post navigation can further be customized via filters (see Filters section).
可以通过过滤器进一步自定义帖子导航(请参阅过滤器部分)。 p>
NOTE: Be sure to save the post currently being edited (if you’ve made any changes) before navigating away to the previousext post!
注意:在导航到上一个/下一个帖子之前,请确保保存当前正在编辑的帖子(如果进行了任何更改)! p>
Links: Plugin Homepage |
链接:插件主页 |
Plugin Directory Page |
插件目录页面 |
GitHub |
GitHub |
Author Homepage
作者主页 p>
Filters
过滤器 h3>
The plugin is further customizable via six filters.
可通过六个过滤器进一步自定义插件。
Such code should ideally be put into a mu-plugin or site-specific plugin (which is beyond the scope of this readme to explain).
理想情况下,应将此类代码放入mu插件或特定于站点的插件中(这不在本自述文件的解释范围内)。 p>
c2c_admin_post_navigation_orderby (filter)
c2c_admin_post_navigation_orderby(过滤器) h4>
The ‘c2c_admin_post_navigation_orderby’ filter allows you to change the post field used in the ORDER BY clause for the SQL to find the previousext post.
通过“ c2c_admin_post_navigation_orderby”过滤器,您可以更改SQL的ORDER BY子句中使用的发布字段,以查找上一个/下一个发布。
By default this is ‘post_date’ for non-hierarchical post types (such as posts) and ‘post_title’ for hierarchical post types (such as pages).
默认情况下,对于非分层帖子类型(例如帖子),这是“ post_date”;对于分层帖子类型(例如页面),这是“ post_title”。
If you wish to change this, hook this filter.
如果您想更改此设置,请钩住此过滤器。
Note: users can customize the post navigation order field for themselves on a per-post type basis via “Screen Options” (see FAQ and screenshot for more info).
注意:用户可以通过“屏幕选项”为每个帖子类型自定义帖子导航顺序字段(有关更多信息,请参阅FAQ和屏幕截图)。 p>
Arguments:
参数: p>
- $field (string) The current ORDER BY field
- $ field(字符串)当前的ORDER BY字段 li>
- $post_type (string) The post type being navigated
- $ post_type(字符串)正在导航的帖子类型 li>
- $user_id (int) The user’s ID
- $ user_id(int)用户的ID li>
ul>
Example:
示例: p>
/** / ** * Modify how Admin Post Navigation orders posts for navigation by changing the
*通过更改以下内容来修改“管理员发布导航”命令发布导航的方式
* ordering of pages by 'menu_order'.
*通过“ menu_order”对页面进行排序。
*
*
* @param string $field The field used to order posts for navigation.
* @param string $ field用于订购帖子以进行导航的字段。
* @param string $post_type The post type being navigated.
* @param string $ post_type正在导航的帖子类型。
* @param int $user_id.
* @param int $ user_id。
The user's ID.
用户的ID。
* @return string
* @返回字符串
*/
* /
function custom_order_apn( $field, $post_type, $user_id ) {
函数custom_order_apn($ field,$ post_type,$ user_id){
// Only change the order for the 'page' post type.
//仅更改“页面”帖子类型的顺序。
if ( 'page' === $post_type ) {
if('page'=== $ post_type){
$field = 'menu_order';
$ field ='menu_order';
}
}
return $field;
返回$ field;
}
}
add_filter( 'c2c_admin_post_navigation_orderby', 'custom_order_apn', 10, 3 );
add_filter('c2c_admin_post_navigation_orderby','custom_order_apn',10,3);
code> pre>
c2c_admin_post_navigation_post_statuses (filter)
c2c_admin_post_navigation_post_statuses(过滤器) h4>
The ‘c2c_admin_post_navigation_post_statuses’ filter allows you to modify the list of post_statuses used as part of the search for the prevext post.
通过“ c2c_admin_post_navigation_post_statuses”过滤器,您可以修改用作搜索上一个/下一个帖子的一部分的post_statuses列表。
By default this array includes ‘draft’, ‘future’, ‘pending’, ‘private’, and ‘publish’.
默认情况下,此数组包括“草稿”,“未来”,“待处理”,“私有”和“发布”。
If you wish to change this, hook this filter.
如果您想更改此设置,请钩住此过滤器。
This is not typical usage for most users.
对于大多数用户而言,这不是典型用法。 p>
Arguments:
参数: p>
- $post_statuses (array) The array of valid post_statuses
- $ post_statuses(数组)有效的post_statuses数组 li>
- $post_type (string) The post type
- $ post_type(字符串)帖子类型 li>
ul>
Example:
示例: p>
/** / ** * Modify Admin Post Navigation to allow and disallow certain post statuses from being navigated.
*修改“管理员帖子导航”以允许和禁止某些帖子状态被导航。
*
*
* @param array $post_statuses Post statuses permitted for admin navigation.
* @param array $ post_statuses允许管理员导航的帖子状态。
* @param string $post_type The post type.
* @param string $ post_type帖子类型。
* @return array
* @返回数组
*/
* /
function change_apn_post_status( $post_statuses, $post_type ) {
函数change_apn_post_status($ post_statuses,$ post_type){
// Add a post status.
//添加帖子状态。
// Note: by default these are already in the $post_statuses array: 'draft', 'future', 'pending', 'private', 'publish'
//注意:默认情况下,这些已经在$ post_statuses数组中:'draft','future','pending','private','publish'
$post_statuses[] = 'trash';
$ post_statuses [] ='垃圾箱';
// Remove post status(es).
//删除帖子状态。
$post_statuses_to_remove = array( 'draft' );
$ post_statuses_to_remove = array('draft');
// Customize here.
//在此处自定义。
if ( 'page' === $post_type ) {
if('page'=== $ post_type){
$post_statuses_to_remove[] = 'pending';
$ post_statuses_to_remove [] ='待定';
}
}
foreach ( $post_statuses_to_remove as $remove ) {
foreach($ post_statuses_to_remove as $ remove){
if ( false !== $index = array_search( $remove, $post_statuses ) ) {
if(false!== $ index = array_search($ remove,$ post_statuses)){
unset( $post_statuses[ $index ] );
unset($ post_statuses [$ index]);
}
}
}
}
return array_values( $post_statuses );
返回array_values($ post_statuses);
}
}
add_filter( 'c2c_admin_post_navigation_post_statuses', 'change_apn_post_status', 10, 2 );
add_filter('c2c_admin_post_navigation_post_statuses','change_apn_post_status',10,2);
code> pre>
c2c_admin_post_navigation_post_types (filter)
c2c_admin_post_navigation_post_types(过滤器) h4>
The ‘c2c_admin_post_navigation_post_types’ filter allows you to modify the list of post_types used as part of the search for the prevext post.
通过“ c2c_admin_post_navigation_post_types”过滤器,您可以修改用作搜索上一个/下一个帖子的一部分的post_types列表。
By default this array includes all available post types.
默认情况下,此数组包括所有可用的帖子类型。
If you wish to change this, hook this filter.
如果您要更改此设置,请挂钩此过滤器。 p>
Arguments:
参数: p>
- $post_types (array) The array of valid post_types
- $ post_types(数组)有效的post_types数组 li>
ul>
Examples:
示例: p>
/** / ** * Modify Admin Post Navigation to only allow navigating strictly for posts.
*修改“管理员帖子导航”以仅允许严格导航帖子。
*
*
* @param array $post_types Post types that should have admin post navigation.
* @param array $ post_types应该具有管理员帖子导航的帖子类型。
* @return array
* @返回数组
*/
* /
function change_apn_post_types( $post_types ) {
函数change_apn_post_types($ post_types){
return array( 'post' );
return array('post');
}
}
add_filter( 'c2c_admin_post_navigation_post_types', 'change_apn_post_types' );
add_filter('c2c_admin_post_navigation_post_types','change_apn_post_types');
/**
/ **
* Modify Admin Post Navigation to disallow navigation for the 'recipe' post type.
*修改“管理员帖子导航”以禁止导航“食谱”帖子类型。
*
*
* @param array $post_types Post types that should have admin post navigation.
* @param array $ post_types应该具有管理员帖子导航的帖子类型。
* @return array
* @返回数组
*/
* /
function remove_recipe_apn_post_types( $post_types ) {
函数remove_recipe_apn_post_types($ post_types){
if ( isset( $post_types['recipe'] ) ) {
如果(isset($ post_types ['recipe'])){
unset( $post_types['recipe'] );
unset($ post_types ['recipe']);
// Removing a post type
//删除帖子类型
}
}
return $post_types;
返回$ post_types;
}
}
add_filter( 'c2c_admin_post_navigation_post_types', 'remove_recipe_apn_post_types' );
add_filter('c2c_admin_post_navigation_post_types','remove_recipe_apn_post_types');
code> pre>
c2c_admin_post_navigation_prev_text (filter)
c2c_admin_post_navigation_prev_text(过滤器) h4>
The ‘c2c_admin_post_navigation_prev_text’ filter allows you to change the link text used for the ‘Previous’ link.
通过“ c2c_admin_post_navigation_prev_text”过滤器,您可以更改用于“上一个”链接的链接文本。
By default this is ‘← Previous’.
默认情况下,这是“←上一步”。 p>
Arguments:
参数: p>
- $text (string) The ‘previous’ link text.
- $ text(字符串)“上一个”链接文本。 li>
ul>
Example:
示例: p>
/** / ** * Changes the text for the 'previous' link to 'Older' output by the Admin Post Navigation plugin.
*通过Admin Post Navigation插件将“先前”链接的文本更改为“较旧”输出。
*
*
* @param string $text The text used to indicate the 'next' post.
* @param string $ text用于指示“下一个”帖子的文本。
* @return string
* @返回字符串
*/
* /
function my_c2c_admin_post_navigation_prev_text( $text ) {
函数my_c2c_admin_post_navigation_prev_text($ text){
return 'Older';
返回“较旧”;
}
}
add_filter( 'c2c_admin_post_navigation_prev_text', 'my_c2c_admin_post_navigation_prev_text' );
add_filter('c2c_admin_post_navigation_prev_text','my_c2c_admin_post_navigation_prev_text');
code> pre>
c2c_admin_post_navigation_next_text (filter)
c2c_admin_post_navigation_next_text(过滤器) h4>
The ‘c2c_admin_post_navigation_next_text’ filter allows you to change the link text used for the ‘Next’ link.
通过“ c2c_admin_post_navigation_next_text”过滤器,您可以更改用于“下一个”链接的链接文本。
By default this is ‘Next →’.
默认情况下,这是“下一步→”。 p>
Arguments:
参数: p>
- $text (string) The ‘next’ link text.
- $ text(字符串)“下一个”链接文本。 li>
ul>
Example:
示例: p>
/** / ** * Changes the text for the 'next' link to 'Newer' output by the Admin Post Navigation plugin.
*通过Admin Post Navigation插件将“下一个”链接的文本更改为“较新”输出。
*
*
* @param string $text The text used to indicate the 'next' post.
* @param string $ text用于指示“下一个”帖子的文本。
* @return string
* @返回字符串
*/
* /
function my_c2c_admin_post_navigation_next_text( $text ) {
函数my_c2c_admin_post_navigation_next_text($ text){
return 'Newer';
返回“较新”;
}
}
add_filter( 'c2c_admin_post_navigation_next_text', 'my_c2c_admin_post_navigation_next_text' );
add_filter('c2c_admin_post_navigation_next_text','my_c2c_admin_post_navigation_next_text');
code> pre>
c2c_admin_post_navigation_display (filter)
c2c_admin_post_navigation_display(过滤器) h4>
The ‘c2c_admin_post_navigation_display’ filter allows you to customize the output links for the post navigation.
通过“ c2c_admin_post_navigation_display”过滤器,您可以自定义帖子导航的输出链接。 p>
Arguments:
参数: p>
- $text (string) The current output for the prevext navigation link
- $ text(字符串)上一个/下一个导航链接的当前输出 li>
ul>
Example:
示例: p>
/** / ** * Change the markup displayed by the Admin Post Navigation plugin.
*更改Admin Post Navigation插件显示的标记。
*
*
* @param string $text The text being output by the plugin.
* @param string $ text插件输出的文本。
* @return string
* @返回字符串
*/
* /
function override_apn_display( $text ) {
函数override_apn_display($ text){
// Simplistic example.
//简单的示例。
You could preferably make the text bold using CSS.
您最好使用CSS将文本设为粗体。
return '' .返回''。 $text .
$ text。
'
';
' strong>';
}
}
add_filter( 'c2c_admin_post_navigation_display', 'override_apn_display' );
add_filter('c2c_admin_post_navigation_display','override_apn_display');
code> pre>