Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions includes/gutenberg/feedzy-rss-feeds-gutenberg-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,9 @@ public function feedzy_register_rest_route() {
array(
'methods' => 'POST',
'callback' => array( $this, 'feedzy_rest_route' ),
'permission_callback' => function () {
return is_user_logged_in();
'permission_callback' => function ( WP_REST_Request $request ) {
$post_id = absint( $request->get_param( 'postId' ) );
return current_user_can( 'edit_post', $post_id );
},
'args' => array(
'url' => array(
Expand Down Expand Up @@ -398,12 +399,12 @@ public function feedzy_rest_route( $data ) {
*/
public function feedzy_sanitize_feeds( $input ) {
if ( count( $input ) === 1 ) {
$feed = esc_url( $input[0] );
$feed = wp_http_validate_url( $input[0] );
return $feed;
} else {
$feeds = array();
foreach ( $input as $item ) {
$feeds[] = esc_url( $item );
$feeds[] = wp_http_validate_url( $item );
}
return $feeds;
}
Expand Down
3 changes: 2 additions & 1 deletion js/FeedzyBlock/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,12 @@ class Editor extends Component {
.filter((item) => item !== '');
url = queryString.stringify({ url }, { arrayFormat: 'bracket' });
}
const postId = wp.data.select('core/editor').getCurrentPostId();

apiFetch({
path: `/feedzy/v1/feed?${url}`,
method: 'POST',
data: this.props.attributes,
data: {...this.props.attributes, postId: postId},
})
.then((data) => {
if (this.unmounting) {
Expand Down
Loading