Skip to content

Commit 5462480

Browse files
fix: check current user has edit_post capability
1 parent e19cab5 commit 5462480

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

includes/gutenberg/feedzy-rss-feeds-gutenberg-block.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,9 @@ public function feedzy_register_rest_route() {
284284
array(
285285
'methods' => 'POST',
286286
'callback' => array( $this, 'feedzy_rest_route' ),
287-
'permission_callback' => function () {
288-
return current_user_can( 'manage_options' );
287+
'permission_callback' => function ( WP_REST_Request $request ) {
288+
$post_id = $request->get_param( 'postId' );
289+
return current_user_can( 'edit_post', $post_id );
289290
},
290291
'args' => array(
291292
'url' => array(

js/FeedzyBlock/Editor.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,12 @@ class Editor extends Component {
194194
.filter((item) => item !== '');
195195
url = queryString.stringify({ url }, { arrayFormat: 'bracket' });
196196
}
197+
const postId = wp.data.select('core/editor').getCurrentPostId();
197198

198199
apiFetch({
199200
path: `/feedzy/v1/feed?${url}`,
200201
method: 'POST',
201-
data: this.props.attributes,
202+
data: {...this.props.attributes, postId: postId},
202203
})
203204
.then((data) => {
204205
if (this.unmounting) {

0 commit comments

Comments
 (0)