@automattic/newspack-blocks 4.2.3-alpha.1 → 4.2.3

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.
@@ -322,7 +322,7 @@ final class Modal_Checkout {
322
322
  $products = array_keys( self::$products );
323
323
  foreach ( $products as $product_id ) {
324
324
  $product = wc_get_product( $product_id );
325
- if ( ! $product || ! $product->is_type( 'variable' ) ) {
325
+ if ( ! $product->is_type( 'variable' ) ) {
326
326
  continue;
327
327
  }
328
328
  ?>
@@ -210,7 +210,11 @@ class Newspack_Blocks_Caching {
210
210
  return $block_html;
211
211
  }
212
212
 
213
- Newspack_Blocks::enqueue_view_assets( 'homepage-articles' );
213
+ if ( 'newspack-blocks/homepage-articles' === $block_data['blockName'] ) {
214
+ Newspack_Blocks::enqueue_view_assets( 'homepage-articles' );
215
+ } elseif ( 'newspack-blocks/carousel' === $block_data['blockName'] ) {
216
+ Newspack_Blocks::enqueue_view_assets( 'carousel' );
217
+ }
214
218
 
215
219
  return $cached_data['cached_content'];
216
220
  }
@@ -241,7 +241,6 @@ class Newspack_Blocks {
241
241
  'custom_taxonomies' => self::get_custom_taxonomies(),
242
242
  'can_use_name_your_price' => self::can_use_name_your_price(),
243
243
  'tier_amounts_template' => self::get_formatted_amount(),
244
- 'can_use_video_playlist' => self::can_use_video_playlist_block(),
245
244
  ];
246
245
 
247
246
  if ( class_exists( 'WP_REST_Newspack_Author_List_Controller' ) ) {
@@ -1644,29 +1643,5 @@ class Newspack_Blocks {
1644
1643
 
1645
1644
  return $combined_caption;
1646
1645
  }
1647
-
1648
- /**
1649
- * Check if the current site can use the Video Playlist block.
1650
- * If the block doesn't already exist in site content, it won't be registered.
1651
- */
1652
- public static function can_use_video_playlist_block() {
1653
- // Check if the block exists in any content on the site.
1654
- $existing_blocks = new WP_Query(
1655
- [
1656
- 'fields' => 'ids',
1657
- 'post_type' => 'any',
1658
- 'post_status' => 'publish',
1659
- 's' => 'newspack-blocks/youtube-video-playlist',
1660
- 'posts_per_page' => 1,
1661
- ]
1662
- );
1663
-
1664
- // Don't register the block if it's not already on the site.
1665
- if ( 0 < $existing_blocks->found_posts ) {
1666
- return true;
1667
- }
1668
-
1669
- return false;
1670
- }
1671
1646
  }
1672
1647
  Newspack_Blocks::init();
@@ -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.2.3-alpha.1
10
+ * Version: 4.2.3
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.2.3-alpha.1' );
18
+ define( 'NEWSPACK_BLOCKS__VERSION', '4.2.3' );
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,13 +1,13 @@
1
1
  {
2
2
  "name": "@automattic/newspack-blocks",
3
- "version": "4.2.3-alpha.1",
3
+ "version": "4.2.3",
4
4
  "author": "Automattic",
5
5
  "devDependencies": {
6
6
  "@rushstack/eslint-patch": "^1.10.4",
7
7
  "@testing-library/dom": "^10.4.0",
8
8
  "@testing-library/user-event": "^14.5.2",
9
- "@types/lodash": "^4.17.10",
10
- "@wordpress/browserslist-config": "^6.9.0",
9
+ "@types/lodash": "^4.17.7",
10
+ "@wordpress/browserslist-config": "^6.7.0",
11
11
  "eslint": "^8.57.0",
12
12
  "fetch-mock-jest": "^1.5.1",
13
13
  "html-entities": "^2.5.2",
@@ -17,7 +17,7 @@ import { addQueryArgs } from '@wordpress/url';
17
17
  * Internal dependencies
18
18
  */
19
19
  import metadata from './block.json';
20
- import { getBlockQueries, sanitizePostList, recursivelyGetBlocks } from './utils';
20
+ import { getBlockQueries, sanitizePostList } from './utils';
21
21
 
22
22
  const { name } = metadata;
23
23
  export const STORE_NAMESPACE = `newspack-blocks/${ name }`;
@@ -138,7 +138,15 @@ const createFetchPostsSaga = blockNames => {
138
138
 
139
139
  yield put( { type: 'DISABLE_UI' } );
140
140
 
141
- const blocks = recursivelyGetBlocks( getBlocks );
141
+ // Ensure innerBlocks are populated for widget area blocks.
142
+ // See https://github.com/WordPress/gutenberg/issues/32607#issuecomment-890728216.
143
+ const blocks = getBlocks().map( block => {
144
+ const innerBlocks = select( 'core/block-editor' ).getBlocks( block.clientId );
145
+ return {
146
+ ...block,
147
+ innerBlocks,
148
+ };
149
+ } );
142
150
 
143
151
  const blockQueries = getBlockQueries( blocks, blockNames );
144
152
 
@@ -272,23 +272,3 @@ export const postsBlockDispatch = (
272
272
  triggerReflow: isEditorBlock ? dispatch( STORE_NAMESPACE ).reflow : () => undefined,
273
273
  };
274
274
  };
275
-
276
- // Ensure innerBlocks are populated for some blocks (e.g. `widget-area` and `post-content`).
277
- // See https://github.com/WordPress/gutenberg/issues/32607#issuecomment-890728216.
278
- // See https://github.com/Automattic/wp-calypso/issues/91839.
279
- export const recursivelyGetBlocks = (
280
- getBlocks: ( clientId?: string ) => Block[],
281
- blocks: Block[] = getBlocks()
282
- ) => {
283
- return blocks.map( ( block ) => {
284
- let innerBlocks =
285
- block.innerBlocks.length === 0
286
- ? getBlocks( block.clientId )
287
- : block.innerBlocks;
288
- innerBlocks = recursivelyGetBlocks( getBlocks, innerBlocks );
289
- return {
290
- ...block,
291
- innerBlocks,
292
- };
293
- });
294
- };
@@ -1,14 +1,19 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { __, sprintf } from '@wordpress/i18n';
4
+ import { __ } from '@wordpress/i18n';
5
5
  import apiFetch from '@wordpress/api-fetch';
6
6
  import { Component, Fragment } from '@wordpress/element';
7
- import { Notice, Placeholder, Spinner, PanelBody } from '@wordpress/components';
7
+ import { Placeholder, Spinner, PanelBody, RangeControl } from '@wordpress/components';
8
8
  import { InspectorControls } from '@wordpress/block-editor';
9
9
  import { addQueryArgs } from '@wordpress/url';
10
10
  import { decodeEntities } from '@wordpress/html-entities';
11
11
 
12
+ /**
13
+ * Internal dependencies.
14
+ */
15
+ import AutocompleteTokenField from '../../components/autocomplete-tokenfield';
16
+
12
17
  class Edit extends Component {
13
18
  constructor( props ) {
14
19
  super( props );
@@ -170,46 +175,55 @@ class Edit extends Component {
170
175
  } );
171
176
  };
172
177
 
178
+ /**
179
+ * Hide the overlay so users can play the videos.
180
+ */
181
+ hideOverlay() {
182
+ this.setState( { interactive: true } );
183
+ }
184
+
173
185
  /**
174
186
  * Render.
175
187
  */
176
188
  render() {
177
- const { embed, isLoading } = this.state;
178
-
179
- const Warning = () => (
180
- <>
181
- <h2>{ __( 'The YouTube Video Playlist block is deprecated', 'newspack-plugin' ) }</h2>
182
- <p dangerouslySetInnerHTML={ {
183
- __html: sprintf(
184
- // translators: %1$s is the link to Google's help doc on creating YouTube playlists. %2$s is the link to the help doc on embedding playlists.
185
- __( 'Consider using <a href="%1$s">YouTube Playlists</a> instead, which can be <a href="%2$s">embedded</a> into post or page content.', 'newspack-blocks' ),
186
- 'https://support.google.com/youtube/answer/57792',
187
- 'https://support.google.com/youtube/answer/171780'
188
- ),
189
- } } />
190
- </>
191
- )
189
+ const { attributes, setAttributes } = this.props;
190
+ const { categories, videosToShow } = attributes;
191
+ const { embed, isLoading, interactive } = this.state;
192
192
 
193
193
  return (
194
194
  <Fragment>
195
- <div>
196
- { ( isLoading || '' === embed ) && this.renderPlaceholder() }
197
- { ! ( isLoading || '' === embed ) && (
198
- <div className="wpbnbvp-preview">
199
- <div dangerouslySetInnerHTML={ { __html: embed } } />
200
- </div>
201
- ) }
202
- { ! isLoading && (
203
- <div className="wpbnbvp__overlay">
204
- <Warning />
205
- </div>
206
- ) }
207
- </div>
195
+ { ( isLoading || '' === embed ) && this.renderPlaceholder() }
196
+ { ! ( isLoading || '' === embed ) && (
197
+ <div className="wpbnbvp-preview">
198
+ <div dangerouslySetInnerHTML={ { __html: embed } } />
199
+ { ! interactive && (
200
+ // eslint-disable-next-line jsx-a11y/no-static-element-interactions
201
+ <div className="wpbnbvp__overlay" onMouseUp={ () => this.hideOverlay() } />
202
+ ) }
203
+ </div>
204
+ ) }
208
205
  <InspectorControls>
209
206
  <PanelBody title={ __( 'Settings', 'newspack-blocks' ) } initialOpen={ true }>
210
- <Notice status="warning" isDismissible={ false }>
211
- <Warning />
212
- </Notice>
207
+ <Fragment>
208
+ <RangeControl
209
+ className="videosToShow"
210
+ label={ __( 'Videos', 'newspack-blocks' ) }
211
+ help={ __( 'The maximum number of videos to pull from posts.', 'newspack-blocks' ) }
212
+ value={ videosToShow }
213
+ onChange={ _videosToShow => setAttributes( { videosToShow: _videosToShow } ) }
214
+ min={ 1 }
215
+ max={ 30 }
216
+ required
217
+ />
218
+ <AutocompleteTokenField
219
+ key="categories"
220
+ tokens={ categories || [] }
221
+ onChange={ _categories => setAttributes( { categories: _categories } ) }
222
+ fetchSuggestions={ this.fetchCategorySuggestions }
223
+ fetchSavedInfo={ this.fetchSavedCategories }
224
+ label={ __( 'Categories', 'newspack-blocks' ) }
225
+ />
226
+ </Fragment>
213
227
  </PanelBody>
214
228
  </InspectorControls>
215
229
  </Fragment>
@@ -4,6 +4,4 @@
4
4
  import { registerBlockType } from '@wordpress/blocks';
5
5
  import { name, settings } from '.';
6
6
 
7
- if ( window.newspack_blocks_data?.can_use_video_playlist ) {
8
- registerBlockType( `newspack-blocks/${ name }`, settings );
9
- }
7
+ registerBlockType( `newspack-blocks/${ name }`, settings );
@@ -5,17 +5,8 @@
5
5
  * Prevents interaction with the player until the block is focused.
6
6
  */
7
7
  .wpbnbvp__overlay {
8
- align-content: center;
9
- background-color: rgba(255, 255, 255, 0.9);
10
- display: flex;
11
- flex-direction: column;
12
- justify-content: center;
13
- left: 0;
14
- height: 100%;
15
8
  position: absolute;
16
- text-align: center;
17
- top: 0;
18
- width: 100%;
9
+ inset: 0;
19
10
  }
20
11
 
21
12
  .wpbnbvp-preview {
@@ -15,7 +15,7 @@ import edit from './edit';
15
15
  import './editor.scss';
16
16
 
17
17
  export const name = 'youtube-video-playlist';
18
- export const title = __( 'YouTube Video Playlist (DEPRECATED)', 'newspack-blocks' );
18
+ export const title = __( 'YouTube Video Playlist', 'newspack-blocks' );
19
19
 
20
20
  export const icon = (
21
21
  <SVG xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
@@ -23,10 +23,6 @@ function newspack_blocks_render_block_video_playlist( $attributes ) {
23
23
  * Registers the `newspack-blocks/donate` block on server.
24
24
  */
25
25
  function newspack_blocks_register_video_playlist() {
26
- if ( ! Newspack_Blocks::can_use_video_playlist_block() ) {
27
- return;
28
- }
29
-
30
26
  register_block_type(
31
27
  'newspack-blocks/youtube-video-playlist',
32
28
  array(
@@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
22
22
 
23
23
  require_once __DIR__ . '/composer/autoload_real.php';
24
24
 
25
- return ComposerAutoloaderInit1e9d32440a93967bd3f7373626d4d90d::getLoader();
25
+ return ComposerAutoloaderInitc830e3b75b1ee3a7f71194dcf259dfea::getLoader();
@@ -2,7 +2,7 @@
2
2
 
3
3
  // autoload_real.php @generated by Composer
4
4
 
5
- class ComposerAutoloaderInit1e9d32440a93967bd3f7373626d4d90d
5
+ class ComposerAutoloaderInitc830e3b75b1ee3a7f71194dcf259dfea
6
6
  {
7
7
  private static $loader;
8
8
 
@@ -22,12 +22,12 @@ class ComposerAutoloaderInit1e9d32440a93967bd3f7373626d4d90d
22
22
  return self::$loader;
23
23
  }
24
24
 
25
- spl_autoload_register(array('ComposerAutoloaderInit1e9d32440a93967bd3f7373626d4d90d', 'loadClassLoader'), true, true);
25
+ spl_autoload_register(array('ComposerAutoloaderInitc830e3b75b1ee3a7f71194dcf259dfea', 'loadClassLoader'), true, true);
26
26
  self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
27
- spl_autoload_unregister(array('ComposerAutoloaderInit1e9d32440a93967bd3f7373626d4d90d', 'loadClassLoader'));
27
+ spl_autoload_unregister(array('ComposerAutoloaderInitc830e3b75b1ee3a7f71194dcf259dfea', 'loadClassLoader'));
28
28
 
29
29
  require __DIR__ . '/autoload_static.php';
30
- call_user_func(\Composer\Autoload\ComposerStaticInit1e9d32440a93967bd3f7373626d4d90d::getInitializer($loader));
30
+ call_user_func(\Composer\Autoload\ComposerStaticInitc830e3b75b1ee3a7f71194dcf259dfea::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 ComposerStaticInit1e9d32440a93967bd3f7373626d4d90d
7
+ class ComposerStaticInitc830e3b75b1ee3a7f71194dcf259dfea
8
8
  {
9
9
  public static $classMap = array (
10
10
  'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
@@ -13,7 +13,7 @@ class ComposerStaticInit1e9d32440a93967bd3f7373626d4d90d
13
13
  public static function getInitializer(ClassLoader $loader)
14
14
  {
15
15
  return \Closure::bind(function () use ($loader) {
16
- $loader->classMap = ComposerStaticInit1e9d32440a93967bd3f7373626d4d90d::$classMap;
16
+ $loader->classMap = ComposerStaticInitc830e3b75b1ee3a7f71194dcf259dfea::$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' => 'c404843de635c433e022a6267bcf2b46c8d12670',
6
+ 'reference' => '3830350984f8c997dfda57df005a58cc45f7f7d0',
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' => 'c404843de635c433e022a6267bcf2b46c8d12670',
16
+ 'reference' => '3830350984f8c997dfda57df005a58cc45f7f7d0',
17
17
  'type' => 'wordpress-plugin',
18
18
  'install_path' => __DIR__ . '/../../',
19
19
  'aliases' => array(),