← All changes
|
_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-following.php
+6
-11
12.8.3
→
16.3-a.7
View file →
| @@ -8,8 +8,12 @@ | ||
| 8 | 8 | |
| 9 | 9 | use Automattic\Jetpack\Connection\Client; |
| 10 | 10 | use Automattic\Jetpack\Status\Visitor; |
| 11 | 11 | |
| 12 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 13 | + exit( 0 ); | |
| 14 | +} | |
| 15 | + | |
| 12 | 16 | /** |
| 13 | 17 | * Class WPCOM_REST_API_V2_Endpoint_Following |
| 14 | 18 | */ |
| 15 | 19 | class WPCOM_REST_API_V2_Endpoint_Following extends WP_REST_Controller { |
| @@ -47,9 +51,9 @@ | ||
| 47 | 51 | array( |
| 48 | 52 | array( |
| 49 | 53 | 'methods' => WP_REST_Server::READABLE, |
| 50 | 54 | 'callback' => array( $this, 'get_following' ), |
| 51 | - 'permission_callback' => array( $this, 'permission_check' ), | |
| 55 | + 'permission_callback' => 'is_user_logged_in', | |
| 52 | 56 | 'args' => array( |
| 53 | 57 | 'ignore_user_blogs' => array( |
| 54 | 58 | 'type' => 'boolean', |
| 55 | 59 | ), |
| @@ -64,9 +68,9 @@ | ||
| 64 | 68 | array( |
| 65 | 69 | array( |
| 66 | 70 | 'methods' => WP_REST_Server::READABLE, |
| 67 | 71 | 'callback' => array( $this, 'get_recommendations' ), |
| 68 | - 'permission_callback' => array( $this, 'permission_check' ), | |
| 72 | + 'permission_callback' => 'is_user_logged_in', | |
| 69 | 73 | 'args' => array( |
| 70 | 74 | 'number' => array( |
| 71 | 75 | 'type' => 'number', |
| 72 | 76 | 'default' => 5, |
| @@ -77,17 +81,8 @@ | ||
| 77 | 81 | ), |
| 78 | 82 | ), |
| 79 | 83 | ) |
| 80 | 84 | ); |
| 81 | - } | |
| 82 | - | |
| 83 | - /** | |
| 84 | - * Check if user has edit post permission. | |
| 85 | - * | |
| 86 | - * @return true|WP_Error True if the request has access to create items, WP_Error object otherwise. | |
| 87 | - */ | |
| 88 | - public function permission_check() { | |
| 89 | - return current_user_can( 'edit_posts' ); | |
| 90 | 85 | } |
| 91 | 86 | |
| 92 | 87 | /** |
| 93 | 88 | * Gets the sites the user is following |