Co-Authors Plus - Version 1.1.5

Version Description

Download this release

Release Info

Developer batmoo
Plugin Icon wp plugin Co-Authors Plus
Version 1.1.5
Comparing to
See all releases

Code changes from version 1.1.4 to 1.1.5

Files changed (4) hide show
  1. admin.js +73 -16
  2. co-authors.php +10 -1
  3. readme.txt +29 -9
  4. suggest.php +14 -10
admin.js CHANGED
@@ -4,11 +4,12 @@
4
var coauthors_table = null;
5
6
var coauthorsTable = jQuery('#coauthors-table');
7
- var editing = false;
8
9
/*
10
* Get an author's name from their ID
11
* Iterates through the coauthors-select input box until finds the entry with the associated ID
12
*
13
*/
14
function coauthors_get_author_name( authorID ) {
@@ -30,7 +31,11 @@ function coauthors_get_author_name( authorID ) {
30
31
}
32
33
-
34
function coauthors_select_author( authorID, selectID ) {
35
if(!selectID) selectID = '#coauthors-select';
36
@@ -48,6 +53,10 @@ function coauthors_select_author( authorID, selectID ) {
48
49
}
50
51
function coauthors_remove_author( authorName ) {
52
var select = jQuery('#coauthors-select');
53
if(authorName){
@@ -61,11 +70,18 @@ function coauthors_remove_author( authorName ) {
61
}
62
}
63
64
- // Old function not needed; though may be useful for duplicate validation
65
var coauthors_select_onchange = function(event){
66
67
};
68
69
var coauthors_delete_onclick = function(event){
70
71
if(confirm('Are you sure you want to delete this author?')) {
@@ -79,6 +95,10 @@ var coauthors_delete_onclick = function(event){
79
return false;
80
};
81
82
function coauthors_insert_author_edit_cells(tr){
83
84
var deleteBtn = jQuery('<span></span>')
@@ -96,6 +116,12 @@ function coauthors_insert_author_edit_cells(tr){
96
97
}
98
99
function coauthors_save_coauthor(authorID, authorName, co) {
100
101
coauthors_remove_author(co.next().text());
@@ -112,19 +138,28 @@ function coauthors_save_coauthor(authorID, authorName, co) {
112
coauthors_select_author( authorID )
113
}
114
115
- editing = false;
116
}
117
118
119
-
120
function coauthors_add_coauthor(authorID, authorName, co, init){
121
var selectedIndex = -1;
122
123
- if(editing) {
124
coauthors_save_coauthor(authorID, authorName, co)
125
126
} else {
127
128
if(!co) var co = coauthors_create_autosuggest(authorName)
129
var tag = coauthors_create_author_tag(authorName);
130
@@ -152,6 +187,12 @@ function coauthors_add_coauthor(authorID, authorName, co, init){
152
}
153
154
155
function coauthors_add_to_table( co, tag, del ) {
156
if(co) {
157
var td = jQuery('<td></td>');
@@ -168,6 +209,11 @@ function coauthors_add_to_table( co, tag, del ) {
168
}
169
}
170
171
function coauthors_create_autosuggest(authorName, inputName) {
172
173
if(!inputName) inputName = 'coauthors2[]';
@@ -213,7 +259,12 @@ function coauthors_create_autosuggest(authorName, inputName) {
213
214
}
215
216
function coauthors_stop_editing(event) {
217
var co = jQuery(event.target);
218
var tag = jQuery(co.next());
219
@@ -221,9 +272,14 @@ function coauthors_stop_editing(event) {
221
222
co.hide();
223
tag.show();
224
- editing = false;
225
}
226
227
function coauthors_create_author_tag (name) {
228
var tag = jQuery('<span></span>')
229
.html(name)
@@ -231,8 +287,8 @@ function coauthors_create_author_tag (name) {
231
.addClass('author-tag')
232
// Add Click event to edit
233
.click(function(){
234
- if(!editing) {
235
- editing = true;
236
237
var co = tag.prev();
238
@@ -242,7 +298,7 @@ function coauthors_create_author_tag (name) {
242
;
243
244
co.previousAuthor = tag.text();
245
- }
246
247
});
248
@@ -251,12 +307,14 @@ function coauthors_create_author_tag (name) {
251
252
253
if(document.getElementById('post_author_override')){
254
if(!coauthors_can_edit_others_posts){
255
jQuery('#authordiv, #pageauthordiv').remove();
256
return;
257
}
258
259
- //Note that there can be co-authors (changes dbx title from "Post Author" to "Post Author(s)")
260
var h3 = jQuery('#authordiv :header, #pageauthordiv :header').html(
261
/page[^\/]+#x2F;.test(window.location.href) ?
262
coauthors_dbx_page_title
@@ -264,7 +322,7 @@ if(document.getElementById('post_author_override')){
264
coauthors_dbx_post_title
265
);
266
267
- //Add the controls to add co-authors
268
var div = jQuery('#authordiv div, #pageauthordiv div').filter(function(){
269
if(jQuery(this).is('.inside') || jQuery(this).is('.dbx-content'))
270
return true;
@@ -272,20 +330,19 @@ if(document.getElementById('post_author_override')){
272
})[0];
273
274
if(div){
275
-
276
var table = jQuery('<table></table>')
277
.attr('id', 'coauthors-table')
278
;
279
-
280
var coauthors_table = jQuery('<tbody></tbody>')
281
.appendTo(table)
282
;
283
-
284
var tr = jQuery('<tr></tr>');
285
var td = jQuery('<td></td>')
286
.addClass('select')
287
;
288
-
289
var select = jQuery('#post_author_override')[0];
290
291
td.append(select);
4
var coauthors_table = null;
5
6
var coauthorsTable = jQuery('#coauthors-table');
7
+ //var editing = false;
8
9
/*
10
* Get an author's name from their ID
11
* Iterates through the coauthors-select input box until finds the entry with the associated ID
12
+ * @param int User ID
13
*
14
*/
15
function coauthors_get_author_name( authorID ) {
31
32
}
33
34
+ /*
35
+ * Selects author (specified by authorID) within the appropriate select box (specified by selectID)
36
+ * @param int
37
+ * @param string ID of the select box
38
+ */
39
function coauthors_select_author( authorID, selectID ) {
40
if(!selectID) selectID = '#coauthors-select';
41
53
54
}
55
56
+ /*
57
+ * Unselects author
58
+ * @param string Name of the Author to remove
59
+ */
60
function coauthors_remove_author( authorName ) {
61
var select = jQuery('#coauthors-select');
62
if(authorName){
70
}
71
}
72
73
+ /*
74
+ * Old function not needed; though may be useful for duplicate validation
75
+ * @param event
76
+ */
77
var coauthors_select_onchange = function(event){
78
79
};
80
81
+ /*
82
+ * Click handler for the delete button
83
+ * @param event
84
+ */
85
var coauthors_delete_onclick = function(event){
86
87
if(confirm('Are you sure you want to delete this author?')) {
95
return false;
96
};
97
98
+ /*
99
+ * Adds a delete button next to an author
100
+ * @param object The row to which the new author should be added
101
+ */
102
function coauthors_insert_author_edit_cells(tr){
103
104
var deleteBtn = jQuery('<span></span>')
116
117
}
118
119
+ /*
120
+ * Save coauthor
121
+ * @param int Author ID
122
+ * @param string Author Name
123
+ * @param object The autosuggest input box
124
+ */
125
function coauthors_save_coauthor(authorID, authorName, co) {
126
127
coauthors_remove_author(co.next().text());
138
coauthors_select_author( authorID )
139
}
140
141
+ // editing = false;
142
}
143
144
145
+ /*
146
+ * Add coauthor
147
+ * @param int Author ID
148
+ * @param string Author Name
149
+ * @param object The autosuggest input box
150
+ * @param boolean Initial set up or not?
151
+ */
152
function coauthors_add_coauthor(authorID, authorName, co, init){
153
var selectedIndex = -1;
154
155
+ // Check if editing
156
+ if(co && co.next().attr('class')=='author-tag') {
157
coauthors_save_coauthor(authorID, authorName, co)
158
159
} else {
160
+ // Not editing, so we create a new author entry
161
162
+ // Create autosuggest box and text tag
163
if(!co) var co = coauthors_create_autosuggest(authorName)
164
var tag = coauthors_create_author_tag(authorName);
165
187
}
188
189
190
+ /*
191
+ * Add the autosuggest box and text tag to the Co-Authors table
192
+ * @param object Autosuggest input box
193
+ * @param object Text tag
194
+ * @param
195
+ */
196
function coauthors_add_to_table( co, tag, del ) {
197
if(co) {
198
var td = jQuery('<td></td>');
209
}
210
}
211
212
+ /*
213
+ * Creates autosuggest input box
214
+ * @param string [optional] Name of the author
215
+ * @param string [optional] Name to be applied to the input box
216
+ */
217
function coauthors_create_autosuggest(authorName, inputName) {
218
219
if(!inputName) inputName = 'coauthors2[]';
259
260
}
261
262
+ /*
263
+ * Blur handler for autosuggest input box
264
+ * @param event
265
+ */
266
function coauthors_stop_editing(event) {
267
+
268
var co = jQuery(event.target);
269
var tag = jQuery(co.next());
270
272
273
co.hide();
274
tag.show();
275
+
276
+ // editing = false;
277
}
278
279
+ /*
280
+ * Creates the text tag for an author
281
+ * @param string Name of the author
282
+ */
283
function coauthors_create_author_tag (name) {
284
var tag = jQuery('<span></span>')
285
.html(name)
287
.addClass('author-tag')
288
// Add Click event to edit
289
.click(function(){
290
+ //if(!editing) {
291
+ //editing = true;
292
293
var co = tag.prev();
294
298
;
299
300
co.previousAuthor = tag.text();
301
+ //}
302
303
});
304
307
308
309
if(document.getElementById('post_author_override')){
310
+
311
+ // Check if user has permissions to change post authors; if not, remove controls and end
312
if(!coauthors_can_edit_others_posts){
313
jQuery('#authordiv, #pageauthordiv').remove();
314
return;
315
}
316
317
+ // Changes the meta_box title from "Post Author" to "Post Author(s)"
318
var h3 = jQuery('#authordiv :header, #pageauthordiv :header').html(
319
/page[^\/]+#x2F;.test(window.location.href) ?
320
coauthors_dbx_page_title
322
coauthors_dbx_post_title
323
);
324
325
+ // Add the controls to add co-authors
326
var div = jQuery('#authordiv div, #pageauthordiv div').filter(function(){
327
if(jQuery(this).is('.inside') || jQuery(this).is('.dbx-content'))
328
return true;
330
})[0];
331
332
if(div){
333
+
334
+ // Create the co-authors table
335
var table = jQuery('<table></table>')
336
.attr('id', 'coauthors-table')
337
;
338
var coauthors_table = jQuery('<tbody></tbody>')
339
.appendTo(table)
340
;
341
var tr = jQuery('<tr></tr>');
342
var td = jQuery('<td></td>')
343
.addClass('select')
344
;
345
+
346
var select = jQuery('#post_author_override')[0];
347
348
td.append(select);
co-authors.php CHANGED
@@ -3,7 +3,7 @@
3
Plugin Name: Co-Authors Plus
4
Plugin URI: http://wordpress.org/extend/plugins/co-authors-plus/
5
Description: Allows multiple authors to be assigned to a post. Co-authored posts appear on a co-author's posts page and feed. New template tags allow listing of co-authors. Editors may assign co-authors to a post via the 'Post Author' box. <em>This plugin is an extended version of the Co-Authors plugin originally developed at [Shepherd Interactive](http://www.shepherd-interactive.com/ "Shepherd Interactive specializes in web design and development in Portland, Oregon") (2007). Their plugin was inspired by 'Multiple Authors' plugin by Mark Jaquith (2005).</em>
6
- Version: 1.1.4
7
Author: Mohammad Jangda
8
Author URI: http://digitalize.ca
9
Copyright: Some parts (C) 2009, Mohammad; Other parts (C) 2008, Weston Ruter, Shepherd Interactive
@@ -26,6 +26,13 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
27
## Change Log ##
28
29
*2009-04-25 / 1.1.4*
30
31
* Disabled "New Author" output in suggest box
@@ -48,6 +55,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
48
49
*2009-04-14: 1.1.0*
50
51
@@ To do @@
52
- Setting to enable/disable co-authors for Pages
53
- Check Cross-browser compatibility
3
Plugin Name: Co-Authors Plus
4
Plugin URI: http://wordpress.org/extend/plugins/co-authors-plus/
5
Description: Allows multiple authors to be assigned to a post. Co-authored posts appear on a co-author's posts page and feed. New template tags allow listing of co-authors. Editors may assign co-authors to a post via the 'Post Author' box. <em>This plugin is an extended version of the Co-Authors plugin originally developed at [Shepherd Interactive](http://www.shepherd-interactive.com/ "Shepherd Interactive specializes in web design and development in Portland, Oregon") (2007). Their plugin was inspired by 'Multiple Authors' plugin by Mark Jaquith (2005).</em>
6
+ Version: 1.1.5
7
Author: Mohammad Jangda
8
Author URI: http://digitalize.ca
9
Copyright: Some parts (C) 2009, Mohammad; Other parts (C) 2008, Weston Ruter, Shepherd Interactive
26
27
## Change Log ##
28
29
+ *2009-04-26 / 1.1.5*
30
+
31
+ * Bug fix: Not searching Updated SQL query for autosuggest to search through first name, last name, and nickname
32
+ * Bug fix: When editing an author, and clicking on a suggested author, the original author was not be removed
33
+ * Docs: Added code comments to javascript; more still to be added
34
+ * Docs: Updated readme information
35
+
36
*2009-04-25 / 1.1.4*
37
38
* Disabled "New Author" output in suggest box
55
56
*2009-04-14: 1.1.0*
57
58
+ * First beta release
59
+
60
@@ To do @@
61
- Setting to enable/disable co-authors for Pages
62
- Check Cross-browser compatibility
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
- === Co-Authors-Plus ===
2
Contributors: batmoo
3
Donate link: http://digitalize.ca/donate
4
Tags: authors, users
5
Tested up to: 2.7.1
6
Requires at least: 2.6
7
- Stable tag: 1.1.4
8
9
Allows multiple authors to be assigned to a Post or Page via search-as-you-type input boxes.
10
@@ -12,15 +12,23 @@ Allows multiple authors to be assigned to a Post or Page via search-as-you-type
12
13
> **IMPORTANT: If you are upgrading from 1.1.3, please delete the plugin from your plugins directory and reinstall!**
14
15
- Allows multiple authors to be assigned to a Post or Page. Co-authored posts appear on a co-author's posts page and feed. New template tags allow listing of co-authors. Editors may assign co-authors to a post via the search-as-you-type inputs in the 'Post Author(s)' box. Additionally, co-authors may edit the posts they are associated with, and co-authors who are contributors may only edit posts if they have not been published (as is usual). Co-authored posts appear on a co-author's posts page and feed.
16
17
This plugin is an extended version of the Co-Authors plugin originally developed at [Shepherd Interactive](http://www.shepherd-interactive.com/ "Shepherd Interactive specializes in web design and development in Portland, Oregon") (2007). Their plugin was inspired by 'Multiple Authors' plugin by Mark Jaquith (2005).
18
19
The extended version is created by Mohammad Jangda, and incorporates search-as-you-type functionality for adding users, which aims to make easy the task of adding multiple users to posts and pages, especially when dealing with a system with hundreds of users (typical of newspaper and magazine sites).
20
21
22
= Changelog =
23
24
*2009-04-25 / 1.1.4*
25
26
* Disabled "New Author" output in suggest box, for now
@@ -43,16 +51,25 @@ The extended version is created by Mohammad Jangda, and incorporates search-as-y
43
44
*2009-04-14: 1.1.0*
45
46
- * Initial release.
47
48
49
== Installation ==
50
51
- 1. IMPORTANT: Please disable the original co-authors plugin before installing Co-Authors Plus
52
1. Extract the coauthors-plus.zip file and upload its contents to the `/wp-content/plugins/` directory. Alternatively you can install directly from the Plugin directory within your WordPress Install.
53
1. Activate the plugin through the 'Plugins' menu in WordPress.
54
1. Place the appropriate coauthors template tags in your template.
55
- 1. Add coauthors to your posts and pages.
56
57
58
== Template Tags ==
@@ -111,17 +128,20 @@ For example:
111
}
112
113
114
-
115
== Frequently Asked Questions ==
116
117
= When will the "New Author" function be added? =
118
119
Hopefully soon.
120
121
= What happens to posts and pages when I delete a user assigned to a post or page as a coauthor? =
122
123
- When a user is deleted from WordPress, they will be removed from all of posts for which they are co-authors, and if a replacement user is provided, their co-authored posts will instead be co-attributed to another user.
124
125
== Screenshots ==
126
1. "Post Author(s)" box with multiple authors added
127
- 2. Search-as-you-type input box that looks up authors as you type in their name.
1
+ === Co-Authors Plus ===
2
Contributors: batmoo
3
Donate link: http://digitalize.ca/donate
4
Tags: authors, users
5
Tested up to: 2.7.1
6
Requires at least: 2.6
7
+ Stable tag: 1.1.5
8
9
Allows multiple authors to be assigned to a Post or Page via search-as-you-type input boxes.
10
12
13
> **IMPORTANT: If you are upgrading from 1.1.3, please delete the plugin from your plugins directory and reinstall!**
14
15
+ Allows multiple authors to be assigned to a Post or Page via the search-as-you-type inputs. Co-authored posts appear on a co-author's posts page and feed. New template tags allow listing of co-authors. Editors and Administrators may assign co-authors to a post. Additionally, co-authors may edit the posts they are associated with, and co-authors who are contributors may only edit posts if they have not been published (as is usual).
16
17
This plugin is an extended version of the Co-Authors plugin originally developed at [Shepherd Interactive](http://www.shepherd-interactive.com/ "Shepherd Interactive specializes in web design and development in Portland, Oregon") (2007). Their plugin was inspired by 'Multiple Authors' plugin by Mark Jaquith (2005).
18
19
The extended version is created by Mohammad Jangda, and incorporates search-as-you-type functionality for adding users, which aims to make easy the task of adding multiple users to posts and pages, especially when dealing with a system with hundreds of users (typical of newspaper and magazine sites).
20
21
+ > *See "Other Notes" section for Template Tags and usage information
22
23
= Changelog =
24
25
+ *2009-04-26 / 1.1.5*
26
+
27
+ * Bug fix: Not searching Updated SQL query for autosuggest to search through first name, last name, and nickname
28
+ * Bug fix: When editing an author, and clicking on a suggested author, the original author was not be removed
29
+ * Docs: Added code comments to javascript; more still to be added
30
+ * Docs: Updated readme information
31
+
32
*2009-04-25 / 1.1.4*
33
34
* Disabled "New Author" output in suggest box, for now
51
52
*2009-04-14: 1.1.0*
53
54
+ * Initial beta release.
55
56
57
== Installation ==
58
59
+ 1. IMPORTANT: Please disable the original Co-Authors plugin (if you are using it) before installing Co-Authors Plus
60
1. Extract the coauthors-plus.zip file and upload its contents to the `/wp-content/plugins/` directory. Alternatively you can install directly from the Plugin directory within your WordPress Install.
61
1. Activate the plugin through the 'Plugins' menu in WordPress.
62
1. Place the appropriate coauthors template tags in your template.
63
+ 1. Add co-authors to your posts and pages.
64
+
65
+
66
+ == Basic Usage and Other Notes ==
67
+
68
+ *Only Author-level and above can be added as co-authors. Namely, contributers cannot be added as co-authors.
69
+ *As per WordPress design, only Editor-level and above users can change Post Authors. Authors cannot change authors or add co-authors (yet)
70
+ *As per WordPress design, when an editor creates a new Post or Page, they are by default added as an author. However, they can changed by clicking on their name and typing in the name of the new author.
71
+ *The search-as-you-type box starts searching once two letters have been added, and executes a new search with every subsequent letter.
72
+ *The search-as-you-type box searches through the following user fields: a) user_login; b) user_nicename; c) display_name; d) user_email; e) first_name; f) last_name; and g) nickname.
73
74
75
== Template Tags ==
128
}
129
130
131
== Frequently Asked Questions ==
132
133
+ = What�s the main difference between Co-Authors and Co-Authors Plus? =
134
+
135
+ The most notable difference is the replacement of the standard WordPress authors drop-downs with search-as-you-type/auto-suggest/whatever-you-call-them input boxes. As a result, major bits of the JavaScript code was changed to be more jQuery-friendly. Eventually, I hope to include the ability to add new Users from within the Edit Post/Page screen and possibly Gravatar support.
136
+
137
= When will the "New Author" function be added? =
138
139
Hopefully soon.
140
141
= What happens to posts and pages when I delete a user assigned to a post or page as a coauthor? =
142
143
+ When a user is deleted from WordPress, they will be removed from all of posts for which they are co-authors.
144
145
== Screenshots ==
146
1. "Post Author(s)" box with multiple authors added
147
+ 2. Search-as-you-type input box that looks up authors as you type in their name. Fields displayed are: ID, Display Name, and Email.
suggest.php CHANGED
@@ -43,16 +43,17 @@ function coauthors_ajax_suggest() {
43
$q = '%'.strtolower($_REQUEST["q"]).'%';
44
if (!$q) return;
45
46
- //
47
- $authors_query = $wpdb->prepare("SELECT ID, display_name, user_email
48
- FROM $wpdb->users
49
- WHERE ID = ANY (SELECT user_id FROM $wpdb->usermeta WHERE meta_key = 'wp_user_level' AND meta_value >= 1)
50
- AND (user_login LIKE %s
51
- OR user_nicename LIKE %s
52
- OR display_name LIKE %s
53
- OR user_email LIKE %s)",$q,$q,$q,$q
54
- );
55
-
56
$authors = $wpdb->get_results($authors_query, ARRAY_A);
57
58
if(is_array($authors)) {
@@ -60,7 +61,10 @@ function coauthors_ajax_suggest() {
60
61
echo $author['ID']." | ". $author['display_name'] ." | ".$author['user_email'] ."\n";
62
}
63
}
64
//echo "New | Add new author: ".trim($q,'%')."\n";
65
}
66
43
$q = '%'.strtolower($_REQUEST["q"]).'%';
44
if (!$q) return;
45
46
+ // Prepare search query
47
+ $authors_query = $wpdb->prepare("SELECT DISTINCT u.ID, u.display_name, u.user_email FROM $wpdb->users AS u
48
+ INNER JOIN $wpdb->usermeta AS um ON u.ID = um.user_id
49
+ WHERE ID = ANY (SELECT user_id FROM $wpdb->usermeta WHERE meta_key = 'wp_user_level' AND meta_value >= 1)
50
+ AND (um.meta_key = 'first_name' OR um.meta_key = 'last_name' OR um.meta_key = 'nickname')
51
+ AND (u.user_login LIKE %s
52
+ OR u.user_nicename LIKE %s
53
+ OR u.display_name LIKE %s
54
+ OR u.user_email LIKE %s
55
+ OR um.meta_value LIKE %s)",$q,$q,$q,$q,$q);
56
+
57
$authors = $wpdb->get_results($authors_query, ARRAY_A);
58
59
if(is_array($authors)) {
61
62
echo $author['ID']." | ". $author['display_name'] ." | ".$author['user_email'] ."\n";
63
}
64
+ } else {
65
+
66
}
67
+ // Return output to create new author
68
//echo "New | Add new author: ".trim($q,'%')."\n";
69
}
70