@automattic/newspack-blocks 4.26.7 → 4.26.8
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,3 +1,10 @@
|
|
|
1
|
+
## @automattic/newspack-blocks [4.26.8](https://github.com/Automattic/newspack-workspace/compare/newspack-blocks@4.26.7...newspack-blocks@4.26.8) (2026-07-02)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **blocks:** restrict articles endpoint to viewable post types ([cde3e84](https://github.com/Automattic/newspack-workspace/commit/cde3e84ebf2c8e653f085560799f32c69bd75a36))
|
|
7
|
+
|
|
1
8
|
## @automattic/newspack-blocks [4.26.7](https://github.com/Automattic/newspack-workspace/compare/newspack-blocks@4.26.6...newspack-blocks@4.26.7) (2026-06-30)
|
|
2
9
|
|
|
3
10
|
|
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.26.
|
|
10
|
+
* Version: 4.26.8
|
|
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.26.
|
|
18
|
+
define( 'NEWSPACK_BLOCKS__VERSION', '4.26.8' );
|
|
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.26.
|
|
3
|
+
"version": "4.26.8",
|
|
4
4
|
"author": "Automattic",
|
|
5
5
|
"description": "=== Newspack Blocks === Contributors: (this should be a list of wordpress.org userid's) Donate link: https://example.com/ Tags: comments, spam Requires at least: 4.5 Tested up to: 5.1.1 Stable tag: 0.1.0 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html",
|
|
6
6
|
"repository": {
|
|
@@ -129,6 +129,15 @@ class WP_REST_Newspack_Articles_Controller extends WP_REST_Controller {
|
|
|
129
129
|
$exclude_ids = [];
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
// This endpoint is public, so restrict it to publicly viewable post types — matching
|
|
133
|
+
// what WordPress exposes on the front end. The editor endpoints are capability-gated.
|
|
134
|
+
$attributes['postType'] = self::filter_viewable_post_types( $attributes['postType'] );
|
|
135
|
+
if ( empty( $attributes['postType'] ) ) {
|
|
136
|
+
// Every requested post type was non-viewable; return nothing rather than
|
|
137
|
+
// substituting a different post type.
|
|
138
|
+
return self::articles_response();
|
|
139
|
+
}
|
|
140
|
+
|
|
132
141
|
$article_query_args = Newspack_Blocks::build_articles_query( $attributes, apply_filters( 'newspack_blocks_block_name', 'newspack-blocks/homepage-articles' ) );
|
|
133
142
|
|
|
134
143
|
// If using exclude_ids, don't worry about pagination. Just get the next postsToShow number of results without the excluded posts. Otherwise, use standard WP pagination.
|
|
@@ -192,15 +201,41 @@ class WP_REST_Newspack_Articles_Controller extends WP_REST_Controller {
|
|
|
192
201
|
);
|
|
193
202
|
}
|
|
194
203
|
|
|
204
|
+
return self::articles_response( $items, $ids, $next_url );
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Build the articles endpoint response.
|
|
209
|
+
*
|
|
210
|
+
* @param array $items Rendered article items.
|
|
211
|
+
* @param array $ids Post ids in the response.
|
|
212
|
+
* @param string $next URL for the next page, or empty string when there is none.
|
|
213
|
+
* @return WP_REST_Response
|
|
214
|
+
*/
|
|
215
|
+
private static function articles_response( $items = [], $ids = [], $next = '' ) {
|
|
195
216
|
return rest_ensure_response(
|
|
196
217
|
[
|
|
197
218
|
'items' => $items,
|
|
198
219
|
'ids' => $ids,
|
|
199
|
-
'next' => $
|
|
220
|
+
'next' => $next,
|
|
200
221
|
]
|
|
201
222
|
);
|
|
202
223
|
}
|
|
203
224
|
|
|
225
|
+
/**
|
|
226
|
+
* Restrict a list of post types to those that are publicly viewable.
|
|
227
|
+
*
|
|
228
|
+
* Used to keep the public articles endpoint from exposing post types that
|
|
229
|
+
* WordPress would not surface on the front end. Non-viewable types are dropped;
|
|
230
|
+
* the returned list may be empty when none qualify (the caller then returns no results).
|
|
231
|
+
*
|
|
232
|
+
* @param array|string $post_types Requested post type(s).
|
|
233
|
+
* @return array Viewable post types (may be empty).
|
|
234
|
+
*/
|
|
235
|
+
private static function filter_viewable_post_types( $post_types ) {
|
|
236
|
+
return array_values( array_filter( (array) $post_types, 'is_post_type_viewable' ) );
|
|
237
|
+
}
|
|
238
|
+
|
|
204
239
|
/**
|
|
205
240
|
* Sets up and returns attribute schema.
|
|
206
241
|
*
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
'name' => 'automattic/newspack-blocks',
|
|
4
4
|
'pretty_version' => 'dev-main',
|
|
5
5
|
'version' => 'dev-main',
|
|
6
|
-
'reference' => '
|
|
6
|
+
'reference' => 'cde3e84ebf2c8e653f085560799f32c69bd75a36',
|
|
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-main',
|
|
15
15
|
'version' => 'dev-main',
|
|
16
|
-
'reference' => '
|
|
16
|
+
'reference' => 'cde3e84ebf2c8e653f085560799f32c69bd75a36',
|
|
17
17
|
'type' => 'wordpress-plugin',
|
|
18
18
|
'install_path' => __DIR__ . '/../../',
|
|
19
19
|
'aliases' => array(),
|