@automattic/newspack-blocks 4.2.2 → 4.2.3-alpha.1
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 +9 -0
- package/dist/editor-rtl.css +1 -1
- package/dist/editor.asset.php +1 -1
- package/dist/editor.css +1 -1
- package/dist/editor.js +15 -12
- package/includes/class-modal-checkout.php +1 -1
- package/includes/class-newspack-blocks.php +25 -0
- package/newspack-blocks.php +2 -2
- package/package.json +3 -3
- package/src/blocks/homepage-articles/store.js +2 -10
- package/src/blocks/homepage-articles/utils.ts +20 -0
- package/src/blocks/video-playlist/edit.js +33 -47
- package/src/blocks/video-playlist/editor.js +3 -1
- package/src/blocks/video-playlist/editor.scss +10 -1
- package/src/blocks/video-playlist/index.js +1 -1
- package/src/blocks/video-playlist/view.php +4 -0
- package/vendor/autoload.php +1 -1
- package/vendor/composer/autoload_real.php +4 -4
- package/vendor/composer/autoload_static.php +2 -2
- package/vendor/composer/installed.php +2 -2
|
@@ -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->is_type( 'variable' ) ) {
|
|
325
|
+
if ( ! $product || ! $product->is_type( 'variable' ) ) {
|
|
326
326
|
continue;
|
|
327
327
|
}
|
|
328
328
|
?>
|
|
@@ -241,6 +241,7 @@ 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(),
|
|
244
245
|
];
|
|
245
246
|
|
|
246
247
|
if ( class_exists( 'WP_REST_Newspack_Author_List_Controller' ) ) {
|
|
@@ -1643,5 +1644,29 @@ class Newspack_Blocks {
|
|
|
1643
1644
|
|
|
1644
1645
|
return $combined_caption;
|
|
1645
1646
|
}
|
|
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
|
+
}
|
|
1646
1671
|
}
|
|
1647
1672
|
Newspack_Blocks::init();
|
package/newspack-blocks.php
CHANGED
|
@@ -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.
|
|
10
|
+
* Version: 4.2.3-alpha.1
|
|
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.
|
|
18
|
+
define( 'NEWSPACK_BLOCKS__VERSION', '4.2.3-alpha.1' );
|
|
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
|
+
"version": "4.2.3-alpha.1",
|
|
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
|
-
"@wordpress/browserslist-config": "^6.
|
|
9
|
+
"@types/lodash": "^4.17.10",
|
|
10
|
+
"@wordpress/browserslist-config": "^6.9.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 } from './utils';
|
|
20
|
+
import { getBlockQueries, sanitizePostList, recursivelyGetBlocks } from './utils';
|
|
21
21
|
|
|
22
22
|
const { name } = metadata;
|
|
23
23
|
export const STORE_NAMESPACE = `newspack-blocks/${ name }`;
|
|
@@ -138,15 +138,7 @@ const createFetchPostsSaga = blockNames => {
|
|
|
138
138
|
|
|
139
139
|
yield put( { type: 'DISABLE_UI' } );
|
|
140
140
|
|
|
141
|
-
|
|
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
|
-
} );
|
|
141
|
+
const blocks = recursivelyGetBlocks( getBlocks );
|
|
150
142
|
|
|
151
143
|
const blockQueries = getBlockQueries( blocks, blockNames );
|
|
152
144
|
|
|
@@ -272,3 +272,23 @@ 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,19 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { __ } from '@wordpress/i18n';
|
|
4
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
5
5
|
import apiFetch from '@wordpress/api-fetch';
|
|
6
6
|
import { Component, Fragment } from '@wordpress/element';
|
|
7
|
-
import { Placeholder, Spinner, PanelBody
|
|
7
|
+
import { Notice, Placeholder, Spinner, PanelBody } 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
|
-
|
|
17
12
|
class Edit extends Component {
|
|
18
13
|
constructor( props ) {
|
|
19
14
|
super( props );
|
|
@@ -175,55 +170,46 @@ class Edit extends Component {
|
|
|
175
170
|
} );
|
|
176
171
|
};
|
|
177
172
|
|
|
178
|
-
/**
|
|
179
|
-
* Hide the overlay so users can play the videos.
|
|
180
|
-
*/
|
|
181
|
-
hideOverlay() {
|
|
182
|
-
this.setState( { interactive: true } );
|
|
183
|
-
}
|
|
184
|
-
|
|
185
173
|
/**
|
|
186
174
|
* Render.
|
|
187
175
|
*/
|
|
188
176
|
render() {
|
|
189
|
-
const {
|
|
190
|
-
|
|
191
|
-
const
|
|
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
|
+
)
|
|
192
192
|
|
|
193
193
|
return (
|
|
194
194
|
<Fragment>
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
<div
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
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>
|
|
205
208
|
<InspectorControls>
|
|
206
209
|
<PanelBody title={ __( 'Settings', 'newspack-blocks' ) } initialOpen={ true }>
|
|
207
|
-
<
|
|
208
|
-
<
|
|
209
|
-
|
|
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>
|
|
210
|
+
<Notice status="warning" isDismissible={ false }>
|
|
211
|
+
<Warning />
|
|
212
|
+
</Notice>
|
|
227
213
|
</PanelBody>
|
|
228
214
|
</InspectorControls>
|
|
229
215
|
</Fragment>
|
|
@@ -4,4 +4,6 @@
|
|
|
4
4
|
import { registerBlockType } from '@wordpress/blocks';
|
|
5
5
|
import { name, settings } from '.';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
if ( window.newspack_blocks_data?.can_use_video_playlist ) {
|
|
8
|
+
registerBlockType( `newspack-blocks/${ name }`, settings );
|
|
9
|
+
}
|
|
@@ -5,8 +5,17 @@
|
|
|
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%;
|
|
8
15
|
position: absolute;
|
|
9
|
-
|
|
16
|
+
text-align: center;
|
|
17
|
+
top: 0;
|
|
18
|
+
width: 100%;
|
|
10
19
|
}
|
|
11
20
|
|
|
12
21
|
.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', 'newspack-blocks' );
|
|
18
|
+
export const title = __( 'YouTube Video Playlist (DEPRECATED)', '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,6 +23,10 @@ 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
|
+
|
|
26
30
|
register_block_type(
|
|
27
31
|
'newspack-blocks/youtube-video-playlist',
|
|
28
32
|
array(
|
package/vendor/autoload.php
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// autoload_real.php @generated by Composer
|
|
4
4
|
|
|
5
|
-
class
|
|
5
|
+
class ComposerAutoloaderInit1e9d32440a93967bd3f7373626d4d90d
|
|
6
6
|
{
|
|
7
7
|
private static $loader;
|
|
8
8
|
|
|
@@ -22,12 +22,12 @@ class ComposerAutoloaderInit0bb7139426d46ba9e60aab1249f589e1
|
|
|
22
22
|
return self::$loader;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
spl_autoload_register(array('
|
|
25
|
+
spl_autoload_register(array('ComposerAutoloaderInit1e9d32440a93967bd3f7373626d4d90d', 'loadClassLoader'), true, true);
|
|
26
26
|
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
|
|
27
|
-
spl_autoload_unregister(array('
|
|
27
|
+
spl_autoload_unregister(array('ComposerAutoloaderInit1e9d32440a93967bd3f7373626d4d90d', 'loadClassLoader'));
|
|
28
28
|
|
|
29
29
|
require __DIR__ . '/autoload_static.php';
|
|
30
|
-
call_user_func(\Composer\Autoload\
|
|
30
|
+
call_user_func(\Composer\Autoload\ComposerStaticInit1e9d32440a93967bd3f7373626d4d90d::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
|
|
7
|
+
class ComposerStaticInit1e9d32440a93967bd3f7373626d4d90d
|
|
8
8
|
{
|
|
9
9
|
public static $classMap = array (
|
|
10
10
|
'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
|
|
@@ -13,7 +13,7 @@ class ComposerStaticInit0bb7139426d46ba9e60aab1249f589e1
|
|
|
13
13
|
public static function getInitializer(ClassLoader $loader)
|
|
14
14
|
{
|
|
15
15
|
return \Closure::bind(function () use ($loader) {
|
|
16
|
-
$loader->classMap =
|
|
16
|
+
$loader->classMap = ComposerStaticInit1e9d32440a93967bd3f7373626d4d90d::$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' => '
|
|
6
|
+
'reference' => 'c404843de635c433e022a6267bcf2b46c8d12670',
|
|
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' => '
|
|
16
|
+
'reference' => 'c404843de635c433e022a6267bcf2b46c8d12670',
|
|
17
17
|
'type' => 'wordpress-plugin',
|
|
18
18
|
'install_path' => __DIR__ . '/../../',
|
|
19
19
|
'aliases' => array(),
|