@automattic/newspack-blocks 2.3.0-alpha.3 → 2.3.0-alpha.4

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,9 +1,16 @@
1
- # [2.3.0-alpha.3](https://github.com/Automattic/newspack-blocks/compare/v2.3.0-alpha.2...v2.3.0-alpha.3) (2023-12-04)
1
+ # [2.3.0-alpha.4](https://github.com/Automattic/newspack-blocks/compare/v2.3.0-alpha.3...v2.3.0-alpha.4) (2023-12-06)
2
2
 
3
3
 
4
4
  ### Bug Fixes
5
5
 
6
- * update selected tier behavior for donate block ([#1617](https://github.com/Automattic/newspack-blocks/issues/1617)) ([8a9a76f](https://github.com/Automattic/newspack-blocks/commit/8a9a76fb970ffac6f00f67f83a17a931a169c103))
6
+ * **homepage-posts:** handle empty block when printing inline styles ([#1621](https://github.com/Automattic/newspack-blocks/issues/1621)) ([c3aa957](https://github.com/Automattic/newspack-blocks/commit/c3aa9577c2284f2139c8fa1170785db9fe4edfe9))
7
+
8
+ ## [2.2.4](https://github.com/Automattic/newspack-blocks/compare/v2.2.3...v2.2.4) (2023-12-06)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **homepage-posts:** handle empty block when printing inline styles ([#1621](https://github.com/Automattic/newspack-blocks/issues/1621)) ([c3aa957](https://github.com/Automattic/newspack-blocks/commit/c3aa9577c2284f2139c8fa1170785db9fe4edfe9))
7
14
 
8
15
  ## [2.2.3](https://github.com/Automattic/newspack-blocks/compare/v2.2.2...v2.2.3) (2023-12-04)
9
16
 
@@ -7,7 +7,7 @@
7
7
  * Author URI: https://newspack.com/
8
8
  * Text Domain: newspack-blocks
9
9
  * Domain Path: /languages
10
- * Version: 2.3.0-alpha.3
10
+ * Version: 2.3.0-alpha.4
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', '2.3.0-alpha.3' );
18
+ define( 'NEWSPACK_BLOCKS__VERSION', '2.3.0-alpha.4' );
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": "2.3.0-alpha.3",
3
+ "version": "2.3.0-alpha.4",
4
4
  "author": "Automattic",
5
5
  "devDependencies": {
6
6
  "@rushstack/eslint-patch": "^1.5.1",
@@ -227,6 +227,10 @@ function newspack_blocks_render_block_homepage_articles( $attributes ) {
227
227
  }
228
228
 
229
229
  $block_name = apply_filters( 'newspack_blocks_block_name', 'newspack-blocks/homepage-articles' );
230
+ $article_query = new WP_Query( Newspack_Blocks::build_articles_query( $attributes, $block_name ) );
231
+ if ( ! $article_query->have_posts() ) {
232
+ return;
233
+ }
230
234
 
231
235
  // Gather all Homepage Articles blocks on the page and output only the needed CSS.
232
236
  // This CSS will be printed along with the first found block markup.
@@ -249,8 +253,6 @@ function newspack_blocks_render_block_homepage_articles( $attributes ) {
249
253
  // This will let the FSE plugin know we need CSS/JS now.
250
254
  do_action( 'newspack_blocks_render_homepage_articles' );
251
255
 
252
- $article_query = new WP_Query( Newspack_Blocks::build_articles_query( $attributes, $block_name ) );
253
-
254
256
  $classes = Newspack_Blocks::block_classes( 'homepage-articles', $attributes, [ 'wpnbha' ] );
255
257
 
256
258
  if ( isset( $attributes['postLayout'] ) && 'grid' === $attributes['postLayout'] ) {
@@ -352,55 +354,53 @@ function newspack_blocks_render_block_homepage_articles( $attributes ) {
352
354
 
353
355
  ob_start();
354
356
 
355
- if ( $article_query->have_posts() ) :
356
- ?>
357
- <div
358
- class="<?php echo esc_attr( $classes ); ?>"
359
- style="<?php echo esc_attr( $styles ); ?>"
360
- >
361
- <?php echo $inline_style_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
362
- <div data-posts data-current-post-id="<?php the_ID(); ?>">
363
- <?php if ( '' !== $attributes['sectionHeader'] ) : ?>
364
- <h2 class="article-section-title">
365
- <span><?php echo wp_kses_post( $attributes['sectionHeader'] ); ?></span>
366
- </h2>
367
- <?php endif; ?>
368
- <?php
369
- echo Newspack_Blocks::template_inc( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
370
- __DIR__ . '/templates/articles-list.php',
371
- [
372
- 'articles_rest_url' => $articles_rest_url, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
373
- 'article_query' => $article_query, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
374
- 'attributes' => $attributes, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
375
- ]
376
- );
377
- ?>
378
- </div>
379
- <?php
380
-
381
- if ( $has_more_button ) :
382
- ?>
383
- <button type="button" class="wp-block-button__link" data-next="<?php echo esc_url( $articles_rest_url ); ?>">
384
- <?php
385
- if ( ! empty( $attributes['moreButtonText'] ) ) {
386
- echo esc_html( $attributes['moreButtonText'] );
387
- } else {
388
- esc_html_e( 'Load more posts', 'newspack-blocks' );
389
- }
390
- ?>
391
- </button>
392
- <p class="loading">
393
- <?php esc_html_e( 'Loading...', 'newspack-blocks' ); ?>
394
- </p>
395
- <p class="error">
396
- <?php esc_html_e( 'Something went wrong. Please refresh the page and/or try again.', 'newspack-blocks' ); ?>
397
- </p>
398
-
357
+ ?>
358
+ <div
359
+ class="<?php echo esc_attr( $classes ); ?>"
360
+ style="<?php echo esc_attr( $styles ); ?>"
361
+ >
362
+ <?php echo $inline_style_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
363
+ <div data-posts data-current-post-id="<?php the_ID(); ?>">
364
+ <?php if ( '' !== $attributes['sectionHeader'] ) : ?>
365
+ <h2 class="article-section-title">
366
+ <span><?php echo wp_kses_post( $attributes['sectionHeader'] ); ?></span>
367
+ </h2>
399
368
  <?php endif; ?>
400
-
369
+ <?php
370
+ echo Newspack_Blocks::template_inc( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
371
+ __DIR__ . '/templates/articles-list.php',
372
+ [
373
+ 'articles_rest_url' => $articles_rest_url, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
374
+ 'article_query' => $article_query, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
375
+ 'attributes' => $attributes, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
376
+ ]
377
+ );
378
+ ?>
401
379
  </div>
402
380
  <?php
403
- endif;
381
+
382
+ if ( $has_more_button ) :
383
+ ?>
384
+ <button type="button" class="wp-block-button__link" data-next="<?php echo esc_url( $articles_rest_url ); ?>">
385
+ <?php
386
+ if ( ! empty( $attributes['moreButtonText'] ) ) {
387
+ echo esc_html( $attributes['moreButtonText'] );
388
+ } else {
389
+ esc_html_e( 'Load more posts', 'newspack-blocks' );
390
+ }
391
+ ?>
392
+ </button>
393
+ <p class="loading">
394
+ <?php esc_html_e( 'Loading...', 'newspack-blocks' ); ?>
395
+ </p>
396
+ <p class="error">
397
+ <?php esc_html_e( 'Something went wrong. Please refresh the page and/or try again.', 'newspack-blocks' ); ?>
398
+ </p>
399
+
400
+ <?php endif; ?>
401
+
402
+ </div>
403
+ <?php
404
404
 
405
405
  $content = ob_get_clean();
406
406
  Newspack_Blocks::enqueue_view_assets( 'homepage-articles' );
@@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
22
22
 
23
23
  require_once __DIR__ . '/composer/autoload_real.php';
24
24
 
25
- return ComposerAutoloaderInit41f247baa9e3dfb7a32ee26fd2d06db2::getLoader();
25
+ return ComposerAutoloaderInitc4d43837b94072ba16fbe4f7df49c2fa::getLoader();
@@ -2,7 +2,7 @@
2
2
 
3
3
  // autoload_real.php @generated by Composer
4
4
 
5
- class ComposerAutoloaderInit41f247baa9e3dfb7a32ee26fd2d06db2
5
+ class ComposerAutoloaderInitc4d43837b94072ba16fbe4f7df49c2fa
6
6
  {
7
7
  private static $loader;
8
8
 
@@ -22,12 +22,12 @@ class ComposerAutoloaderInit41f247baa9e3dfb7a32ee26fd2d06db2
22
22
  return self::$loader;
23
23
  }
24
24
 
25
- spl_autoload_register(array('ComposerAutoloaderInit41f247baa9e3dfb7a32ee26fd2d06db2', 'loadClassLoader'), true, true);
25
+ spl_autoload_register(array('ComposerAutoloaderInitc4d43837b94072ba16fbe4f7df49c2fa', 'loadClassLoader'), true, true);
26
26
  self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
27
- spl_autoload_unregister(array('ComposerAutoloaderInit41f247baa9e3dfb7a32ee26fd2d06db2', 'loadClassLoader'));
27
+ spl_autoload_unregister(array('ComposerAutoloaderInitc4d43837b94072ba16fbe4f7df49c2fa', 'loadClassLoader'));
28
28
 
29
29
  require __DIR__ . '/autoload_static.php';
30
- call_user_func(\Composer\Autoload\ComposerStaticInit41f247baa9e3dfb7a32ee26fd2d06db2::getInitializer($loader));
30
+ call_user_func(\Composer\Autoload\ComposerStaticInitc4d43837b94072ba16fbe4f7df49c2fa::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 ComposerStaticInit41f247baa9e3dfb7a32ee26fd2d06db2
7
+ class ComposerStaticInitc4d43837b94072ba16fbe4f7df49c2fa
8
8
  {
9
9
  public static $classMap = array (
10
10
  'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
@@ -13,7 +13,7 @@ class ComposerStaticInit41f247baa9e3dfb7a32ee26fd2d06db2
13
13
  public static function getInitializer(ClassLoader $loader)
14
14
  {
15
15
  return \Closure::bind(function () use ($loader) {
16
- $loader->classMap = ComposerStaticInit41f247baa9e3dfb7a32ee26fd2d06db2::$classMap;
16
+ $loader->classMap = ComposerStaticInitc4d43837b94072ba16fbe4f7df49c2fa::$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-master',
5
5
  'version' => 'dev-master',
6
- 'reference' => '6c6671dc2033e7f050eb6daf876e3a42dfdd14a9',
6
+ 'reference' => 'aa2771d4163a11c79e163d2028e2156a66a62911',
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-master',
15
15
  'version' => 'dev-master',
16
- 'reference' => '6c6671dc2033e7f050eb6daf876e3a42dfdd14a9',
16
+ 'reference' => 'aa2771d4163a11c79e163d2028e2156a66a62911',
17
17
  'type' => 'wordpress-plugin',
18
18
  'install_path' => __DIR__ . '/../../',
19
19
  'aliases' => array(),