jetpack
7 years ago
class.wpcom-json-api-add-widget-endpoint.php
8 years ago
class.wpcom-json-api-autosave-post-v1-1-endpoint.php
8 years ago
class.wpcom-json-api-bulk-delete-post-endpoint.php
8 years ago
class.wpcom-json-api-bulk-restore-post-endpoint.php
8 years ago
class.wpcom-json-api-bulk-update-comments-endpoint.php
7 years ago
class.wpcom-json-api-comment-endpoint.php
7 years ago
class.wpcom-json-api-delete-media-endpoint.php
8 years ago
class.wpcom-json-api-delete-media-v1-1-endpoint.php
8 years ago
class.wpcom-json-api-edit-media-v1-2-endpoint.php
7 years ago
class.wpcom-json-api-get-autosave-v1-1-endpoint.php
8 years ago
class.wpcom-json-api-get-comment-counts-endpoint.php
7 years ago
class.wpcom-json-api-get-comment-endpoint.php
8 years ago
class.wpcom-json-api-get-comment-history-endpoint.php
8 years ago
class.wpcom-json-api-get-comments-tree-endpoint.php
8 years ago
class.wpcom-json-api-get-comments-tree-v1-1-endpoint.php
8 years ago
class.wpcom-json-api-get-comments-tree-v1-2-endpoint.php
8 years ago
class.wpcom-json-api-get-customcss.php
8 years ago
class.wpcom-json-api-get-media-endpoint.php
8 years ago
class.wpcom-json-api-get-media-v1-1-endpoint.php
8 years ago
class.wpcom-json-api-get-media-v1-2-endpoint.php
8 years ago
class.wpcom-json-api-get-post-counts-v1-1-endpoint.php
8 years ago
class.wpcom-json-api-get-post-endpoint.php
8 years ago
class.wpcom-json-api-get-post-v1-1-endpoint.php
8 years ago
class.wpcom-json-api-get-site-endpoint.php
7 years ago
class.wpcom-json-api-get-site-v1-2-endpoint.php
8 years ago
class.wpcom-json-api-get-taxonomies-endpoint.php
8 years ago
class.wpcom-json-api-get-taxonomy-endpoint.php
8 years ago
class.wpcom-json-api-get-term-endpoint.php
8 years ago
class.wpcom-json-api-list-comments-endpoint.php
7 years ago
class.wpcom-json-api-list-embeds-endpoint.php
8 years ago
class.wpcom-json-api-list-media-endpoint.php
8 years ago
class.wpcom-json-api-list-media-v1-1-endpoint.php
8 years ago
class.wpcom-json-api-list-media-v1-2-endpoint.php
8 years ago
class.wpcom-json-api-list-post-type-taxonomies-endpoint.php
8 years ago
class.wpcom-json-api-list-post-types-endpoint.php
8 years ago
class.wpcom-json-api-list-posts-endpoint.php
8 years ago
class.wpcom-json-api-list-posts-v1-1-endpoint.php
8 years ago
class.wpcom-json-api-list-posts-v1-2-endpoint.php
8 years ago
class.wpcom-json-api-list-roles-endpoint.php
8 years ago
class.wpcom-json-api-list-shortcodes-endpoint.php
8 years ago
class.wpcom-json-api-list-terms-endpoint.php
8 years ago
class.wpcom-json-api-list-users-endpoint.php
8 years ago
class.wpcom-json-api-menus-v1-1-endpoint.php
8 years ago
class.wpcom-json-api-post-endpoint.php
7 years ago
class.wpcom-json-api-post-v1-1-endpoint.php
8 years ago
class.wpcom-json-api-render-embed-endpoint.php
8 years ago
class.wpcom-json-api-render-embed-reversal-endpoint.php
8 years ago
class.wpcom-json-api-render-endpoint.php
9 years ago
class.wpcom-json-api-render-shortcode-endpoint.php
8 years ago
class.wpcom-json-api-sharing-buttons-endpoint.php
8 years ago
class.wpcom-json-api-site-settings-endpoint.php
7 years ago
class.wpcom-json-api-site-settings-v1-2-endpoint.php
7 years ago
class.wpcom-json-api-site-settings-v1-3-endpoint.php
7 years ago
class.wpcom-json-api-site-settings-v1-4-endpoint.php
7 years ago
class.wpcom-json-api-site-user-endpoint.php
8 years ago
class.wpcom-json-api-taxonomy-endpoint.php
7 years ago
class.wpcom-json-api-update-comment-endpoint.php
8 years ago
class.wpcom-json-api-update-customcss.php
8 years ago
class.wpcom-json-api-update-media-endpoint.php
8 years ago
class.wpcom-json-api-update-media-v1-1-endpoint.php
8 years ago
class.wpcom-json-api-update-post-endpoint.php
7 years ago
class.wpcom-json-api-update-post-v1-1-endpoint.php
7 years ago
class.wpcom-json-api-update-post-v1-2-endpoint.php
7 years ago
class.wpcom-json-api-update-site-homepage-endpoint.php
8 years ago
class.wpcom-json-api-update-site-logo-endpoint.php
8 years ago
class.wpcom-json-api-update-taxonomy-endpoint.php
8 years ago
class.wpcom-json-api-update-term-endpoint.php
7 years ago
class.wpcom-json-api-update-user-endpoint.php
7 years ago
class.wpcom-json-api-upload-media-endpoint.php
8 years ago
class.wpcom-json-api-upload-media-v1-1-endpoint.php
8 years ago
class.wpcom-json-api-get-comment-history-endpoint.php
54 lines
| 1 | <?php |
| 2 | |
| 3 | new WPCOM_JSON_API_GET_Comment_History_Endpoint( array( |
| 4 | 'description' => 'Get the audit history for given comment', |
| 5 | 'group' => 'comments', |
| 6 | 'stat' => 'comments:1:comment-history', |
| 7 | 'method' => 'GET', |
| 8 | 'path' => '/sites/%s/comment-history/%d', |
| 9 | 'path_labels' => array( |
| 10 | '$site' => '(int|string) Site ID or domain', |
| 11 | '$comment_ID' => '(int) The comment ID' |
| 12 | ), |
| 13 | |
| 14 | 'example_request' => 'https://public-api.wordpress.com/rest/v1/sites/en.blog.wordpress.com/comment-history/11', |
| 15 | |
| 16 | 'response_format' => array( |
| 17 | 'comment_history' => '(array) Array of arrays representing the comment history objects.' |
| 18 | ) |
| 19 | ) ); |
| 20 | |
| 21 | class WPCOM_JSON_API_GET_Comment_History_Endpoint extends WPCOM_JSON_API_Endpoint { |
| 22 | |
| 23 | // /sites/%s/comment-history/%d |
| 24 | public function callback( $path = '', $blog_id = 0, $comment_id = 0 ) { |
| 25 | $blog_id = $this->api->switch_to_blog_and_validate_user( $this->api->get_blog_id( $blog_id ) ); |
| 26 | |
| 27 | if ( is_wp_error( $blog_id ) ) { |
| 28 | return $blog_id; |
| 29 | } |
| 30 | |
| 31 | if ( ! get_current_user_id() ) { |
| 32 | return new WP_Error( 'authorization_required', 'An active access token must be used to retrieve comment history.', 403 ); |
| 33 | } |
| 34 | |
| 35 | if ( ! current_user_can_for_blog( $blog_id, 'edit_posts' ) ) { |
| 36 | return new WP_Error( 'authorization_required', 'You are not authorized to view comment history on this blog.', 403 ); |
| 37 | } |
| 38 | |
| 39 | if ( ! method_exists( 'Akismet', 'get_comment_history' ) ) { |
| 40 | return new WP_Error( 'akismet_required', 'Akismet plugin must be active for this feature to work', 503 ); |
| 41 | } |
| 42 | |
| 43 | $comment_history = Akismet::get_comment_history( $comment_id ); |
| 44 | |
| 45 | foreach ( $comment_history as &$item ) { |
| 46 | // Times are stored as floating point values in microseconds. |
| 47 | // We don't need that precision on the client so let's get rid of the decimal part. |
| 48 | $item['time'] = intval( $item['time'] ); |
| 49 | } |
| 50 | |
| 51 | return array( 'comment_history' => $comment_history ); |
| 52 | } |
| 53 | } |
| 54 |