| @@ 5-22 (lines=18) @@ | ||
| 2 | ||
| 3 | class WPCOM_JSON_API_Get_Comment_Endpoint extends WPCOM_JSON_API_Comment_Endpoint { |
|
| 4 | // /sites/%s/comments/%d -> $blog_id, $comment_id |
|
| 5 | function callback( $path = '', $blog_id = 0, $comment_id = 0 ) { |
|
| 6 | $blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $blog_id ) ); |
|
| 7 | if ( is_wp_error( $blog_id ) ) { |
|
| 8 | return $blog_id; |
|
| 9 | } |
|
| 10 | ||
| 11 | $args = $this->query_args(); |
|
| 12 | ||
| 13 | $return = $this->get_comment( $comment_id, $args['context'] ); |
|
| 14 | if ( !$return || is_wp_error( $return ) ) { |
|
| 15 | return $return; |
|
| 16 | } |
|
| 17 | ||
| 18 | /** This action is documented in json-endpoints/class.wpcom-json-api-site-settings-endpoint.php */ |
|
| 19 | do_action( 'wpcom_json_api_objects', 'comments' ); |
|
| 20 | ||
| 21 | return $return; |
|
| 22 | } |
|
| 23 | } |
|
| 24 | ||
| @@ 217-236 (lines=20) @@ | ||
| 214 | class WPCOM_JSON_API_Get_Sharing_Button_Endpoint extends WPCOM_JSON_API_Sharing_Button_Endpoint { |
|
| 215 | ||
| 216 | // GET /sites/%s/sharing-buttons/%s -> $blog_id, $button_id |
|
| 217 | public function callback( $path = '', $blog_id = 0, $button_id = 0 ) { |
|
| 218 | // Validate request |
|
| 219 | $blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $blog_id ) ); |
|
| 220 | if ( is_wp_error( $blog_id ) ) { |
|
| 221 | return $blog_id; |
|
| 222 | } |
|
| 223 | ||
| 224 | $continue = $this->setup(); |
|
| 225 | if ( is_wp_error( $continue ) ) { |
|
| 226 | return $continue; |
|
| 227 | } |
|
| 228 | ||
| 229 | // Search existing services for button |
|
| 230 | $all_buttons = $this->sharing_service->get_all_services_blog(); |
|
| 231 | if ( ! array_key_exists( $button_id, $all_buttons ) ) { |
|
| 232 | return new WP_Error( 'not_found', 'The specified sharing button was not found', 404 ); |
|
| 233 | } else { |
|
| 234 | return $this->format_sharing_button( $all_buttons[ $button_id ] ); |
|
| 235 | } |
|
| 236 | } |
|
| 237 | ||
| 238 | } |
|
| 239 | ||