Admin Post Navigation - Version 1.7

Version Description

  • Add support for localization
  • Change to use post type label instead of post type name, when possible, in link title attribute
  • Change to use larr and rarr characters to denote direction of navigation
  • Enhanced styling of navigation links
  • Hook 'admin_enqueue_scripts' action instead of 'admin_head' to output CSS
  • Hook 'load-post.php' to add actions for the post.php page rather than using $pagenow
  • Add version() to return plugin version
  • Add register_post_page_hooks()
  • Remove admin_init() and hook 'do_meta_boxes' in register_post_page_hooks() instead
  • Update screenshots for WP 3.3
  • Note compatibility through WP 3.3+
  • Drop compatibility with versions of WP older than 3.0
  • Update screenshots for WP 3.3
  • Add link to plugin directory page to readme.txt
  • Minor code reformatting
  • Minor readme.txt reformatting
  • Update copyright date (2012)
Download this release

Release Info

Developer coffee2code
Plugin Icon 128x128 Admin Post Navigation
Version 1.7
Comparing to
See all releases

Code changes from version 1.6.1 to 1.7

admin-post-navigation.php CHANGED
@@ -2,29 +2,27 @@
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
  /*
27
- Copyright (c) 2008-2011 by Scott Reilly (aka coffee2code)
28
 
29
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
30
  files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
@@ -47,27 +45,39 @@ class c2c_AdminPostNavigation {
47
  private static $next_text = '';
48
  private static $post_statuses = array( 'draft', 'future', 'pending', 'private', 'publish' ); // Filterable later
49
  private static $post_statuses_sql = '';
 
 
 
 
 
 
 
 
 
 
50
 
51
  /**
52
  * Class constructor: initializes class variables and adds actions and filters.
53
  */
54
  public static function init() {
55
- global $pagenow;
56
- if ( 'post.php' == $pagenow ) {
57
- self::$prev_text = __( '« Previous' );
58
- self::$next_text = __( 'Next »' );
59
-
60
- add_action( 'admin_init', array( __CLASS__, 'admin_init' ) );
61
- add_action( 'admin_head', array( __CLASS__, 'add_css' ) );
62
- add_action( 'admin_print_footer_scripts', array( __CLASS__, 'add_js' ) );
63
- }
64
  }
65
 
66
  /**
67
- * Initialize variables and meta_box
 
 
 
68
  */
69
- public static function admin_init() {
70
- add_action( 'do_meta_boxes', array( __CLASS__, 'do_meta_box' ), 10, 3 ); /* For WP 3.0+ only support, change this to hook 'add_meta_boxes' */
 
 
 
 
 
 
 
71
  }
72
 
73
  /**
@@ -82,15 +92,15 @@ class c2c_AdminPostNavigation {
82
  * @return void
83
  */
84
  public static function do_meta_box( $post_type, $type, $post ) {
85
- $post_statuses = apply_filters( 'c2c_admin_post_navigation_post_statuses', self::$post_statuses, $post_type, $post );
86
-
87
  $post_types = apply_filters( 'c2c_admin_post_navigation_post_types', get_post_types() );
88
- if ( !in_array( $post_type, $post_types ) )
89
  return;
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
  /**
@@ -103,26 +113,49 @@ class c2c_AdminPostNavigation {
103
  public static function add_meta_box( $object, $box ) {
104
  global $post_ID;
105
  $display = '';
106
- $context = $object->post_type;
 
 
107
  $prev = self::previous_post();
108
  if ( $prev ) {
109
- $post_title = esc_attr( strip_tags( get_the_title( $prev->ID ) ) ); /* If only the_title_attribute() accepted post ID as arg */
110
- $display .= '<a href="' . get_edit_post_link( $prev->ID ) .
111
- "\" id='admin-post-nav-prev' title='Previous $context: $post_title' class='admin-post-nav-prev'>" . self::$prev_text . '</a>';
 
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 ) .
119
- "\" id='admin-post-nav-next' title='Next $context: $post_title' class='admin-post-nav-next'>" . self::$next_text . '</a>';
 
 
120
  }
 
121
  $display = '<span id="admin-post-nav">' . $display . '</span>';
122
  $display = apply_filters( 'admin_post_nav', $display ); /* Deprecated as of v1.5 */
123
  echo apply_filters( 'c2c_admin_post_navigation_display', $display );
124
  }
125
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  /**
127
  * Outputs CSS within style tags
128
  */
@@ -130,6 +163,7 @@ class c2c_AdminPostNavigation {
130
  echo <<<CSS
131
  <style type="text/css">
132
  #admin-post-nav {margin-left:20px;}
 
133
  h2 #admin-post-nav {font-size:0.6em;}
134
  </style>
135
 
2
  /**
3
  * @package Admin_Post_Navigation
4
  * @author Scott Reilly
5
+ * @version 1.7
6
  */
7
  /*
8
  Plugin Name: Admin Post Navigation
9
+ Version: 1.7
10
  Plugin URI: http://coffee2code.com/wp-plugins/admin-post-navigation/
11
  Author: Scott Reilly
12
  Author URI: http://coffee2code.com
13
+ Text Domain: admin-post-navigation
14
+ Domain Path: /lang/
15
+ Description: Adds links to navigate to the next and previous posts when editing a post in the WordPress admin.
16
 
17
+ Compatible with WordPress 3.0+, 3.1+, 3.2+, 3.3+.
18
 
19
  =>> Read the accompanying readme.txt file for instructions and documentation.
20
  =>> Also, visit the plugin's homepage for additional information and updates.
21
  =>> Or visit: http://wordpress.org/extend/plugins/admin-post-navigation/
 
 
 
 
22
  */
23
 
24
  /*
25
+ Copyright (c) 2008-2012 by Scott Reilly (aka coffee2code)
26
 
27
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
28
  files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
45
  private static $next_text = '';
46
  private static $post_statuses = array( 'draft', 'future', 'pending', 'private', 'publish' ); // Filterable later
47
  private static $post_statuses_sql = '';
48
+ private static $textdomain = 'admin-post-navigation';
49
+
50
+ /**
51
+ * Returns version of the plugin.
52
+ *
53
+ * @since 1.7
54
+ */
55
+ public static function version() {
56
+ return '1.7';
57
+ }
58
 
59
  /**
60
  * Class constructor: initializes class variables and adds actions and filters.
61
  */
62
  public static function init() {
63
+ add_action( 'load-post.php', array( __CLASS__, 'register_post_page_hooks' ) );
 
 
 
 
 
 
 
 
64
  }
65
 
66
  /**
67
+ * Filters/actions to hook on the admin post.php page.
68
+ *
69
+ * @since 1.7
70
+ *
71
  */
72
+ public static function register_post_page_hooks() {
73
+ load_plugin_textdomain( self::$textdomain, false, basename( dirname( __FILE__ ) ) . DIRECTORY_SEPARATOR . 'lang' );
74
+
75
+ self::$prev_text = __( '&larr; Previous', self::$textdomain );
76
+ self::$next_text = __( 'Next &rarr;', self::$textdomain );
77
+
78
+ add_action( 'admin_enqueue_scripts', array( __CLASS__, 'add_css' ) );
79
+ add_action( 'admin_print_footer_scripts', array( __CLASS__, 'add_js' ) );
80
+ add_action( 'do_meta_boxes', array( __CLASS__, 'do_meta_box' ), 10, 3 );
81
  }
82
 
83
  /**
92
  * @return void
93
  */
94
  public static function do_meta_box( $post_type, $type, $post ) {
 
 
95
  $post_types = apply_filters( 'c2c_admin_post_navigation_post_types', get_post_types() );
96
+ if ( ! in_array( $post_type, $post_types ) )
97
  return;
98
 
99
+ $post_statuses = apply_filters( 'c2c_admin_post_navigation_post_statuses', self::$post_statuses, $post_type, $post );
100
  self::$post_statuses_sql = "'" . implode( "', '", array_map( 'esc_sql', $post_statuses ) ) . "'";
101
+ $label = self::_get_post_type_label( $post_type );
102
  if ( in_array( $post->post_status, $post_statuses ) )
103
+ add_meta_box( 'adminpostnav', sprintf( __( '%s Navigation', self::$textdomain ), ucfirst( $post_type ) ), array( __CLASS__, 'add_meta_box' ), $post_type, 'side', 'core' );
104
  }
105
 
106
  /**
113
  public static function add_meta_box( $object, $box ) {
114
  global $post_ID;
115
  $display = '';
116
+
117
+ $context = self::_get_post_type_label( $object->post_type );
118
+
119
  $prev = self::previous_post();
120
  if ( $prev ) {
121
+ $post_title = strip_tags( get_the_title( $prev->ID ) ); /* If only the_title_attribute() accepted post ID as arg */
122
+ $display .= '<a href="' . get_edit_post_link( $prev->ID ) . '" id="admin-post-nav-prev" title="' .
123
+ esc_attr( sprintf( __( 'Previous %1$s: %2$s', self::$textdomain ), $context, $post_title ) ) .
124
+ '" class="admin-post-nav-prev add-new-h2">' . self::$prev_text . '</a>';
125
  }
126
+
127
  $next = self::next_post();
128
  if ( $next ) {
129
  if ( ! empty( $display ) )
130
+ $display .= ' ';
131
+ $post_title = strip_tags( get_the_title( $next->ID ) ); /* If only the_title_attribute() accepted post ID as arg */
132
  $display .= '<a href="' . get_edit_post_link( $next->ID ) .
133
+ '" id="admin-post-nav-next" title="' .
134
+ esc_attr( sprintf( __( 'Next %1$s: %2$s', self::$textdomain ), $context, $post_title ) ).
135
+ '" class="admin-post-nav-next add-new-h2">' . self::$next_text . '</a>';
136
  }
137
+
138
  $display = '<span id="admin-post-nav">' . $display . '</span>';
139
  $display = apply_filters( 'admin_post_nav', $display ); /* Deprecated as of v1.5 */
140
  echo apply_filters( 'c2c_admin_post_navigation_display', $display );
141
  }
142
 
143
+ /**
144
+ * Gets label for post type.
145
+ *
146
+ * @since 1.7
147
+ *
148
+ * @param string $post_type The post_type
149
+ * @return string The label for the post_type
150
+ */
151
+ public static function _get_post_type_label( $post_type ) {
152
+ $label = $post_type;
153
+ $post_type_object = get_post_type_object( $label );
154
+ if ( is_object( $post_type_object ) )
155
+ $label = $post_type_object->labels->singular_name;
156
+ return strtolower( $label );
157
+ }
158
+
159
  /**
160
  * Outputs CSS within style tags
161
  */
163
  echo <<<CSS
164
  <style type="text/css">
165
  #admin-post-nav {margin-left:20px;}
166
+ #adminpostnav #admin-post-nav {margin-left:0;}
167
  h2 #admin-post-nav {font-size:0.6em;}
168
  </style>
169
 
lang/admin-post-navigation.pot ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Translation of the WordPress plugin Admin Post Navigation v1.7 by Scott Reilly.
2
+ # Copyright (C) 2011 Scott Reilly
3
+ # This file is distributed under the same license as the Admin Post Navigation plugin.
4
+ msgid ""
5
+ msgstr ""
6
+ "Project-Id-Version: Admin Post Navigation 1.7\n"
7
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/admin-post-navigation\n"
8
+ "POT-Creation-Date: 2011-12-15 22:01:43+00:00\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "PO-Revision-Date: 2010-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
+
16
+ #: admin-post-navigation.php:75
17
+ msgid "&larr; Previous"
18
+ msgstr ""
19
+
20
+ #: admin-post-navigation.php:76
21
+ msgid "Next &rarr;"
22
+ msgstr ""
23
+
24
+ #: admin-post-navigation.php:103
25
+ msgid "%s Navigation"
26
+ msgstr ""
27
+
28
+ #: admin-post-navigation.php:123
29
+ msgid "Previous %1$s: %2$s"
30
+ msgstr ""
31
+
32
+ #: admin-post-navigation.php:134
33
+ msgid "Next %1$s: %2$s"
34
+ msgstr ""
35
+
36
+ #. Plugin Name of the plugin/theme
37
+ msgid "Admin Post Navigation"
38
+ msgstr ""
39
+
40
+ #. Plugin URI of the plugin/theme
41
+ msgid "http://coffee2code.com/wp-plugins/admin-post-navigation/"
42
+ msgstr ""
43
+
44
+ #. Description of the plugin/theme
45
+ msgid ""
46
+ "Adds links to navigate to the next and previous posts when editing a post in "
47
+ "the WordPress admin."
48
+ msgstr ""
49
+
50
+ #. Author of the plugin/theme
51
+ msgid "Scott Reilly"
52
+ msgstr ""
53
+
54
+ #. Author URI of the plugin/theme
55
+ msgid "http://coffee2code.com"
56
+ msgstr ""
readme.txt CHANGED
@@ -2,17 +2,17 @@
2
  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.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
 
12
 
13
  == Description ==
14
 
15
- Adds links to the next and previous posts when editing a post in the WordPress admin.
16
 
17
  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 previous/next post. The links link to the "Edit Post" admin page for the previous/next posts so that you may edit them.
18
 
@@ -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](http://coffee2code.com/wp-plugins/admin-post-navigation/) | [Author Homepage](http://coffee2code.com)
24
 
25
 
26
  == Installation ==
@@ -130,6 +130,25 @@ function override_apn_display( $text ) {
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+
2
  Contributors: coffee2code
3
  Donate link: http://coffee2code.com/donate
4
  Tags: admin, navigation, post, next, previous, edit, post types, coffee2code
5
+ Requires at least: 3.0
6
+ Tested up to: 3.3
7
+ Stable tag: 1.7
8
+ Version: 1.7
9
 
10
+ Adds links to navigate to the next and previous posts when editing a post in the WordPress admin.
11
 
12
 
13
  == Description ==
14
 
15
+ Adds links to navigate to the next and previous posts when editing a post in the WordPress admin.
16
 
17
  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 previous/next post. The links link to the "Edit Post" admin page for the previous/next posts so that you may edit them.
18
 
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/) | [Plugin Directory Page](http://wordpress.org/extend/plugins/admin-post-navigation/) | [Author Homepage](http://coffee2code.com)
24
 
25
 
26
  == Installation ==
130
 
131
  == Changelog ==
132
 
133
+ = 1.7 =
134
+ * Add support for localization
135
+ * Change to use post type label instead of post type name, when possible, in link title attribute
136
+ * Change to use larr and rarr characters to denote direction of navigation
137
+ * Enhanced styling of navigation links
138
+ * Hook 'admin_enqueue_scripts' action instead of 'admin_head' to output CSS
139
+ * Hook 'load-post.php' to add actions for the post.php page rather than using $pagenow
140
+ * Add version() to return plugin version
141
+ * Add register_post_page_hooks()
142
+ * Remove admin_init() and hook 'do_meta_boxes' in register_post_page_hooks() instead
143
+ * Update screenshots for WP 3.3
144
+ * Note compatibility through WP 3.3+
145
+ * Drop compatibility with versions of WP older than 3.0
146
+ * Update screenshots for WP 3.3
147
+ * Add link to plugin directory page to readme.txt
148
+ * Minor code reformatting
149
+ * Minor readme.txt reformatting
150
+ * Update copyright date (2012)
151
+
152
  = 1.6.1 =
153
  * Use ucfirst() instead of strtoupper() to capitalize post type name for metabox title
154
  * Note compatibility through WP 3.2+
screenshot-1.png CHANGED
Binary file
screenshot-2.png CHANGED
Binary file