I’ve come up with a fix for this, so if you’re willing to edit about with your copy of the plugin code then here’s some diff patches…
co-authors.php
@@ -329,6 +329,7 @@
function coauthors_modify_post_sidebar(){
global $current_user;
+ global $post;
//if($current_user->has_cap('edit_others_posts')){
print '<script type="text/javascript">';
print 'var coauthors_can_edit_others_posts = ' . ($current_user->has_cap('edit_others_posts') ? 'true' : 'false') . "\n";
@@ -339,6 +340,8 @@
#print 'var coauthors_moveUp_author_label = "' . __('+ Add author', 'co-authors') . '";';
#print 'var coauthors_moveDown_author_label = "' . __('+ Add author', 'co-authors') . '";';
#print 'var coauthors_delete_author_label = "' . __('+ Add author', 'co-authors') . '";';
+ $coauthors_array = get_post_meta($post->ID, '_coauthor', false);
+ print 'var coauthors_saved_authors = [' . (is_array($coauthors_array) ? implode(',', $coauthors_array) : '') . '];';
print '</script>';
//<script type='text/javascript' src='https://new-wineskins.org-beta/wp-includes/js/jquery/jquery.js?ver=1.1.4'></script>
@@ -347,7 +350,7 @@
print '<script type="text/javascript" src="../' . PLUGINDIR . '/co-authors/admin.js"></script>';
//}
}
-add_action('admin_footer', 'coauthors_modify_post_sidebar'); //dbx_post_sidebar,edit_form_advanced
+add_action('admin_footer-post.php', 'coauthors_modify_post_sidebar'); //dbx_post_sidebar,edit_form_advanced
admin.js
@@ -243,6 +243,14 @@
}
});
+ //Fix by af to add in existing saved coauthors
+ jQuery.each(coauthors_saved_authors, function(i, userID) {
+ if (!addedAlready[userID]) {
+ coauthors_add_coauthor(userID);
+ addedAlready[userID] = true;
+ }
+ });
+
//Remove coauthor post meta select option
//jQuery("#metakeyselect option[value='coauthor']").remove();
coauthors_check_first_delete_disabled_state();
If anyone is interested, this bug exists because WordPress stopped printing “hidden” metadata fields (those beginning with underscores) in the “Custom Fields” box, which this plugin relied on to add the extra co-authors to the “Post Author” box. My fix simply prints this information elsewhere with the PHP then processes in accordingly in the JavaScript. Enjoy!