n class="octicon octicon-file-text"> 3394_vm 058f31828c first commit vor 1 Jahr 3395 058f31828c first commit vor 1 Jahr 3429 058f31828c first commit vor 1 Jahr 3430 058f31828c first commit vor 1 Jahr 3431 058f31828c first commit vor 1 Jahr 3433 058f31828c first commit vor 1 Jahr 3439 058f31828c first commit vor 1 Jahr 3440 058f31828c first commit vor 1 Jahr 3455 058f31828c first commit vor 1 Jahr 3456 058f31828c first commit vor 1 Jahr 3456_fsm 058f31828c first commit vor 1 Jahr 3456_vm 058f31828c first commit vor 1 Jahr 3466 058f31828c first commit vor 1 Jahr 3467 058f31828c first commit vor 1 Jahr 3468 058f31828c first commit vor 1 Jahr 3501 058f31828c first commit vor 1 Jahr 3502 058f31828c first commit vor 1 Jahr 3503 058f31828c first commit vor 1 Jahr 3534 058f31828c first commit vor 1 Jahr 3541 058f31828c first commit vor 1 Jahr 3541_fsm 058f31828c first commit vor 1 Jahr 3541_vm 058f31828c first commit vor 1 Jahr 3542 058f31828c first commit vor 1 Jahr 3574 058f31828c first commit vor 1 Jahr 3575 058f31828c first commit vor 1 Jahr 3576 058f31828c first commit vor 1 Jahr 3596 058f31828c first commit vor 1 Jahr 3597 058f31828c first commit vor 1 Jahr 3598 058f31828c first commit vor 1 Jahr 3599 058f31828c first commit vor 1 Jahr 3600 058f31828c first commit vor 1 Jahr 3600_fsm 058f31828c first commit vor 1 Jahr 3600_vm 058f31828c first commit vor 1 Jahr 3601 058f31828c first commit vor 1 Jahr 3601_fsm 058f31828c first commit vor 1 Jahr 3601_vm 058f31828c first commit vor 1 Jahr 3602 058f31828c first commit vor 1 Jahr 3602_fsm 058f31828c first commit vor 1 Jahr 3602_vm 058f31828c first commit vor 1 Jahr 3603 058f31828c first commit vor 1 Jahr 3603_fsm 058f31828c first commit vor 1 Jahr 3603_vm 058f31828c first commit vor 1 Jahr 3604 058f31828c first commit vor 1 Jahr 3605 058f31828c first commit vor 1 Jahr 3606 058f31828c first commit vor 1 Jahr 3607 058f31828c first commit vor 1 Jahr 3608 058f31828c first commit vor 1 Jahr 3609 058f31828c first commit vor 1 Jahr 3712 058f31828c first commit vor 1 Jahr 3764 058f31828c first commit vor 1 Jahr 3764_fsm 058f31828c first commit vor 1 Jahr 3764_vm 058f31828c first commit vor 1 Jahr 3766 058f31828c first commit vor 1 Jahr 3767 058f31828c first commit vor 1 Jahr 3997 058f31828c first commit vor 1 Jahr 4143 058f31828c first commit vor 1 Jahr 4144 058f31828c first commit vor 1 Jahr 4145 058f31828c first commit vor 1 Jahr 4146 058f31828c first commit vor 1 Jahr 4147 058f31828c first commit vor 1 Jahr 4148 058f31828c first commit vor 1 Jahr 4149 058f31828c first commit vor 1 Jahr 4150 058f31828c first commit vor 1 Jahr 4151 058f31828c first commit vor 1 Jahr 4152 058f31828c first commit vor 1 Jahr 4153 058f31828c first commit vor 1 Jahr 4154 058f31828c first commit vor 1 Jahr 4155 058f31828c first commit vor 1 Jahr 4156 058f31828c first commit vor 1 Jahr 4157 058f31828c first commit vor 1 Jahr 4158 058f31828c first commit vor 1 Jahr 4159 058f31828c first commit vor 1 Jahr 4160 058f31828c first commit vor 1 Jahr 4161 058f31828c first commit vor 1 Jahr 4162 058f31828c first commit vor 1 Jahr 4163 058f31828c first commit vor 1 Jahr 4164 058f31828c first commit vor 1 Jahr 4165 058f31828c first commit vor 1 Jahr 4166 058f31828c first commit vor 1 Jahr 4167 058f31828c first commit vor 1 Jahr 4168 058f31828c first commit vor 1 Jahr 4169 058f31828c first commit vor 1 Jahr 4170 058f31828c first commit vor 1 Jahr 4171 058f31828c first commit vor 1 Jahr 4172 058f31828c first commit vor 1 Jahr 4173 058f31828c first commit vor 1 Jahr 4174 058f31828c first commit vor 1 Jahr 5002 058f31828c first commit vor 1 Jahr 548 058f31828c first commit vor 1 Jahr 549 058f31828c first commit vor 1 Jahr 6102 058f31828c first commit vor 1 Jahr 6104 058f31828c first commit vor 1 Jahr 6106 058f31828c first commit vor 1 Jahr 6110 058f31828c first commit vor 1 Jahr 6111 058f31828c first commit vor 1 Jahr 6112 058f31828c first commit vor 1 Jahr 6113 058f31828c first commit vor 1 Jahr 6117 058f31828c first commit vor 1 Jahr 826 058f31828c first commit vor 1 Jahr 827 058f31828c first commit vor 1 Jahr 828 058f31828c first commit vor 1 Jahr PG_VERSION 058f31828c first commit vor 1 Jahr pg_filenode.map 058f31828c first commit vor 1 Jahr tum/whitesports - Gogs: Simplico Git Service

Keine Beschreibung

class.wpcom-json-api-get-comments-tree-v1-1-endpoint.php 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. new WPCOM_JSON_API_Get_Comments_Tree_v1_1_Endpoint ( array(
  3. 'description' => 'Get a comments tree for site.',
  4. 'min_version' => '1.1',
  5. 'max_version' => '1.1',
  6. 'group' => 'comments-tree',
  7. 'stat' => 'comments-tree:1',
  8. 'method' => 'GET',
  9. 'path' => '/sites/%s/comments-tree',
  10. 'path_labels' => array(
  11. '$site' => '(int|string) Site ID or domain',
  12. ),
  13. 'query_parameters' => array(
  14. 'status' => '(string) Filter returned comments based on this value (allowed values: all, approved, pending, trash, spam).'
  15. ),
  16. 'response_format' => array(
  17. 'comments_count' => '(int) Total number of comments on the site',
  18. 'comments_tree' => '(array) Array of post IDs representing the comments tree for given site (max 50000)',
  19. 'trackbacks_count' => '(int) Total number of trackbacks on the site',
  20. 'trackbacks_tree' => '(array) Array of post IDs representing the trackbacks tree for given site (max 50000)',
  21. 'pingbacks_count' => '(int) Total number of pingbacks on the site',
  22. 'pingbacks_tree' => '(array) Array of post IDs representing the pingbacks tree for given site (max 50000)',
  23. ),
  24. 'example_request' => 'https://public-api.wordpress.com/rest/v1.1/sites/en.blog.wordpress.com/comments-tree?status=approved'
  25. ) );
  26. class WPCOM_JSON_API_Get_Comments_Tree_v1_1_Endpoint extends WPCOM_JSON_API_Get_Comments_Tree_Endpoint {
  27. /**
  28. * Retrieves a list of comment data for a given site.
  29. *
  30. * @param string $status Filter by status: all, approved, pending, spam or trash.
  31. * @param int $start_at first comment to search from going back in time
  32. *
  33. * @return array
  34. */
  35. function get_site_tree( $status, $start_at = PHP_INT_MAX ) {
  36. global $wpdb;
  37. $max_comment_count = 50000;
  38. $db_status = $this->get_comment_db_status( $status );
  39. $db_comment_rows = $wpdb->get_results(
  40. $wpdb->prepare(
  41. "SELECT comment_ID, comment_post_ID, comment_parent, comment_type " .
  42. "FROM $wpdb->comments AS comments " .
  43. "INNER JOIN $wpdb->posts AS posts ON comments.comment_post_ID = posts.ID " .
  44. "WHERE comment_ID <= %d AND ( %s = 'all' OR comment_approved = %s ) " .
  45. "ORDER BY comment_ID DESC " .
  46. "LIMIT %d",
  47. (int) $start_at, $db_status, $db_status, $max_comment_count
  48. ),
  49. ARRAY_N
  50. );
  51. $comments = array();
  52. $trackbacks = array();
  53. $pingbacks = array();
  54. foreach ( $db_comment_rows as $row ) {
  55. $comment_id = (int) $row[0];
  56. $comment_post_id = (int) $row[1];
  57. $comment_parent_id = (int) $row[2];
  58. if ( ! isset( $comments[ $comment_post_id ] ) ) {
  59. $comments[ $comment_post_id ] = array( array(), array() );
  60. }
  61. switch ( $row[3] ) {
  62. case 'trackback':
  63. $trackbacks[ $comment_post_id ][] = $comment_id;
  64. break;
  65. case 'pingback':
  66. $pingbacks[ $comment_post_id ][] = $comment_id;
  67. break;
  68. default:
  69. if ( 0 === $comment_parent_id ) {
  70. $comments[ $comment_post_id ][0][] = $comment_id;
  71. } else {
  72. $comments[ $comment_post_id ][1][] = array( $comment_id, $comment_parent_id );
  73. }
  74. }
  75. }
  76. return array(
  77. 'comments_count' => $this->get_site_tree_total_count( $status, 'comment' ),
  78. 'comments_tree' => $comments,
  79. 'trackbacks_count' => $this->get_site_tree_total_count( $status, 'trackback' ),
  80. 'trackbacks_tree' => $trackbacks,
  81. 'pingbacks_count' => $this->get_site_tree_total_count( $status, 'pingback' ),
  82. 'pingbacks_tree' => $pingbacks,
  83. );
  84. }
  85. }