Admin Post Navigation - Version 1.0

Version Description

Download this release

Release Info

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

Version 1.0

Files changed (4) hide show
  1. admin-post-navigation.php +146 -0
  2. readme.txt +33 -0
  3. screenshot-1.png +0 -0
  4. screenshot-2.png +0 -0
admin-post-navigation.php ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Admin Post Navigation
4
+ Version: 1.0
5
+ Plugin URI: http://coffee2code.com/wp-plugins/admin-post-navigation
6
+ Author: Scott Reilly
7
+ Author URI: http://coffee2code.com
8
+ Description: Adds links to the next and previous posts when editing a post in the WordPress admin.
9
+
10
+ This plugin adds "<< Previous" and "Next >>" links to the "Edit Post" admin page, if a previous and next post are
11
+ present, respectively. The link titles (visible when hovering over the links) reveal the title of the previous/next
12
+ post. The links link to the "Edit Post" admin page for the previous/next posts so that you may edit them.
13
+
14
+ Currently, a previous/next post is determined by the next lower/higher valid post based on relative sequential post ID.
15
+ Other post criteria such as post type (draft, pending, etc), publish date, post author, category, etc, are not taken
16
+ into consideration when determining the previous or next post.
17
+
18
+ NOTE: Be sure to save the post currently being edited before navigating away to the previous/next post.
19
+
20
+ Compatible with WordPress 2.6+, 2.7+.
21
+
22
+ =>> Read the accompanying readme.txt file for more information. Also, visit the plugin's homepage
23
+ =>> for more information and the latest updates
24
+
25
+ Installation:
26
+
27
+ 1. Download the file http://coffee2code.com/wp-plugins/admin-post-navigation.zip and unzip it into your
28
+ /wp-content/plugins/ directory.
29
+ 2. Activate the plugin through the 'Plugins' admin menu in WordPress
30
+ */
31
+
32
+ /*
33
+ Copyright (c) 2008-2009 by Scott Reilly (aka coffee2code)
34
+
35
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation
36
+ files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy,
37
+ modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
38
+ Software is furnished to do so, subject to the following conditions:
39
+
40
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
41
+
42
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
43
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
44
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
45
+ IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
46
+ */
47
+
48
+ if ( !class_exists('AdminPostNavigation') ) :
49
+
50
+ class AdminPostNavigation {
51
+ var $prev_text = '&laquo; Previous';
52
+ var $next_text = 'Next &raquo;';
53
+
54
+ function AdminPostNavigation() {
55
+ global $pagenow;
56
+ if ( is_admin() && 'post.php' == $pagenow ) {
57
+ $this->prev_text = __($this->prev_text);
58
+ $this->next_text = __($this->next_text);
59
+
60
+ add_action('admin_init', array(&$this,'admin_init'));
61
+ add_action('admin_head', array(&$this, 'add_css'));
62
+ add_action('admin_footer', array(&$this, 'add_js'));
63
+ }
64
+ }
65
+
66
+ function admin_init() {
67
+ add_meta_box('adminpostnav', 'Post Navigation', array(&$this, 'add_meta_box'), 'post', 'side', 'core');
68
+ }
69
+
70
+ function add_meta_box( $object, $box ) {
71
+ global $post_ID;
72
+ $display = '';
73
+ $context = $object->post_type;
74
+ $prev = $this->previous_post();
75
+ if ( $prev ) {
76
+ $post_title = attribute_escape(strip_tags($prev->post_title));
77
+ $display .= '<a href="' . get_edit_post_link($prev->ID) .
78
+ "\" id='admin-post-nav-prev' title='Previous $context: $post_title' class='admin-post-nav-prev'>{$this->prev_text}</a>";
79
+ }
80
+ $next = $this->next_post();
81
+ if ( $next ) {
82
+ if ( !empty($display) )
83
+ $display .= ' | ';
84
+ $post_title = attribute_escape($next->post_title);
85
+ $display .= '<a href="' . get_edit_post_link($next->ID) .
86
+ "\" id='admin-post-nav-next' title='Next $context: $post_title' class='admin-post-nav-next'>{$this->next_text}</a>";
87
+ }
88
+ $display = '<span id="admin-post-nav">' . $display . '</span>';
89
+ echo apply_filters('admin_post_nav', $display);
90
+ }
91
+
92
+ function add_css() {
93
+ echo <<<CSS
94
+ <style type="text/css">
95
+ #admin-post-nav {
96
+ margin-left:20px;
97
+ }
98
+ h2 #admin-post-nav {
99
+ font-size:0.6em;
100
+ }
101
+ </style>
102
+
103
+ CSS;
104
+ }
105
+
106
+ // For those with JS enabled, the navigation links are moved next to the "Edit Post" header and the plugin's meta_box is hidden.
107
+ // The fallback for non-JS people is that the plugin's meta_box is shown and the navigation links can be found there.
108
+ function add_js() {
109
+ echo <<<JS
110
+ <script type="text/javascript">
111
+ jQuery(document).ready(function($) {
112
+ $('#admin-post-nav').appendTo($('h2'));
113
+ $('#adminpostnav').hide();
114
+ });
115
+
116
+ </script>
117
+ JS;
118
+ }
119
+
120
+ function query($type = '<') {
121
+ global $post_ID, $wpdb;
122
+ $sql = "SELECT * FROM $wpdb->posts WHERE post_type = 'post' ";
123
+ if ($post_ID) {
124
+ $sql .= "AND ID $type $post_ID ";
125
+ }
126
+ $sort = $type == '<' ? 'DESC' : 'ASC';
127
+ $sql .= "ORDER BY post_date $sort LIMIT 1";
128
+ return $wpdb->get_row($sql);
129
+ }
130
+
131
+ function next_post() {
132
+ return $this->query('>');
133
+ }
134
+
135
+ function previous_post() {
136
+ return $this->query('<');
137
+ }
138
+
139
+ } // end AdminPostNavigation
140
+
141
+ endif; // end if !class_exists()
142
+
143
+ if ( class_exists('AdminPostNavigation') )
144
+ new AdminPostNavigation();
145
+
146
+ ?>
readme.txt ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Admin Post Navigation ===
2
+ Contributors: Scott Reilly
3
+ Donate link: http://coffee2code.com
4
+ Tags: admin, navigation, post, next, previous, edit
5
+ Requires at least: 2.6
6
+ Tested up to: 2.7.1
7
+ Stable tag: trunk
8
+ Version: 1.0
9
+
10
+ Adds links to the next and previous posts when editing a post in the WordPress admin.
11
+
12
+ == Description ==
13
+
14
+ Adds links to the next and previous posts when editing a post in the WordPress admin.
15
+
16
+ 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.
17
+
18
+ Currently, a previous/next post is determined by the next lower/higher valid post based on relative sequential post ID. 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.
19
+
20
+ NOTE: Be sure to save the post currently being edited before navigating away to the previous/next post.
21
+
22
+
23
+ == Installation ==
24
+
25
+ 1. Unzip `admin-post-navigation-v1.0.zip` inside the `/wp-content/plugins/` directory for your site
26
+ 1. Activate the plugin through the 'Plugins' admin menu in WordPress
27
+
28
+ == Screenshots ==
29
+
30
+ 1. A screenshot of the previous/next links adjacent to the 'Edit Post' admin page header when Javascript is enabled.
31
+ 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.
32
+
33
+
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file