@automattic/newspack-blocks 4.4.0-alpha.1 → 4.4.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,10 +1,9 @@
1
- # [4.4.0-alpha.1](https://github.com/Automattic/newspack-blocks/compare/v4.3.5...v4.4.0-alpha.1) (2024-11-15)
1
+ # [4.4.0-alpha.2](https://github.com/Automattic/newspack-blocks/compare/v4.4.0-alpha.1...v4.4.0-alpha.2) (2024-11-18)
2
2
 
3
3
 
4
- ### Features
4
+ ### Bug Fixes
5
5
 
6
- * **donate-block:** hide buttons if only one frequency is available ([#1853](https://github.com/Automattic/newspack-blocks/issues/1853)) ([043591e](https://github.com/Automattic/newspack-blocks/commit/043591efef1278575fabeac1bc99000db7a63ed6))
7
- * **homepage-articles:** rename block and reorganise settings ([#1943](https://github.com/Automattic/newspack-blocks/issues/1943)) ([1af11a4](https://github.com/Automattic/newspack-blocks/commit/1af11a45742dd313c2cbe35c9af8da479c9cb569))
6
+ * trigger release with HPP fix ([2c8c1e6](https://github.com/Automattic/newspack-blocks/commit/2c8c1e6030e6a2b0777ee2756bb2d7196f74fca9))
8
7
 
9
8
  ## [4.3.5](https://github.com/Automattic/newspack-blocks/compare/v4.3.4...v4.3.5) (2024-11-11)
10
9
 
@@ -674,19 +674,16 @@ class Newspack_Blocks {
674
674
  }
675
675
  }
676
676
 
677
- $is_co_authors_plus_active = class_exists( 'CoAuthors_Guest_Authors' );
677
+ $is_co_authors_plus_active = class_exists( 'CoAuthors_Plus' );
678
+ $co_authors_guest_authors = class_exists( 'CoAuthors_Guest_Authors' ) ? new CoAuthors_Guest_Authors() : null;
678
679
 
679
680
  if ( $authors && count( $authors ) ) {
680
681
  $co_authors_names = [];
681
- $author_names = [];
682
- $author_emails = [];
683
682
 
684
683
  if ( $is_co_authors_plus_active ) {
685
- $co_authors_guest_authors = new CoAuthors_Guest_Authors();
686
-
687
684
  foreach ( $authors as $index => $author_id ) {
688
685
  // If the given ID is a guest author.
689
- $co_author = $co_authors_guest_authors->get_guest_author_by( 'id', $author_id );
686
+ $co_author = $co_authors_guest_authors ? $co_authors_guest_authors->get_guest_author_by( 'id', $author_id ) : null;
690
687
  if ( $co_author ) {
691
688
  if ( ! empty( $co_author->linked_account ) ) {
692
689
  $linked_account = get_user_by( 'login', $co_author->linked_account );
@@ -697,20 +694,23 @@ class Newspack_Blocks {
697
694
  $co_authors_names[] = $co_author->user_nicename;
698
695
  unset( $authors[ $index ] );
699
696
  } else {
700
- // If the given ID is linked to a guest author.
701
697
  $authors_controller = new WP_REST_Newspack_Authors_Controller();
702
698
  $author_data = get_userdata( $author_id );
703
699
  if ( $author_data ) {
704
700
  $linked_guest_author = $authors_controller->get_linked_guest_author( $author_data->user_login );
701
+ // If the given ID is linked to a guest author.
705
702
  if ( $linked_guest_author ) {
706
703
  $guest_author_name = sanitize_title( $linked_guest_author->post_title );
707
704
  if ( ! in_array( $guest_author_name, $co_authors_names, true ) ) {
708
705
  $co_authors_names[] = $guest_author_name;
706
+ $co_authors_names[] = $linked_guest_author->post_name;
709
707
  unset( $authors[ $index ] );
710
708
  }
711
709
  } else {
712
- $author_names[] = $author_data->user_login;
713
- $author_emails[] = $author_data->user_email;
710
+ $co_authors_names[] = $author_data->user_login;
711
+ $co_authors_names[] = $author_data->user_nicename;
712
+ $co_authors_names[] = 'cap-' . $author_data->user_nicename;
713
+ $co_authors_names[] = $author_data->user_email;
714
714
  }
715
715
  }
716
716
  }
@@ -719,9 +719,16 @@ class Newspack_Blocks {
719
719
 
720
720
  // Reset numeric indexes.
721
721
  $authors = array_values( $authors );
722
+
722
723
  if ( empty( $authors ) && count( $co_authors_names ) ) {
723
- // Look for co-authors posts.
724
+ // We are only looking for Guest Authors posts. So we need to only search by taxonomy.
724
725
  $args['tax_query'] = [ // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
726
+ 'relation' => 'OR',
727
+ [
728
+ 'field' => 'slug',
729
+ 'taxonomy' => 'author',
730
+ 'terms' => $co_authors_names,
731
+ ],
725
732
  [
726
733
  'field' => 'name',
727
734
  'taxonomy' => 'author',
@@ -729,32 +736,11 @@ class Newspack_Blocks {
729
736
  ],
730
737
  ];
731
738
  } elseif ( empty( $co_authors_names ) && count( $authors ) ) {
739
+ // Simple search by author. Co-Authors plus is not active.
732
740
  $args['author__in'] = $authors;
733
-
734
- if ( $is_co_authors_plus_active ) {
735
- // Don't get any posts that are attributed to other CAP guest authors.
736
- $args['tax_query'] = [ // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
737
- [
738
- 'relation' => 'OR',
739
- [
740
- 'taxonomy' => 'author',
741
- 'operator' => 'NOT EXISTS',
742
- ],
743
- [
744
- 'field' => 'name',
745
- 'taxonomy' => 'author',
746
- 'terms' => $author_names,
747
- ],
748
- [
749
- 'field' => 'name',
750
- 'taxonomy' => 'author',
751
- 'terms' => $author_emails,
752
- ],
753
- ],
754
- ];
755
- }
756
741
  } else {
757
742
  // The query contains both WP users and CAP guest authors. We need to filter the SQL query.
743
+ // That's because author__in and tax_query would be combined with AND, not OR.
758
744
  self::$filter_clauses = [
759
745
  'authors' => $authors,
760
746
  'coauthors' => $co_authors_names,
@@ -1254,11 +1240,17 @@ class Newspack_Blocks {
1254
1240
 
1255
1241
  // co-author tax query.
1256
1242
  $tax_query = [
1243
+ 'relation' => 'OR',
1257
1244
  [
1258
1245
  'taxonomy' => 'author',
1259
1246
  'field' => 'name',
1260
1247
  'terms' => $co_authors_names,
1261
1248
  ],
1249
+ [
1250
+ 'taxonomy' => 'author',
1251
+ 'field' => 'slug',
1252
+ 'terms' => $co_authors_names,
1253
+ ],
1262
1254
  ];
1263
1255
 
1264
1256
  // Generate the tax query SQL.
@@ -7,7 +7,7 @@
7
7
  * Author URI: https://newspack.com/
8
8
  * Text Domain: newspack-blocks
9
9
  * Domain Path: /languages
10
- * Version: 4.4.0-alpha.1
10
+ * Version: 4.4.0-alpha.2
11
11
  *
12
12
  * @package Newspack_Blocks
13
13
  */
@@ -15,7 +15,7 @@
15
15
  define( 'NEWSPACK_BLOCKS__PLUGIN_FILE', __FILE__ );
16
16
  define( 'NEWSPACK_BLOCKS__BLOCKS_DIRECTORY', 'dist/' );
17
17
  define( 'NEWSPACK_BLOCKS__PLUGIN_DIR', plugin_dir_path( NEWSPACK_BLOCKS__PLUGIN_FILE ) );
18
- define( 'NEWSPACK_BLOCKS__VERSION', '4.4.0-alpha.1' );
18
+ define( 'NEWSPACK_BLOCKS__VERSION', '4.4.0-alpha.2' );
19
19
 
20
20
  require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-newspack-blocks.php';
21
21
  require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-newspack-blocks-api.php';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/newspack-blocks",
3
- "version": "4.4.0-alpha.1",
3
+ "version": "4.4.0-alpha.2",
4
4
  "author": "Automattic",
5
5
  "devDependencies": {
6
6
  "@rushstack/eslint-patch": "^1.10.4",
@@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
22
22
 
23
23
  require_once __DIR__ . '/composer/autoload_real.php';
24
24
 
25
- return ComposerAutoloaderInit2cf99a59d97a08e424ba39157d0270a1::getLoader();
25
+ return ComposerAutoloaderInit9ce91122910c3bd565085a142c12af0b::getLoader();
@@ -2,7 +2,7 @@
2
2
 
3
3
  // autoload_real.php @generated by Composer
4
4
 
5
- class ComposerAutoloaderInit2cf99a59d97a08e424ba39157d0270a1
5
+ class ComposerAutoloaderInit9ce91122910c3bd565085a142c12af0b
6
6
  {
7
7
  private static $loader;
8
8
 
@@ -22,12 +22,12 @@ class ComposerAutoloaderInit2cf99a59d97a08e424ba39157d0270a1
22
22
  return self::$loader;
23
23
  }
24
24
 
25
- spl_autoload_register(array('ComposerAutoloaderInit2cf99a59d97a08e424ba39157d0270a1', 'loadClassLoader'), true, true);
25
+ spl_autoload_register(array('ComposerAutoloaderInit9ce91122910c3bd565085a142c12af0b', 'loadClassLoader'), true, true);
26
26
  self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
27
- spl_autoload_unregister(array('ComposerAutoloaderInit2cf99a59d97a08e424ba39157d0270a1', 'loadClassLoader'));
27
+ spl_autoload_unregister(array('ComposerAutoloaderInit9ce91122910c3bd565085a142c12af0b', 'loadClassLoader'));
28
28
 
29
29
  require __DIR__ . '/autoload_static.php';
30
- call_user_func(\Composer\Autoload\ComposerStaticInit2cf99a59d97a08e424ba39157d0270a1::getInitializer($loader));
30
+ call_user_func(\Composer\Autoload\ComposerStaticInit9ce91122910c3bd565085a142c12af0b::getInitializer($loader));
31
31
 
32
32
  $loader->register(true);
33
33
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  namespace Composer\Autoload;
6
6
 
7
- class ComposerStaticInit2cf99a59d97a08e424ba39157d0270a1
7
+ class ComposerStaticInit9ce91122910c3bd565085a142c12af0b
8
8
  {
9
9
  public static $classMap = array (
10
10
  'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
@@ -13,7 +13,7 @@ class ComposerStaticInit2cf99a59d97a08e424ba39157d0270a1
13
13
  public static function getInitializer(ClassLoader $loader)
14
14
  {
15
15
  return \Closure::bind(function () use ($loader) {
16
- $loader->classMap = ComposerStaticInit2cf99a59d97a08e424ba39157d0270a1::$classMap;
16
+ $loader->classMap = ComposerStaticInit9ce91122910c3bd565085a142c12af0b::$classMap;
17
17
 
18
18
  }, null, ClassLoader::class);
19
19
  }
@@ -3,7 +3,7 @@
3
3
  'name' => 'automattic/newspack-blocks',
4
4
  'pretty_version' => 'dev-trunk',
5
5
  'version' => 'dev-trunk',
6
- 'reference' => '2d477773224f9e3ddcd38319aa3786870e50db60',
6
+ 'reference' => 'a65c1df33e81153efa79381f8c023275c94ce476',
7
7
  'type' => 'wordpress-plugin',
8
8
  'install_path' => __DIR__ . '/../../',
9
9
  'aliases' => array(),
@@ -13,7 +13,7 @@
13
13
  'automattic/newspack-blocks' => array(
14
14
  'pretty_version' => 'dev-trunk',
15
15
  'version' => 'dev-trunk',
16
- 'reference' => '2d477773224f9e3ddcd38319aa3786870e50db60',
16
+ 'reference' => 'a65c1df33e81153efa79381f8c023275c94ce476',
17
17
  'type' => 'wordpress-plugin',
18
18
  'install_path' => __DIR__ . '/../../',
19
19
  'aliases' => array(),