Version Description
Download this release
Release Info
Developer | coffee2code |
Plugin | Admin Post Navigation |
Version | 1.1 |
Comparing to | |
See all releases |
Code changes from version 1.0 to 1.1
- admin-post-navigation.php +33 -11
- readme.txt +5 -5
admin-post-navigation.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Admin Post Navigation
|
4 |
-
Version: 1.
|
5 |
Plugin URI: http://coffee2code.com/wp-plugins/admin-post-navigation
|
6 |
Author: Scott Reilly
|
7 |
Author URI: http://coffee2code.com
|
@@ -11,13 +11,13 @@ This plugin adds "<< Previous" and "Next >>" links to the "Edit Post" admin page
|
|
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,
|
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
|
@@ -117,15 +117,37 @@ CSS;
|
|
117 |
JS;
|
118 |
}
|
119 |
|
120 |
-
function query($type = '<') {
|
121 |
global $post_ID, $wpdb;
|
122 |
-
|
123 |
-
|
|
|
|
|
|
|
|
|
|
|
124 |
$sql .= "AND ID $type $post_ID ";
|
125 |
-
}
|
126 |
$sort = $type == '<' ? 'DESC' : 'ASC';
|
127 |
-
$sql .= "ORDER BY post_date $sort LIMIT
|
128 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
}
|
130 |
|
131 |
function next_post() {
|
1 |
<?php
|
2 |
/*
|
3 |
Plugin Name: Admin Post Navigation
|
4 |
+
Version: 1.1
|
5 |
Plugin URI: http://coffee2code.com/wp-plugins/admin-post-navigation
|
6 |
Author: Scott Reilly
|
7 |
Author URI: http://coffee2code.com
|
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 |
+
and which the user can edit. Other post criteria such as post type (draft, pending, etc), publish date, post author,
|
16 |
+
category, etc, are not taken 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+, 2.8+.
|
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
|
117 |
JS;
|
118 |
}
|
119 |
|
120 |
+
function query($type = '<', $offset = 0, $limit = 15) {
|
121 |
global $post_ID, $wpdb;
|
122 |
+
if ( $type != '<' )
|
123 |
+
$type = '>';
|
124 |
+
$offset = (int)$offset;
|
125 |
+
$limit = (int)$limit;
|
126 |
+
|
127 |
+
$sql = "SELECT ID, post_title FROM $wpdb->posts WHERE post_type = 'post' ";
|
128 |
+
if ( $post_ID )
|
129 |
$sql .= "AND ID $type $post_ID ";
|
|
|
130 |
$sort = $type == '<' ? 'DESC' : 'ASC';
|
131 |
+
$sql .= "ORDER BY post_date $sort LIMIT $offset, $limit";
|
132 |
+
|
133 |
+
// Find the first one the user can actually edit
|
134 |
+
$posts = $wpdb->get_results($sql);
|
135 |
+
$result = false;
|
136 |
+
if ( $posts ) {
|
137 |
+
foreach ($posts as $post) {
|
138 |
+
if ( current_user_can('edit_post', $post->ID) ) {
|
139 |
+
$result = $post;
|
140 |
+
break;
|
141 |
+
}
|
142 |
+
}
|
143 |
+
if ( !$result ) { // The fetch did not yield a post editable by user, so query again.
|
144 |
+
$offset += $limit;
|
145 |
+
// Double the limit each time (if haven't found a post yet, chances are we may not, so try to get through posts quicker)
|
146 |
+
$limit += $limit;
|
147 |
+
return $this->query($type, $offset, $limit);
|
148 |
+
}
|
149 |
+
}
|
150 |
+
return $result;
|
151 |
}
|
152 |
|
153 |
function next_post() {
|
readme.txt
CHANGED
@@ -3,9 +3,9 @@ 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 |
-
Stable tag:
|
8 |
-
Version: 1.
|
9 |
|
10 |
Adds links to the next and previous posts when editing a post in the WordPress admin.
|
11 |
|
@@ -15,14 +15,14 @@ Adds links to the next and previous posts when editing a post in the WordPress a
|
|
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
|
26 |
1. Activate the plugin through the 'Plugins' admin menu in WordPress
|
27 |
|
28 |
== Screenshots ==
|
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.8
|
7 |
+
Stable tag: 1.1
|
8 |
+
Version: 1.1
|
9 |
|
10 |
Adds links to the next and previous posts when editing a post in the WordPress admin.
|
11 |
|
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 and which 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.
|
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.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 ==
|