Co-Authors Plus - Version 3.4.92

Version Description

Download this release

Release Info

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

Code changes from version 3.4.91 to 3.4.92

.github/workflows/integrate.yml ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Run PHPUnit and PHPCS
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ test:
7
+ name: WP ${{ matrix.wordpress }} on PHP ${{ matrix.php }}
8
+ runs-on: ubuntu-18.04
9
+ continue-on-error: ${{ matrix.allowed_failure }}
10
+
11
+ env:
12
+ WP_VERSION: ${{ matrix.wordpress }}
13
+
14
+ strategy:
15
+ matrix:
16
+ php: [ '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0' ]
17
+ wordpress: [ '5.5', '5.6', '5.7' ]
18
+ allowed_failure: [ false ]
19
+ include:
20
+ - php: "8.0"
21
+ # Ignore platform requirements, so that PHPUnit 7.5 can be installed on PHP 8.0 (and above).
22
+ composer-options: "--ignore-platform-reqs"
23
+ extensions: pcov
24
+ ini-values: pcov.directory=., "pcov.exclude=\"~(vendor|tests)~\""
25
+ coverage: pcov
26
+ exclude:
27
+ - php: '8.0'
28
+ wordpress: '5.5'
29
+ fail-fast: false
30
+
31
+ steps:
32
+ - name: Checkout code
33
+ uses: actions/checkout@v2
34
+
35
+ - name: Set up PHP ${{ matrix.php }}
36
+ uses: shivammathur/setup-php@v2
37
+ with:
38
+ php-version: ${{ matrix.php }}
39
+ extensions: ${{ matrix.extensions }}
40
+ ini-values: ${{ matrix.ini-values }}
41
+ coverage: ${{ matrix.coverage }}
42
+
43
+ - name: Install Composer dependencies
44
+ uses: ramsey/composer-install@v1
45
+ with:
46
+ composer-options: "${{ matrix.composer-options }}"
47
+
48
+ - name: Setup Problem Matchers for PHPUnit
49
+ run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
50
+
51
+ - name: Show PHP and PHPUnit version info
52
+ run: |
53
+ php --version
54
+ ./vendor/bin/phpunit --version
55
+
56
+ - name: Start MySQL service
57
+ run: sudo /etc/init.d/mysql start
58
+
59
+ - name: Install WordPress environment
60
+ run: composer prepare ${{ matrix.wordpress }}
61
+
62
+ - name: Run integration tests (single site)
63
+ run: composer integration
64
+
65
+ - name: Run integration tests (multisite)
66
+ run: composer integration-ms
67
+
68
+ - name: Run PHPCS
69
+ run: composer cs
70
+
CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
  # Changelog for Co-Authors Plus
2
 
 
 
 
3
  **3.4.91 (Aug 12, 2021)**
4
  * Revert change with #686 regex change #816
5
 
1
  # Changelog for Co-Authors Plus
2
 
3
+ **3.4.92 (Oct 14, 2021)**
4
+ * Fix admin posts view for contributors #823
5
+
6
  **3.4.91 (Aug 12, 2021)**
7
  * Revert change with #686 regex change #816
8
 
README.md CHANGED
@@ -4,7 +4,7 @@
4
  * Tags: authors, users, multiple authors, co-authors, multi-author, publishing
5
  * Tested up to: 5.8
6
  * Requires at least: 4.1
7
- * Stable tag: 3.4.91
8
 
9
  Assign multiple bylines to posts, pages, and custom post types via a search-as-you-type input box
10
 
4
  * Tags: authors, users, multiple authors, co-authors, multi-author, publishing
5
  * Tested up to: 5.8
6
  * Requires at least: 4.1
7
+ * Stable tag: 3.4.92
8
 
9
  Assign multiple bylines to posts, pages, and custom post types via a search-as-you-type input box
10
 
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.91
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.91' );
36
 
37
  require_once dirname( __FILE__ ) . '/template-tags.php';
38
  require_once dirname( __FILE__ ) . '/deprecated.php';
@@ -735,15 +735,17 @@ class CoAuthors_Plus {
735
  $id = '\d+';
736
  }
737
 
738
- // When WordPress generates query as 'post_author IN (id)'.
739
- if ( false !== strpos( $where, "{$wpdb->posts}.post_author IN " ) ) {
740
 
741
- $maybe_both_query = $maybe_both ? '$0 OR' : '';
 
742
 
743
- $where = preg_replace( '/\s\b(?:' . $wpdb->posts . '\.)?post_author\s*IN\s*\(' . $id . '\)/', ' (' . $maybe_both_query . ' ' . $terms_implode . ')', $where, -1 ); // ' . $wpdb->postmeta . '.meta_id IS NOT NULL AND
 
744
 
745
- } else {
746
- $where = preg_replace( '/(\b(?:' . $wpdb->posts . '\.)?post_author\s*=\s*(' . $id . '))/', '(' . $maybe_both_query . ' ' . $terms_implode . ')', $where, -1 ); // ' . $wpdb->postmeta . '.meta_id IS NOT NULL AND
 
747
  }
748
 
749
  // the block targets the private posts clause (if it exists)
@@ -759,7 +761,7 @@ class CoAuthors_Plus {
759
  $current_user_query = $wpdb->term_taxonomy . '.taxonomy = \'' . $this->coauthor_taxonomy . '\' AND ' . $wpdb->term_taxonomy . '.term_id = \'' . $current_coauthor_term->term_id . '\'';
760
  $this->having_terms .= ' ' . $wpdb->term_taxonomy . '.term_id = \'' . $current_coauthor_term->term_id . '\' OR ';
761
 
762
- $where = preg_replace( '/(\b(?:' . $wpdb->posts . '\.)?post_author\s*=\s*(' . get_current_user_id() . ') )/', $current_user_query . ' ', $where, -1 ); // ' . $wpdb->postmeta . '.meta_id IS NOT NULL AND}
763
  }
764
  }
765
 
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.92
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.92' );
36
 
37
  require_once dirname( __FILE__ ) . '/template-tags.php';
38
  require_once dirname( __FILE__ ) . '/deprecated.php';
735
  $id = '\d+';
736
  }
737
 
738
+ $maybe_both_query = $maybe_both ? '$0 OR' : '';
 
739
 
740
+ // add the taxonomy terms to the where query
741
+ $where = preg_replace( '/\(?\b(?:' . $wpdb->posts . '\.)?post_author\s*(?:=|IN)\s*\(?\d+\)?\)?/', ' (' . $maybe_both_query . ' ' . $terms_implode . ')', $where, 1 );
742
 
743
+ // if there is a duplicate post_author query parameter, remove the duplicate
744
+ $where = preg_replace( '/AND\s*\((?:' . $wpdb->posts . '\.)?post_author\s*\=\s*\d+\)/', ' ', $where, 1 );
745
 
746
+ // When WordPress generates query as 'post_author IN (id)', and there is a numeric $id, replace the often errant $id with the correct one - related to https://core.trac.wordpress.org/ticket/54268
747
+ if ( '\d+' !== $id ) {
748
+ $where = preg_replace( '/\b(?:' . $wpdb->posts . '\.)?post_author\s*IN\s*\(\d+\)/', ' (' . $wpdb->posts . '.post_author = ' . $id . ')', $where, 1 );
749
  }
750
 
751
  // the block targets the private posts clause (if it exists)
761
  $current_user_query = $wpdb->term_taxonomy . '.taxonomy = \'' . $this->coauthor_taxonomy . '\' AND ' . $wpdb->term_taxonomy . '.term_id = \'' . $current_coauthor_term->term_id . '\'';
762
  $this->having_terms .= ' ' . $wpdb->term_taxonomy . '.term_id = \'' . $current_coauthor_term->term_id . '\' OR ';
763
 
764
+ $where = preg_replace( '/(\b(?:' . $wpdb->posts . '\.)?post_author\s*=\s*(' . get_current_user_id() . ') )/', $current_user_query . ' ', $where, 1 ); // ' . $wpdb->postmeta . '.meta_id IS NOT NULL AND}
765
  }
766
  }
767
 
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.8
5
  Requires at least: 4.1
6
- Stable tag: 3.4.91
7
 
8
  Assign multiple bylines to posts, pages, and custom post types via a search-as-you-type input box
9
 
3
  Tags: authors, users, multiple authors, coauthors, multi-author, publishing
4
  Tested up to: 5.8
5
  Requires at least: 4.1
6
+ Stable tag: 3.4.92
7
 
8
  Assign multiple bylines to posts, pages, and custom post types via a search-as-you-type input box
9