Version Description
- Use ucfirst() instead of strtoupper() to capitalize post type name for metabox title
- Note compatibility through WP 3.2+
- Minor code formatting changes (spacing)
- Add FAQ section to readme.txt
- Fix plugin homepage and author links in description in readme.txt
Download this release
Release Info
| Developer | coffee2code |
| Plugin | |
| Version | 1.6.1 |
| Comparing to | |
| See all releases | |
Code changes from version 1.6 to 1.6.1
- admin-post-navigation.php +11 -9
- readme.txt +42 -17
admin-post-navigation.php
CHANGED
|
@@ -2,22 +2,25 @@
|
|
| 2 |
/**
|
| 3 |
* @package Admin_Post_Navigation
|
| 4 |
* @author Scott Reilly
|
| 5 |
-
* @version 1.6
|
| 6 |
*/
|
| 7 |
/*
|
| 8 |
Plugin Name: Admin Post Navigation
|
| 9 |
-
Version: 1.6
|
| 10 |
Plugin URI: http://coffee2code.com/wp-plugins/admin-post-navigation/
|
| 11 |
Author: Scott Reilly
|
| 12 |
Author URI: http://coffee2code.com
|
| 13 |
Description: Adds links to the next and previous posts when editing a post in the WordPress admin.
|
| 14 |
|
| 15 |
-
Compatible with WordPress 2.8+, 2.9+, 3.0+, 3.1+.
|
| 16 |
|
| 17 |
=>> Read the accompanying readme.txt file for instructions and documentation.
|
| 18 |
=>> Also, visit the plugin's homepage for additional information and updates.
|
| 19 |
=>> Or visit: http://wordpress.org/extend/plugins/admin-post-navigation/
|
| 20 |
|
|
|
|
|
|
|
|
|
|
| 21 |
*/
|
| 22 |
|
| 23 |
/*
|
|
@@ -36,9 +39,10 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRA
|
|
| 36 |
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
| 37 |
*/
|
| 38 |
|
| 39 |
-
if ( is_admin() && !class_exists( 'c2c_AdminPostNavigation' ) ) :
|
| 40 |
|
| 41 |
class c2c_AdminPostNavigation {
|
|
|
|
| 42 |
private static $prev_text = '';
|
| 43 |
private static $next_text = '';
|
| 44 |
private static $post_statuses = array( 'draft', 'future', 'pending', 'private', 'publish' ); // Filterable later
|
|
@@ -86,7 +90,7 @@ class c2c_AdminPostNavigation {
|
|
| 86 |
|
| 87 |
self::$post_statuses_sql = "'" . implode( "', '", array_map( 'esc_sql', $post_statuses ) ) . "'";
|
| 88 |
if ( in_array( $post->post_status, $post_statuses ) )
|
| 89 |
-
add_meta_box( 'adminpostnav', sprintf( '%s Navigation',
|
| 90 |
}
|
| 91 |
|
| 92 |
/**
|
|
@@ -108,7 +112,7 @@ class c2c_AdminPostNavigation {
|
|
| 108 |
}
|
| 109 |
$next = self::next_post();
|
| 110 |
if ( $next ) {
|
| 111 |
-
if ( !empty( $display ) )
|
| 112 |
$display .= ' | ';
|
| 113 |
$post_title = esc_attr( strip_tags( get_the_title( $next->ID ) ) ); /* If only the_title_attribute() accepted post ID as arg */
|
| 114 |
$display .= '<a href="' . get_edit_post_link( $next->ID ) .
|
|
@@ -190,8 +194,6 @@ JS;
|
|
| 190 |
$sql .= "ORDER BY $orderby $sort LIMIT $offset, $limit";
|
| 191 |
|
| 192 |
// Find the first one the user can actually edit
|
| 193 |
-
//echo "<p>query $type : ($sql)</p>";
|
| 194 |
-
//die();
|
| 195 |
$posts = $wpdb->get_results( $sql );
|
| 196 |
$result = false;
|
| 197 |
if ( $posts ) {
|
|
@@ -201,7 +203,7 @@ JS;
|
|
| 201 |
break;
|
| 202 |
}
|
| 203 |
}
|
| 204 |
-
if (
|
| 205 |
$offset += $limit;
|
| 206 |
// Double the limit each time (if haven't found a post yet, chances are we may not, so try to get through posts quicker)
|
| 207 |
$limit += $limit;
|
| 2 |
/**
|
| 3 |
* @package Admin_Post_Navigation
|
| 4 |
* @author Scott Reilly
|
| 5 |
+
* @version 1.6.1
|
| 6 |
*/
|
| 7 |
/*
|
| 8 |
Plugin Name: Admin Post Navigation
|
| 9 |
+
Version: 1.6.1
|
| 10 |
Plugin URI: http://coffee2code.com/wp-plugins/admin-post-navigation/
|
| 11 |
Author: Scott Reilly
|
| 12 |
Author URI: http://coffee2code.com
|
| 13 |
Description: Adds links to the next and previous posts when editing a post in the WordPress admin.
|
| 14 |
|
| 15 |
+
Compatible with WordPress 2.8+, 2.9+, 3.0+, 3.1+, 3.2+.
|
| 16 |
|
| 17 |
=>> Read the accompanying readme.txt file for instructions and documentation.
|
| 18 |
=>> Also, visit the plugin's homepage for additional information and updates.
|
| 19 |
=>> Or visit: http://wordpress.org/extend/plugins/admin-post-navigation/
|
| 20 |
|
| 21 |
+
TODO:
|
| 22 |
+
* Update screenshots for WP3.2
|
| 23 |
+
* L10n
|
| 24 |
*/
|
| 25 |
|
| 26 |
/*
|
| 39 |
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
| 40 |
*/
|
| 41 |
|
| 42 |
+
if ( is_admin() && ! class_exists( 'c2c_AdminPostNavigation' ) ) :
|
| 43 |
|
| 44 |
class c2c_AdminPostNavigation {
|
| 45 |
+
|
| 46 |
private static $prev_text = '';
|
| 47 |
private static $next_text = '';
|
| 48 |
private static $post_statuses = array( 'draft', 'future', 'pending', 'private', 'publish' ); // Filterable later
|
| 90 |
|
| 91 |
self::$post_statuses_sql = "'" . implode( "', '", array_map( 'esc_sql', $post_statuses ) ) . "'";
|
| 92 |
if ( in_array( $post->post_status, $post_statuses ) )
|
| 93 |
+
add_meta_box( 'adminpostnav', sprintf( '%s Navigation', ucfirst( $post_type ) ), array( __CLASS__, 'add_meta_box' ), $post_type, 'side', 'core' );
|
| 94 |
}
|
| 95 |
|
| 96 |
/**
|
| 112 |
}
|
| 113 |
$next = self::next_post();
|
| 114 |
if ( $next ) {
|
| 115 |
+
if ( ! empty( $display ) )
|
| 116 |
$display .= ' | ';
|
| 117 |
$post_title = esc_attr( strip_tags( get_the_title( $next->ID ) ) ); /* If only the_title_attribute() accepted post ID as arg */
|
| 118 |
$display .= '<a href="' . get_edit_post_link( $next->ID ) .
|
| 194 |
$sql .= "ORDER BY $orderby $sort LIMIT $offset, $limit";
|
| 195 |
|
| 196 |
// Find the first one the user can actually edit
|
|
|
|
|
|
|
| 197 |
$posts = $wpdb->get_results( $sql );
|
| 198 |
$result = false;
|
| 199 |
if ( $posts ) {
|
| 203 |
break;
|
| 204 |
}
|
| 205 |
}
|
| 206 |
+
if ( ! $result ) { // The fetch did not yield a post editable by user, so query again.
|
| 207 |
$offset += $limit;
|
| 208 |
// Double the limit each time (if haven't found a post yet, chances are we may not, so try to get through posts quicker)
|
| 209 |
$limit += $limit;
|
readme.txt
CHANGED
|
@@ -3,9 +3,9 @@ Contributors: coffee2code
|
|
| 3 |
Donate link: http://coffee2code.com/donate
|
| 4 |
Tags: admin, navigation, post, next, previous, edit, post types, coffee2code
|
| 5 |
Requires at least: 2.8
|
| 6 |
-
Tested up to: 3.1
|
| 7 |
-
Stable tag: 1.6
|
| 8 |
-
Version: 1.6
|
| 9 |
|
| 10 |
Adds links to the next and previous posts when editing a post in the WordPress admin.
|
| 11 |
|
|
@@ -20,7 +20,7 @@ Currently, a previous/next post is determined by the next lower/higher valid pos
|
|
| 20 |
|
| 21 |
NOTE: Be sure to save the post currently being edited before navigating away to the previous/next post.
|
| 22 |
|
| 23 |
-
Links: [Plugin Homepage]
|
| 24 |
|
| 25 |
|
| 26 |
== Installation ==
|
|
@@ -36,11 +36,18 @@ Links: [Plugin Homepage]:(http://coffee2code.com/wp-plugins/admin-post-navigatio
|
|
| 36 |
2. A screenshot of the previous/next links in their own 'Edit Post' admin page sidebar panel when Javascript is disabled for the admin user.
|
| 37 |
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
== Filters ==
|
| 40 |
|
| 41 |
-
The plugin is further customizable via
|
| 42 |
|
| 43 |
-
= c2c_admin_post_navigation_orderby =
|
| 44 |
|
| 45 |
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 previous/next post. By default this is 'ID' for non-hierarchical post types (such as posts) and 'post_title' for hierarchical post types (such as pages). If you wish to change this, hook this filter. This is not typical usage for most users.
|
| 46 |
|
|
@@ -55,7 +62,7 @@ function order_apn_by_post_date( $field ) {
|
|
| 55 |
return 'post_date';
|
| 56 |
}`
|
| 57 |
|
| 58 |
-
= c2c_admin_post_navigation_post_statuses =
|
| 59 |
|
| 60 |
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 prev/next post. 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.
|
| 61 |
|
|
@@ -65,14 +72,16 @@ Arguments:
|
|
| 65 |
|
| 66 |
Example:
|
| 67 |
|
| 68 |
-
`
|
|
|
|
| 69 |
function change_apn_post_status( $post_statuses ) {
|
| 70 |
$post_statuses[] = 'trash'; // Adding a post status
|
| 71 |
if ( isset( $post_statuses['future'] ) ) unset( $post_statuses['future'] ); // Removing a post status
|
| 72 |
return $post_statuses;
|
| 73 |
-
}
|
|
|
|
| 74 |
|
| 75 |
-
= c2c_admin_post_navigation_post_types =
|
| 76 |
|
| 77 |
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 prev/next post. By default this array includes all available post types. If you wish to change this, hook this filter.
|
| 78 |
|
|
@@ -82,21 +91,25 @@ Arguments:
|
|
| 82 |
|
| 83 |
Examples:
|
| 84 |
|
| 85 |
-
|
|
|
|
| 86 |
add_filter( 'c2c_admin_post_navigation_post_types', 'change_apn_post_types' );
|
| 87 |
function change_apn_post_types( $post_types ) {
|
| 88 |
return array( 'post' );
|
| 89 |
-
}
|
|
|
|
| 90 |
|
| 91 |
-
|
|
|
|
| 92 |
add_filter( 'c2c_admin_post_navigation_post_types', 'remove_recipe_apn_post_types' );
|
| 93 |
function remove_recipe_apn_post_types( $post_types ) {
|
| 94 |
if ( isset( $post_types['recipe'] ) )
|
| 95 |
unset( $post_types['recipe'] ); // Removing a post type
|
| 96 |
return $post_types;
|
| 97 |
-
}
|
|
|
|
| 98 |
|
| 99 |
-
= c2c_admin_post_navigation_display =
|
| 100 |
|
| 101 |
The 'c2c_admin_post_navigation_display' filter allows you to customize the output links for the post navigation.
|
| 102 |
|
|
@@ -106,15 +119,24 @@ Arguments:
|
|
| 106 |
|
| 107 |
Example:
|
| 108 |
|
| 109 |
-
`
|
|
|
|
| 110 |
function override_apn_display( $text ) {
|
| 111 |
// Simplistic example. You could preferably make the text bold using CSS.
|
| 112 |
return '<strong>' . $text . '</strong>';
|
| 113 |
-
}
|
|
|
|
| 114 |
|
| 115 |
|
| 116 |
== Changelog ==
|
| 117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
= 1.6 =
|
| 119 |
* Add support for navigation in other post types
|
| 120 |
* Add filter 'c2c_admin_post_navigation_post_types' for customizing valid post_types for search
|
|
@@ -173,6 +195,9 @@ function override_apn_display( $text ) {
|
|
| 173 |
|
| 174 |
== Upgrade Notice ==
|
| 175 |
|
|
|
|
|
|
|
|
|
|
| 176 |
= 1.6 =
|
| 177 |
Feature update: added support for non-'post' post types; fixed so navigation only appears for posts of appropriate post status; implementation changes; renamed class; updated copyright date; other minor code changes.
|
| 178 |
|
| 3 |
Donate link: http://coffee2code.com/donate
|
| 4 |
Tags: admin, navigation, post, next, previous, edit, post types, coffee2code
|
| 5 |
Requires at least: 2.8
|
| 6 |
+
Tested up to: 3.2.1
|
| 7 |
+
Stable tag: 1.6.1
|
| 8 |
+
Version: 1.6.1
|
| 9 |
|
| 10 |
Adds links to the next and previous posts when editing a post in the WordPress admin.
|
| 11 |
|
| 20 |
|
| 21 |
NOTE: Be sure to save the post currently being edited before navigating away to the previous/next post.
|
| 22 |
|
| 23 |
+
Links: [Plugin Homepage](http://coffee2code.com/wp-plugins/admin-post-navigation/) | [Author Homepage](http://coffee2code.com)
|
| 24 |
|
| 25 |
|
| 26 |
== Installation ==
|
| 36 |
2. A screenshot of the previous/next links in their own 'Edit Post' admin page sidebar panel when Javascript is disabled for the admin user.
|
| 37 |
|
| 38 |
|
| 39 |
+
== Frequently Asked Questions ==
|
| 40 |
+
|
| 41 |
+
= How do I change it so the previous/next links find the adjacent post according to post_date? =
|
| 42 |
+
|
| 43 |
+
See the Filters section for the `c2c_admin_post_navigation_orderby` filter, which has just such an example.
|
| 44 |
+
|
| 45 |
+
|
| 46 |
== Filters ==
|
| 47 |
|
| 48 |
+
The plugin is further customizable via four filters. Typically, these customizations would be put into your active theme's functions.php file, or used by another plugin.
|
| 49 |
|
| 50 |
+
= c2c_admin_post_navigation_orderby (filter) =
|
| 51 |
|
| 52 |
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 previous/next post. By default this is 'ID' for non-hierarchical post types (such as posts) and 'post_title' for hierarchical post types (such as pages). If you wish to change this, hook this filter. This is not typical usage for most users.
|
| 53 |
|
| 62 |
return 'post_date';
|
| 63 |
}`
|
| 64 |
|
| 65 |
+
= c2c_admin_post_navigation_post_statuses (filter) =
|
| 66 |
|
| 67 |
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 prev/next post. 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.
|
| 68 |
|
| 72 |
|
| 73 |
Example:
|
| 74 |
|
| 75 |
+
`
|
| 76 |
+
add_filter( 'c2c_admin_post_navigation_post_statuses', 'change_apn_post_status' );
|
| 77 |
function change_apn_post_status( $post_statuses ) {
|
| 78 |
$post_statuses[] = 'trash'; // Adding a post status
|
| 79 |
if ( isset( $post_statuses['future'] ) ) unset( $post_statuses['future'] ); // Removing a post status
|
| 80 |
return $post_statuses;
|
| 81 |
+
}
|
| 82 |
+
`
|
| 83 |
|
| 84 |
+
= c2c_admin_post_navigation_post_types (filter) =
|
| 85 |
|
| 86 |
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 prev/next post. By default this array includes all available post types. If you wish to change this, hook this filter.
|
| 87 |
|
| 91 |
|
| 92 |
Examples:
|
| 93 |
|
| 94 |
+
`
|
| 95 |
+
// Modify Admin Post Navigation to only allow navigating strictly for posts.
|
| 96 |
add_filter( 'c2c_admin_post_navigation_post_types', 'change_apn_post_types' );
|
| 97 |
function change_apn_post_types( $post_types ) {
|
| 98 |
return array( 'post' );
|
| 99 |
+
}
|
| 100 |
+
`
|
| 101 |
|
| 102 |
+
`
|
| 103 |
+
// Modify Admin Post Navigation to disallow navigation for the 'recipe' post type
|
| 104 |
add_filter( 'c2c_admin_post_navigation_post_types', 'remove_recipe_apn_post_types' );
|
| 105 |
function remove_recipe_apn_post_types( $post_types ) {
|
| 106 |
if ( isset( $post_types['recipe'] ) )
|
| 107 |
unset( $post_types['recipe'] ); // Removing a post type
|
| 108 |
return $post_types;
|
| 109 |
+
}
|
| 110 |
+
`
|
| 111 |
|
| 112 |
+
= c2c_admin_post_navigation_display (filter) =
|
| 113 |
|
| 114 |
The 'c2c_admin_post_navigation_display' filter allows you to customize the output links for the post navigation.
|
| 115 |
|
| 119 |
|
| 120 |
Example:
|
| 121 |
|
| 122 |
+
`
|
| 123 |
+
add_filter( 'c2c_admin_post_navigation_display', 'override_apn_display' );
|
| 124 |
function override_apn_display( $text ) {
|
| 125 |
// Simplistic example. You could preferably make the text bold using CSS.
|
| 126 |
return '<strong>' . $text . '</strong>';
|
| 127 |
+
}
|
| 128 |
+
`
|
| 129 |
|
| 130 |
|
| 131 |
== Changelog ==
|
| 132 |
|
| 133 |
+
= 1.6.1 =
|
| 134 |
+
* Use ucfirst() instead of strtoupper() to capitalize post type name for metabox title
|
| 135 |
+
* Note compatibility through WP 3.2+
|
| 136 |
+
* Minor code formatting changes (spacing)
|
| 137 |
+
* Add FAQ section to readme.txt
|
| 138 |
+
* Fix plugin homepage and author links in description in readme.txt
|
| 139 |
+
|
| 140 |
= 1.6 =
|
| 141 |
* Add support for navigation in other post types
|
| 142 |
* Add filter 'c2c_admin_post_navigation_post_types' for customizing valid post_types for search
|
| 195 |
|
| 196 |
== Upgrade Notice ==
|
| 197 |
|
| 198 |
+
= 1.6.1 =
|
| 199 |
+
Trivial update: noted compatibility through WP 3.2+
|
| 200 |
+
|
| 201 |
= 1.6 =
|
| 202 |
Feature update: added support for non-'post' post types; fixed so navigation only appears for posts of appropriate post status; implementation changes; renamed class; updated copyright date; other minor code changes.
|
| 203 |
|
