| @@ 17-26 (lines=10) @@ | ||
| 14 | add_action( 'rest_api_init', array( $this, 'register_routes' ) ); |
|
| 15 | } |
|
| 16 | ||
| 17 | public function register_routes() { |
|
| 18 | // GET /sites/<blog_id>/subscribers/count - Return number of subscribers for this site. |
|
| 19 | register_rest_route( $this->namespace, '/' . $this->rest_base . '/count', array( |
|
| 20 | array( |
|
| 21 | 'methods' => WP_REST_Server::READABLE, |
|
| 22 | 'callback' => array( $this, 'get_subscriber_count' ), |
|
| 23 | 'permission_callback' => array( $this, 'readable_permission_check' ), |
|
| 24 | ) |
|
| 25 | ) ); |
|
| 26 | } |
|
| 27 | ||
| 28 | public function readable_permission_check() { |
|
| 29 | if ( ! current_user_can_for_blog( get_current_blog_id(), 'edit_posts' ) ) { |
|
| @@ 24-37 (lines=14) @@ | ||
| 21 | /** |
|
| 22 | * Called automatically on `rest_api_init()`. |
|
| 23 | */ |
|
| 24 | public function register_routes() { |
|
| 25 | register_rest_route( |
|
| 26 | $this->namespace, |
|
| 27 | '/' . $this->rest_base, |
|
| 28 | array( |
|
| 29 | array( |
|
| 30 | 'methods' => WP_REST_Server::EDITABLE, |
|
| 31 | 'callback' => array( $this, 'update_option' ), |
|
| 32 | 'permission_callback' => array( $this, 'permission_check' ), |
|
| 33 | ), |
|
| 34 | # 'schema' => array( $this, 'get_public_item_schema' ), |
|
| 35 | ) |
|
| 36 | ); |
|
| 37 | } |
|
| 38 | ||
| 39 | public function permission_check() { |
|
| 40 | return true; #current_user_can( 'manage_options' ); |
|