Co-Authors Plus - Version 3.4.3

Version Description

  • Added author support to CPT instructions in readme FAQ
  • Added object check for user in coauthors_set_post_author_field()
  • Fix inefficient user query in avatar url hook
  • Fix operand typo in get_guest_author_thumbnail() for adding custom classes
  • Remove hardcoded default avatar and use default option
Download this release

Release Info

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

Code changes from version 3.4.2 to 3.4.3

.gitignore ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ .DS_Store
2
+ .svn
3
+ .idea/
4
+ wpcom-helper.php
.travis.yml ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ language: php
2
+
3
+ matrix:
4
+ include:
5
+ # aliased to a recent 5.6.x version
6
+ - php: "5.6"
7
+ env: WP_VERSION=5.1.1
8
+
9
+ - php: '5.6'
10
+ env:
11
+ - WP_VERSION=latest
12
+ #- SNIFF=1
13
+ - WP_MULTISITE=0
14
+
15
+ - php: '5.6'
16
+ env:
17
+ - WP_VERSION=latest
18
+ #- SNIFF=1
19
+ - WP_MULTISITE=1
20
+
21
+ # aliased to a recent 7.x version
22
+ - php: '7.0'
23
+ env: WP_VERSION=5.1.1
24
+
25
+ - php: '7.0'
26
+ env: WP_VERSION=latest
27
+
28
+ - php: '7.1'
29
+ env: WP_VERSION=5.1.1
30
+
31
+ - php: '7.1'
32
+ env: WP_VERSION=latest
33
+
34
+ before_script:
35
+ # Set up CodeSniffer
36
+ - export PHPCS_DIR=/tmp/phpcs
37
+ - export SNIFFS_DIR=/tmp/sniffs
38
+ # Install CodeSniffer for WordPress Coding Standards checks.
39
+ - if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/squizlabs/PHP_CodeSniffer.git $PHPCS_DIR; fi
40
+ # Install WordPress Coding Standards.
41
+ - if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git $SNIFFS_DIR; fi
42
+ # Install PHP Compatibility sniffs.
43
+ - if [[ "$SNIFF" == "1" ]]; then git clone -b master --depth 1 https://github.com/wimg/PHPCompatibility.git $SNIFFS_DIR/PHPCompatibility; fi
44
+ # Set install path for PHPCS sniffs.
45
+ # @link https://github.com/squizlabs/PHP_CodeSniffer/blob/4237c2fc98cc838730b76ee9cee316f99286a2a7/CodeSniffer.php#L1941
46
+ - if [[ "$SNIFF" == "1" ]]; then $PHPCS_DIR/scripts/phpcs --config-set installed_paths $SNIFFS_DIR; fi
47
+ # After CodeSniffer install you should refresh your path.
48
+ - if [[ "$SNIFF" == "1" ]]; then phpenv rehash; fi
49
+ # Set up unit tests
50
+ - bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
51
+ # Properly handle PHPUnit versions
52
+ - export PATH="$HOME/.composer/vendor/bin:$PATH"
53
+ - |
54
+ if [[ ${TRAVIS_PHP_VERSION:0:3} == "5.6" ]]; then
55
+ composer global require "phpunit/phpunit=4.8.*"
56
+ elif [[ ${TRAVIS_PHP_VERSION:0:2} == "7." && ${WP_VERSION} == "5.1.1" ]]; then
57
+ composer global require "phpunit/phpunit=5.7.*"
58
+ fi
59
+ - |
60
+ if [[ -n $COMPOSER_BIN_DIR && -x $COMPOSER_BIN_DIR/phpunit ]]; then
61
+ $COMPOSER_BIN_DIR/phpunit --version
62
+ else
63
+ phpunit --version
64
+ fi
65
+
66
+ script:
67
+ # Search for PHP syntax errors.
68
+ - find -L . -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l
69
+ # WordPress Coding Standards.
70
+ # @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
71
+ # @link http://pear.php.net/package/PHP_CodeSniffer/
72
+ # -p flag: Show progress of the run.
73
+ # -s flag: Show sniff codes in all reports.
74
+ # -v flag: Print verbose output.
75
+ # -n flag: Do not print warnings. (shortcut for --warning-severity=0)
76
+ # --standard: Use WordPress as the standard.
77
+ # --extensions: Only sniff PHP files.
78
+ - if [[ "$SNIFF" == "1" ]]; then $PHPCS_DIR/scripts/phpcs -p -s -v -n . --standard="WordPress-VIP" --extensions=php; fi
79
+ # Run unit tests
80
+ - |
81
+ if [[ -n $COMPOSER_BIN_DIR && -x $COMPOSER_BIN_DIR/phpunit ]]; then
82
+ $COMPOSER_BIN_DIR/phpunit
83
+ else
84
+ phpunit
85
+ fi
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.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
 
@@ -60,16 +60,24 @@ $ wp --url=example.com co-authors-plus create-terms-for-posts
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
2
 
3
  * Contributors: batmoo, danielbachhuber, automattic
4
  * Tags: authors, users, multiple authors, co-authors, multi-author, publishing
5
+ * Tested up to: 5.4
6
  * Requires at least: 4.1
7
+ * Stable tag: 3.4.3
8
 
9
  Assign multiple bylines to posts, pages, and custom post types via a search-as-you-type input box
10
 
60
 
61
  * How do I use custom post types?
62
 
63
+ 1. To ensure posts with your CPT 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
+ 2. To display the metabox on your CPT, either call `register_post_type()` with `$args['supports']` containing `'author'`, or call `add_post_type_support( 'my_cpt_slug', 'author' );`
71
 
72
  ## Changelog ##
73
 
74
+ **3.4.3**
75
+ * Added author support to CPT instructions in readme FAQ #720
76
+ * Added object check for user in `coauthors_set_post_author_field()` #721
77
+ * Fix inefficient user query in avatar url hook #724
78
+ * Fix operand typo in `get_guest_author_thumbnail()` for adding custom classes #725
79
+ * Remove hardcoded default avatar and use default option #728
80
+
81
  **3.4.2**
82
  * Fix incorrect user avatar being displayed from featured post image #706
83
  * Add check for `filter_get_avatar_url` to ensure valid second parameter #707
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.2
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.2' );
36
 
37
  require_once( dirname( __FILE__ ) . '/template-tags.php' );
38
  require_once( dirname( __FILE__ ) . '/deprecated.php' );
@@ -135,7 +135,7 @@ class CoAuthors_Plus {
135
  add_filter( 'get_the_archive_title', array( $this, 'filter_author_archive_title'), 10, 1 );
136
 
137
  // Filter to display author image if exists instead of avatar
138
- add_filter( 'get_avatar_url', array( $this, 'filter_get_avatar_url' ), 10, 2 );
139
  }
140
 
141
  /**
@@ -382,7 +382,7 @@ class CoAuthors_Plus {
382
  <?php
383
  foreach ( $coauthors as $coauthor ) :
384
  $count++;
385
- $avatar_url = get_avatar_url( $coauthor->ID, array( 'default' => 'gravatar_default' ) );
386
  ?>
387
  <li>
388
  <?php echo get_avatar( $coauthor->ID, $this->gravatar_size ); ?>
@@ -475,6 +475,7 @@ class CoAuthors_Plus {
475
  data-user_email="<?php echo esc_attr( $author->user_email ) ?>"
476
  data-display_name="<?php echo esc_attr( $author->display_name ) ?>"
477
  data-user_login="<?php echo esc_attr( $author->user_login ) ?>"
 
478
  ><?php echo esc_html( $author->display_name ); ?></a><?php echo ( $count < count( $authors ) ) ? ',' : ''; ?>
479
  <?php
480
  $count++;
@@ -816,7 +817,10 @@ class CoAuthors_Plus {
816
  // If it's a guest author and has a linked account, store that information in post_author
817
  // because it'll be the valid user ID
818
  if ( 'guest-author' == $author_data->type && ! empty( $author_data->linked_account ) ) {
819
- $data['post_author'] = get_user_by( 'login', $author_data->linked_account )->ID;
 
 
 
820
  } else if ( 'wpuser' === $author_data->type ) {
821
  $data['post_author'] = $author_data->ID;
822
  }
@@ -1200,7 +1204,7 @@ class CoAuthors_Plus {
1200
  if( empty( $authors ) ) echo apply_filters( 'coauthors_no_matching_authors_message', 'Sorry, no matching authors found.');
1201
 
1202
  foreach ( $authors as $author ) {
1203
- $avatar_url = get_avatar_url( $author->ID, array( 'default' => 'gravatar_default' ) );
1204
  echo esc_html( $author->ID . ' | ' . $author->user_login . ' | ' . $author->display_name . ' | ' . $author->user_email . ' | ' . rawurldecode( $author->user_nicename ) ) . ' | ' . esc_url( $avatar_url ) . "\n";
1205
  }
1206
 
@@ -1734,15 +1738,19 @@ class CoAuthors_Plus {
1734
  *
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;
1746
  }
1747
  }
1748
 
@@ -1900,4 +1908,4 @@ function cap_filter_comment_moderation_email_recipients( $recipients, $comment_i
1900
  function cap_get_coauthor_terms_for_post( $post_id ) {
1901
  global $coauthors_plus;
1902
  return $coauthors_plus->get_coauthor_terms_for_post( $post_id );
1903
- }
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.3
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.3' );
36
 
37
  require_once( dirname( __FILE__ ) . '/template-tags.php' );
38
  require_once( dirname( __FILE__ ) . '/deprecated.php' );
135
  add_filter( 'get_the_archive_title', array( $this, 'filter_author_archive_title'), 10, 1 );
136
 
137
  // Filter to display author image if exists instead of avatar
138
+ add_filter( 'pre_get_avatar_data', array( $this, 'filter_pre_get_avatar_data_url' ), 10, 2 );
139
  }
140
 
141
  /**
382
  <?php
383
  foreach ( $coauthors as $coauthor ) :
384
  $count++;
385
+ $avatar_url = get_avatar_url( $coauthor->ID );
386
  ?>
387
  <li>
388
  <?php echo get_avatar( $coauthor->ID, $this->gravatar_size ); ?>
475
  data-user_email="<?php echo esc_attr( $author->user_email ) ?>"
476
  data-display_name="<?php echo esc_attr( $author->display_name ) ?>"
477
  data-user_login="<?php echo esc_attr( $author->user_login ) ?>"
478
+ data-avatar="<?php echo esc_attr( get_avatar_url( $author->ID ) ) ?>"
479
  ><?php echo esc_html( $author->display_name ); ?></a><?php echo ( $count < count( $authors ) ) ? ',' : ''; ?>
480
  <?php
481
  $count++;
817
  // If it's a guest author and has a linked account, store that information in post_author
818
  // because it'll be the valid user ID
819
  if ( 'guest-author' == $author_data->type && ! empty( $author_data->linked_account ) ) {
820
+ $user = get_user_by( 'login', $author_data->linked_account );
821
+ if ( is_object( $user ) ) {
822
+ $data['post_author'] = $user->ID;
823
+ }
824
  } else if ( 'wpuser' === $author_data->type ) {
825
  $data['post_author'] = $author_data->ID;
826
  }
1204
  if( empty( $authors ) ) echo apply_filters( 'coauthors_no_matching_authors_message', 'Sorry, no matching authors found.');
1205
 
1206
  foreach ( $authors as $author ) {
1207
+ $avatar_url = get_avatar_url( $author->ID );
1208
  echo esc_html( $author->ID . ' | ' . $author->user_login . ' | ' . $author->display_name . ' | ' . $author->user_email . ' | ' . rawurldecode( $author->user_nicename ) ) . ' | ' . esc_url( $avatar_url ) . "\n";
1209
  }
1210
 
1738
  *
1739
  * @return string Avatar URL
1740
  */
1741
+ public function filter_pre_get_avatar_data_url( $args, $id ) {
1742
+ if ( ! $id || ! $this->is_guest_authors_enabled() || ! is_numeric( $id ) || isset( $args['url'] ) ) {
1743
+ return $args;
1744
  }
1745
  $coauthor = $this->get_coauthor_by( 'id', $id );
1746
+ if ( false !== $coauthor && isset( $coauthor->type ) && 'guest-author' === $coauthor->type ) {
1747
+ if ( has_post_thumbnail( $id ) ) {
1748
+ $args['url'] = get_the_post_thumbnail_url( $id, $this->gravatar_size );
1749
+ } else {
1750
+ $args['url'] = get_avatar_url( '' ); // Fallback to default.
1751
+ }
1752
  }
1753
+ return $args;
1754
  }
1755
  }
1756
 
1908
  function cap_get_coauthor_terms_for_post( $post_id ) {
1909
  global $coauthors_plus;
1910
  return $coauthors_plus->get_coauthor_terms_for_post( $post_id );
1911
+ }
js/co-authors-plus.js CHANGED
@@ -420,9 +420,11 @@ jQuery( document ).ready(function () {
420
  login: jQuery( el ).data( 'user_login' ),
421
  name: jQuery( el ).data( 'display_name' ),
422
  email: jQuery( el ).data( 'user_email' ),
423
- nicename: jQuery( el ).data( 'user_nicename' )
 
424
  }
425
- })
 
426
  coauthors_initialize( post_coauthors );
427
 
428
  }
420
  login: jQuery( el ).data( 'user_login' ),
421
  name: jQuery( el ).data( 'display_name' ),
422
  email: jQuery( el ).data( 'user_email' ),
423
+ nicename: jQuery( el ).data( 'user_nicename' ),
424
+ avatar: jQuery( el ).data( 'avatar' ),
425
  }
426
+ });
427
+
428
  coauthors_initialize( post_coauthors );
429
 
430
  }
php/class-coauthors-guest-authors.php CHANGED
@@ -970,13 +970,13 @@ class CoAuthors_Guest_Authors
970
  }
971
 
972
  $args = array(
973
- 'class' => "avatar avatar-{$size} photo",
974
- );
975
  if ( ! empty( $class ) ) {
976
  if ( is_array( $class ) ) {
977
  $class = implode( ' ', $class );
978
  }
979
- $args['class'] += " $class";
980
  }
981
 
982
  $size = array( $size, $size );
970
  }
971
 
972
  $args = array(
973
+ 'class' => "avatar avatar-{$size} photo",
974
+ );
975
  if ( ! empty( $class ) ) {
976
  if ( is_array( $class ) ) {
977
  $class = implode( ' ', $class );
978
  }
979
+ $args['class'] .= " $class";
980
  }
981
 
982
  $size = array( $size, $size );
readme.txt CHANGED
@@ -3,7 +3,7 @@ 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,6 +62,13 @@ Bug fixes and minor enhancements
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
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.3
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.3 =
66
+ * Added author support to CPT instructions in readme FAQ
67
+ * Added object check for user in `coauthors_set_post_author_field()`
68
+ * Fix inefficient user query in avatar url hook
69
+ * Fix operand typo in `get_guest_author_thumbnail()` for adding custom classes
70
+ * Remove hardcoded default avatar and use default option
71
+
72
  = 3.4.2 =
73
  * Fix incorrect user avatar being displayed from featured post image
74
  * Add check for `filter_get_avatar_url` to ensure valid second parameter