Co-Authors Plus - Version 3.4.2

Version Description

  • Fix incorrect user avatar being displayed from featured post image
  • Add check for filter_get_avatar_url to ensure valid second parameter
  • add_coauthors() accepts ID parameter now and ensures valid term slug used
  • filter_count_user_posts checks that user ID returns valid user object
  • Added post count instructions in readme FAQ for CPTs
Download this release

Release Info

Developer automattic
Plugin Icon wp plugin Co-Authors Plus
Version 3.4.2
Comparing to
See all releases

Code changes from version 3.4 to 3.4.2

Makefile CHANGED
File without changes
README.md CHANGED
@@ -2,9 +2,9 @@
2
 
3
  * Contributors: batmoo, danielbachhuber, automattic
4
  * Tags: authors, users, multiple authors, co-authors, multi-author, publishing
5
- * Tested up to: 5.1.1
6
  * Requires at least: 4.1
7
- * Stable tag: 3.4
8
 
9
  Assign multiple bylines to posts, pages, and custom post types via a search-as-you-type input box
10
 
@@ -46,7 +46,7 @@ Yep! There's a template tag called `coauthors_wp_list_authors()` that accepts ma
46
 
47
  If the site has a large database, you may run into issues with heavier than usual queries. You can work around this by disabling compat mode and force it to use simpler, tax-only queries by adding the following to your theme:
48
 
49
- ```
50
  // Use simple tax queries for CAP to improve performance
51
  add_filter( 'coauthors_plus_should_query_post_author', '__return_false' );
52
  ```
@@ -58,8 +58,28 @@ Note that this requires the site(s) to have proper terms set up for all users. Y
58
  $ wp --url=example.com co-authors-plus create-terms-for-posts
59
  ```
60
 
 
 
 
 
 
 
 
 
 
 
61
  ## Changelog ##
62
 
 
 
 
 
 
 
 
 
 
 
63
  **3.4**
64
  * New filter `get_coauthors` for modifying coauthor data returned in `get_coauthors()` #646
65
  * New filter `coauthors_guest_authors_exported_extra_data` to allow guest author to export data as regular author #528
@@ -78,7 +98,7 @@ $ wp --url=example.com co-authors-plus create-terms-for-posts
78
  * Have `filter_author_archive_title()` run on author archives only #535
79
  * Improve tests coverage (#529, #540, #546, #576 and #569)
80
  * Change `posts_selection` to action from filter #563
81
- * Fix number of args expected for `get_the_archive_title` callback #657
82
  * Fix spelling, update FAQ for disabling guest authors and credits in readme (#656, #523 and #501)
83
  * Output `coauthors_links_single()` template tag correctly when guest author has no website #504
84
  * Number by "Mine" link shows correct listing of posts #663
@@ -90,7 +110,7 @@ $ wp --url=example.com co-authors-plus create-terms-for-posts
90
  * Fix SQL error (#593 and #628)
91
  * Fix "Mine" link href for Pages #547
92
  * Can delete users when guest authors functionality disabled #602
93
- * Fix incompatibility issue with Yoast of missing posts in author pages #624
94
  * Resolve undefined index warnings on author archives #521
95
  * Resolve warnings when current user has no term assigned #517
96
 
2
 
3
  * Contributors: batmoo, danielbachhuber, automattic
4
  * Tags: authors, users, multiple authors, co-authors, multi-author, publishing
5
+ * Tested up to: 5.3.1
6
  * Requires at least: 4.1
7
+ * Stable tag: 3.4.2
8
 
9
  Assign multiple bylines to posts, pages, and custom post types via a search-as-you-type input box
10
 
46
 
47
  If the site has a large database, you may run into issues with heavier than usual queries. You can work around this by disabling compat mode and force it to use simpler, tax-only queries by adding the following to your theme:
48
 
49
+ ```php
50
  // Use simple tax queries for CAP to improve performance
51
  add_filter( 'coauthors_plus_should_query_post_author', '__return_false' );
52
  ```
58
  $ wp --url=example.com co-authors-plus create-terms-for-posts
59
  ```
60
 
61
+ * How do I use custom post types?
62
+
63
+ To ensure posts with CPTs are counted, use the `coauthors_count_published_post_types` filter.
64
+ ```php
65
+ add_filter( 'coauthors_count_published_post_types', function( $post_types ) {
66
+ $post_types[] = 'my_cpt_slug';
67
+ return $post_types;
68
+ } );
69
+ ```
70
+
71
  ## Changelog ##
72
 
73
+ **3.4.2**
74
+ * Fix incorrect user avatar being displayed from featured post image #706
75
+ * Add check for `filter_get_avatar_url` to ensure valid second parameter #707
76
+ * `add_coauthors()` accepts ID parameter now #685 and ensures valid term slug used #708
77
+ * `filter_count_user_posts` checks that user ID returns valid user object #714
78
+ * Added post count instructions in readme FAQ for CPTs #713
79
+
80
+ **3.4.1**
81
+ * Fix an issue that may arise in bulk edit #700
82
+
83
  **3.4**
84
  * New filter `get_coauthors` for modifying coauthor data returned in `get_coauthors()` #646
85
  * New filter `coauthors_guest_authors_exported_extra_data` to allow guest author to export data as regular author #528
98
  * Have `filter_author_archive_title()` run on author archives only #535
99
  * Improve tests coverage (#529, #540, #546, #576 and #569)
100
  * Change `posts_selection` to action from filter #563
101
+ * Fix number of args expected for `get_the_archive_title` callback #657
102
  * Fix spelling, update FAQ for disabling guest authors and credits in readme (#656, #523 and #501)
103
  * Output `coauthors_links_single()` template tag correctly when guest author has no website #504
104
  * Number by "Mine" link shows correct listing of posts #663
110
  * Fix SQL error (#593 and #628)
111
  * Fix "Mine" link href for Pages #547
112
  * Can delete users when guest authors functionality disabled #602
113
+ * Fix incompatibility issue with Yoast of missing posts in author pages #624
114
  * Resolve undefined index warnings on author archives #521
115
  * Resolve warnings when current user has no term assigned #517
116
 
co-authors-plus.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. This plugin is an extended version of the Co-Authors plugin developed by Weston Ruter.
6
- Version: 3.4
7
  Author: Mohammad Jangda, Daniel Bachhuber, Automattic
8
  Copyright: 2008-2015 Shared and distributed between Mohammad Jangda, Daniel Bachhuber, Weston Ruter
9
 
@@ -32,7 +32,7 @@ Co-author - in the context of a single post, a guest author or user assigned to
32
  Author - user with the role of author
33
  */
34
 
35
- define( 'COAUTHORS_PLUS_VERSION', '3.4' );
36
 
37
  require_once( dirname( __FILE__ ) . '/template-tags.php' );
38
  require_once( dirname( __FILE__ ) . '/deprecated.php' );
@@ -881,8 +881,9 @@ class CoAuthors_Plus {
881
  * @param int
882
  * @param array
883
  * @param bool
 
884
  */
885
- public function add_coauthors( $post_id, $coauthors, $append = false ) {
886
  global $current_user, $wpdb;
887
 
888
  $post_id = (int) $post_id;
@@ -890,7 +891,8 @@ class CoAuthors_Plus {
890
 
891
  // Best way to persist order
892
  if ( $append ) {
893
- $existing_coauthors = wp_list_pluck( get_coauthors( $post_id ), 'user_login' );
 
894
  } else {
895
  $existing_coauthors = array();
896
  }
@@ -909,11 +911,13 @@ class CoAuthors_Plus {
909
  $coauthors = array_unique( array_merge( $existing_coauthors, $coauthors ) );
910
  $coauthor_objects = array();
911
  foreach ( $coauthors as &$author_name ) {
912
-
913
- $author = $this->get_coauthor_by( 'user_nicename', $author_name );
914
  $coauthor_objects[] = $author;
915
  $term = $this->update_author_term( $author );
916
- $author_name = $term->slug;
 
 
917
  }
918
  wp_set_post_terms( $post_id, $coauthors, $this->coauthor_taxonomy, false );
919
 
@@ -1014,6 +1018,9 @@ class CoAuthors_Plus {
1014
  case 'tt_ids' :
1015
  $terms[] = $author->term_taxonomy_id;
1016
  break;
 
 
 
1017
  case 'all' :
1018
  default :
1019
  $terms[] = get_term( $author->term_id, $this->coauthor_taxonomy );
@@ -1037,16 +1044,19 @@ class CoAuthors_Plus {
1037
  */
1038
  function filter_count_user_posts( $count, $user_id ) {
1039
  $user = get_userdata( $user_id );
1040
- $user = $this->get_coauthor_by( 'user_nicename', $user->user_nicename );
1041
 
1042
- $term = $this->get_author_term( $user );
 
1043
 
1044
- if ( $term && ! is_wp_error( $term ) ) {
1045
- if ( 'guest-author' === $user->type ) {
1046
- // If using guest author term count, add on linked user count.
1047
- $count = (int) $count + $term->count;
1048
- } else {
1049
- $count = $term->count;
 
 
 
1050
  }
1051
  }
1052
 
@@ -1254,7 +1264,7 @@ class CoAuthors_Plus {
1254
  $ignored_authors = apply_filters( 'coauthors_edit_ignored_authors', $ignored_authors );
1255
  foreach ( $found_users as $key => $found_user ) {
1256
  // Make sure the user is contributor and above (or a custom cap)
1257
- if ( in_array( $found_user->user_nicename, $ignored_authors ) ) { //AJAX sends a list of already present *users_nicenames*
1258
  unset( $found_users[ $key ] );
1259
  } else if ( 'wpuser' === $found_user->type && false === $found_user->has_cap( apply_filters( 'coauthors_edit_author_cap', 'edit_posts' ) ) ) {
1260
  unset( $found_users[ $key ] );
@@ -1696,7 +1706,7 @@ class CoAuthors_Plus {
1696
  */
1697
  public function get_guest_author_post_count( $guest_author ) {
1698
  if ( ! is_object( $guest_author ) ) {
1699
- return;
1700
  }
1701
 
1702
  $term = $this->get_author_term( $guest_author );
@@ -1705,16 +1715,19 @@ class CoAuthors_Plus {
1705
  if ( is_object( $guest_term )
1706
  && ! empty( $guest_author->linked_account )
1707
  && $guest_term->count ) {
1708
- return count_user_posts( get_user_by( 'login', $guest_author->linked_account )->ID );
 
 
 
1709
  } elseif ( $term ) {
1710
  return $term->count;
1711
- } else {
1712
- return 0;
1713
  }
 
 
1714
  }
1715
-
1716
  /**
1717
- * Filter to display author image if exists instead of avatar.
1718
  *
1719
  * @param $url string Avatar URL
1720
  * @param $id int Author ID
@@ -1722,7 +1735,11 @@ class CoAuthors_Plus {
1722
  * @return string Avatar URL
1723
  */
1724
  public function filter_get_avatar_url( $url, $id ) {
1725
- if ( has_post_thumbnail( $id ) ) {
 
 
 
 
1726
  $url = get_the_post_thumbnail_url( $id, $this->gravatar_size );
1727
  }
1728
  return $url;
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. This plugin is an extended version of the Co-Authors plugin developed by Weston Ruter.
6
+ Version: 3.4.2
7
  Author: Mohammad Jangda, Daniel Bachhuber, Automattic
8
  Copyright: 2008-2015 Shared and distributed between Mohammad Jangda, Daniel Bachhuber, Weston Ruter
9
 
32
  Author - user with the role of author
33
  */
34
 
35
+ define( 'COAUTHORS_PLUS_VERSION', '3.4.2' );
36
 
37
  require_once( dirname( __FILE__ ) . '/template-tags.php' );
38
  require_once( dirname( __FILE__ ) . '/deprecated.php' );
881
  * @param int
882
  * @param array
883
  * @param bool
884
+ * @param string
885
  */
886
+ public function add_coauthors( $post_id, $coauthors, $append = false, $query_type = 'user_nicename' ) {
887
  global $current_user, $wpdb;
888
 
889
  $post_id = (int) $post_id;
891
 
892
  // Best way to persist order
893
  if ( $append ) {
894
+ $field = apply_filters( 'coauthors_post_list_pluck_field', 'user_login' );
895
+ $existing_coauthors = wp_list_pluck( get_coauthors( $post_id ), $field );
896
  } else {
897
  $existing_coauthors = array();
898
  }
911
  $coauthors = array_unique( array_merge( $existing_coauthors, $coauthors ) );
912
  $coauthor_objects = array();
913
  foreach ( $coauthors as &$author_name ) {
914
+ $field = apply_filters( 'coauthors_post_get_coauthor_by_field', $query_type, $author_name );
915
+ $author = $this->get_coauthor_by( $field, $author_name );
916
  $coauthor_objects[] = $author;
917
  $term = $this->update_author_term( $author );
918
+ if ( is_object( $term ) ) {
919
+ $author_name = $term->slug;
920
+ }
921
  }
922
  wp_set_post_terms( $post_id, $coauthors, $this->coauthor_taxonomy, false );
923
 
1018
  case 'tt_ids' :
1019
  $terms[] = $author->term_taxonomy_id;
1020
  break;
1021
+ case 'ids':
1022
+ $terms[] = (int) $author->term_id;
1023
+ break;
1024
  case 'all' :
1025
  default :
1026
  $terms[] = get_term( $author->term_id, $this->coauthor_taxonomy );
1044
  */
1045
  function filter_count_user_posts( $count, $user_id ) {
1046
  $user = get_userdata( $user_id );
 
1047
 
1048
+ if ( is_object( $user ) ) {
1049
+ $user = $this->get_coauthor_by( 'user_nicename', $user->user_nicename );
1050
 
1051
+ $term = $this->get_author_term( $user );
1052
+
1053
+ if ( $term && ! is_wp_error( $term ) ) {
1054
+ if ( 'guest-author' === $user->type ) {
1055
+ // If using guest author term count, add on linked user count.
1056
+ $count = (int) $count + $term->count;
1057
+ } else {
1058
+ $count = $term->count;
1059
+ }
1060
  }
1061
  }
1062
 
1264
  $ignored_authors = apply_filters( 'coauthors_edit_ignored_authors', $ignored_authors );
1265
  foreach ( $found_users as $key => $found_user ) {
1266
  // Make sure the user is contributor and above (or a custom cap)
1267
+ if ( in_array( $found_user->user_nicename, $ignored_authors, true ) ) { // AJAX sends a list of already present *users_nicenames*
1268
  unset( $found_users[ $key ] );
1269
  } else if ( 'wpuser' === $found_user->type && false === $found_user->has_cap( apply_filters( 'coauthors_edit_author_cap', 'edit_posts' ) ) ) {
1270
  unset( $found_users[ $key ] );
1706
  */
1707
  public function get_guest_author_post_count( $guest_author ) {
1708
  if ( ! is_object( $guest_author ) ) {
1709
+ return 0;
1710
  }
1711
 
1712
  $term = $this->get_author_term( $guest_author );
1715
  if ( is_object( $guest_term )
1716
  && ! empty( $guest_author->linked_account )
1717
  && $guest_term->count ) {
1718
+ $user = get_user_by( 'login', $guest_author->linked_account );
1719
+ if ( is_object( $user ) ) {
1720
+ return count_user_posts( $user->ID );
1721
+ }
1722
  } elseif ( $term ) {
1723
  return $term->count;
 
 
1724
  }
1725
+
1726
+ return 0;
1727
  }
1728
+
1729
  /**
1730
+ * Filter to display author image if exists instead of avatar.
1731
  *
1732
  * @param $url string Avatar URL
1733
  * @param $id int Author ID
1735
  * @return string Avatar URL
1736
  */
1737
  public function filter_get_avatar_url( $url, $id ) {
1738
+ if ( ! $id || ! $this->is_guest_authors_enabled() || ! is_numeric( $id ) ) {
1739
+ return $url;
1740
+ }
1741
+ $coauthor = $this->get_coauthor_by( 'id', $id );
1742
+ if ( false !== $coauthor && isset( $coauthor->type ) && 'guest-author' === $coauthor->type && has_post_thumbnail( $id ) ) {
1743
  $url = get_the_post_thumbnail_url( $id, $this->gravatar_size );
1744
  }
1745
  return $url;
composer.json CHANGED
File without changes
css/co-authors-plus.css CHANGED
File without changes
css/guest-authors.css CHANGED
File without changes
deprecated.php CHANGED
File without changes
js/guest-authors.js CHANGED
File without changes
languages/co-authors-plus-de_DE.mo CHANGED
File without changes
languages/co-authors-plus-de_DE.po CHANGED
File without changes
languages/co-authors-plus-nl_NL.mo CHANGED
File without changes
languages/co-authors-plus-nl_NL.po CHANGED
File without changes
languages/co-authors-plus-sv_SE.mo CHANGED
File without changes
languages/co-authors-plus-sv_SE.po CHANGED
File without changes
lib/select2/select2.css CHANGED
File without changes
lib/select2/select2.min.js CHANGED
File without changes
lib/select2/select2.png CHANGED
File without changes
lib/select2/select2x2.png CHANGED
File without changes
lib/select2/spinner.gif CHANGED
File without changes
php/class-coauthors-guest-authors.php CHANGED
File without changes
php/class-coauthors-template-filters.php CHANGED
File without changes
php/class-wp-cli.php CHANGED
File without changes
php/integrations/amp.php CHANGED
File without changes
php/integrations/amp/meta-author.php CHANGED
File without changes
phpunit.xml CHANGED
File without changes
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Co-Authors Plus ===
2
  Contributors: batmoo, danielbachhuber, automattic
3
  Tags: authors, users, multiple authors, coauthors, multi-author, publishing
4
- Tested up to: 5.1.1
5
  Requires at least: 4.1
6
- Stable tag: 3.4
7
 
8
  Assign multiple bylines to posts, pages, and custom post types via a search-as-you-type input box
9
 
@@ -62,6 +62,16 @@ Bug fixes and minor enhancements
62
 
63
  == Changelog ==
64
 
 
 
 
 
 
 
 
 
 
 
65
  = 3.4 =
66
  * New filter get_coauthors for modifying coauthor data returned in get_coauthors()
67
  * New filter coauthors_guest_authors_exported_extra_data to allow guest author to export data as regular author
1
  === Co-Authors Plus ===
2
  Contributors: batmoo, danielbachhuber, automattic
3
  Tags: authors, users, multiple authors, coauthors, multi-author, publishing
4
+ Tested up to: 5.3.1
5
  Requires at least: 4.1
6
+ Stable tag: 3.4.2
7
 
8
  Assign multiple bylines to posts, pages, and custom post types via a search-as-you-type input box
9
 
62
 
63
  == Changelog ==
64
 
65
+ = 3.4.2 =
66
+ * Fix incorrect user avatar being displayed from featured post image
67
+ * Add check for `filter_get_avatar_url` to ensure valid second parameter
68
+ * `add_coauthors()` accepts ID parameter now and ensures valid term slug used
69
+ * `filter_count_user_posts` checks that user ID returns valid user object
70
+ * Added post count instructions in readme FAQ for CPTs
71
+
72
+ = 3.4.1 =
73
+ * Fix an issue that may arise in bulk edit
74
+
75
  = 3.4 =
76
  * New filter get_coauthors for modifying coauthor data returned in get_coauthors()
77
  * New filter coauthors_guest_authors_exported_extra_data to allow guest author to export data as regular author
screenshot-1.png CHANGED
File without changes
screenshot-2.png CHANGED
File without changes
screenshot-3.png CHANGED
File without changes
template-tags.php CHANGED
File without changes
tests/bootstrap.php CHANGED
File without changes
tests/coauthorsplus-testcase.php CHANGED
File without changes
tests/test-author-queried-object.php CHANGED
File without changes
tests/test-author-queries.php CHANGED
File without changes
tests/test-coauthors-guest-authors.php CHANGED
File without changes
tests/test-coauthors-plus.php CHANGED
File without changes
tests/test-manage-coauthors.php CHANGED
File without changes
tests/test-template-tags.php CHANGED
File without changes
upgrade.php CHANGED
File without changes