Skip to content

Commit 12a122e

Browse files
committed
Fix rest route
Fixed the issues as descripted in the the helpscout ticket.
1 parent af01da9 commit 12a122e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

classes/Visualizer/Gutenberg/Block.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,10 @@ public function register_rest_endpoints() {
192192
* Get Post Meta Fields
193193
*/
194194
public function get_visualizer_data( $post ) {
195+
if ( ! current_user_can( 'edit_posts' ) ) {
196+
return false;
197+
}
198+
195199
$data = array();
196200
$post_id = $post['id'];
197201

@@ -239,6 +243,10 @@ public function get_visualizer_data( $post ) {
239243
* Rest Callback Method
240244
*/
241245
public function update_chart_data( $data ) {
246+
if ( ! current_user_can( 'edit_posts' ) ) {
247+
return false;
248+
}
249+
242250
if ( $data['id'] && ! is_wp_error( $data['id'] ) ) {
243251

244252
update_post_meta( $data['id'], Visualizer_Plugin::CF_CHART_TYPE, $data['visualizer-chart-type'] );
@@ -352,6 +360,10 @@ public function toUTF8( $datum ) {
352360
* Handle remote CSV data
353361
*/
354362
public function upload_csv_data( $data ) {
363+
if ( ! current_user_can( 'edit_posts' ) ) {
364+
return false;
365+
}
366+
355367
if ( $data['url'] && ! is_wp_error( $data['url'] ) && filter_var( $data['url'], FILTER_VALIDATE_URL ) ) {
356368
$source = new Visualizer_Source_Csv_Remote( $data['url'] );
357369
if ( $source->fetch() ) {
@@ -375,6 +387,10 @@ public function upload_csv_data( $data ) {
375387
* Get permission data
376388
*/
377389
public function get_permission_data( $data ) {
390+
if ( ! current_user_can( 'edit_posts' ) ) {
391+
return false;
392+
}
393+
378394
$options = array();
379395
switch ( $data['type'] ) {
380396
case 'users':

0 commit comments

Comments
 (0)