| @@ 149-164 (lines=16) @@ | ||
| 146 | * @param WP_REST_Request $request |
|
| 147 | * @return array filtered $connection |
|
| 148 | */ |
|
| 149 | public function prepare_item_for_response( $connection, $request ) { |
|
| 150 | if ( ! is_callable( array( $this, 'get_fields_for_response' ) ) ) { |
|
| 151 | return $connection; |
|
| 152 | } |
|
| 153 | ||
| 154 | $fields = $this->get_fields_for_response( $request ); |
|
| 155 | ||
| 156 | $response_data = array(); |
|
| 157 | foreach ( $connection as $field => $value ) { |
|
| 158 | if ( in_array( $field, $fields, true ) ) { |
|
| 159 | $response_data[ $field ] = $value; |
|
| 160 | } |
|
| 161 | } |
|
| 162 | ||
| 163 | return $response_data; |
|
| 164 | } |
|
| 165 | ||
| 166 | /** |
|
| 167 | * Verify that user can access Publicize data |
|
| @@ 122-137 (lines=16) @@ | ||
| 119 | * @param WP_REST_Request $request |
|
| 120 | * @return array filtered $service |
|
| 121 | */ |
|
| 122 | public function prepare_item_for_response( $service, $request ) { |
|
| 123 | if ( ! is_callable( array( $this, 'get_fields_for_response' ) ) ) { |
|
| 124 | return $service; |
|
| 125 | } |
|
| 126 | ||
| 127 | $fields = $this->get_fields_for_response( $request ); |
|
| 128 | ||
| 129 | $response_data = array(); |
|
| 130 | foreach ( $service as $field => $value ) { |
|
| 131 | if ( in_array( $field, $fields, true ) ) { |
|
| 132 | $response_data[ $field ] = $value; |
|
| 133 | } |
|
| 134 | } |
|
| 135 | ||
| 136 | return $response_data; |
|
| 137 | } |
|
| 138 | ||
| 139 | /** |
|
| 140 | * Verify that user can access Publicize data |
|
| @@ 93-108 (lines=16) @@ | ||
| 90 | * @param WP_REST_Request $request |
|
| 91 | * @return array filtered $connection |
|
| 92 | */ |
|
| 93 | public function prepare_item_for_response( $connection, $request ) { |
|
| 94 | if ( ! is_callable( array( $this, 'get_fields_for_response' ) ) ) { |
|
| 95 | return $connection; |
|
| 96 | } |
|
| 97 | ||
| 98 | $fields = $this->get_fields_for_response( $request ); |
|
| 99 | ||
| 100 | $response_data = array(); |
|
| 101 | foreach ( $connection as $field => $value ) { |
|
| 102 | if ( in_array( $field, $fields, true ) ) { |
|
| 103 | $response_data[ $field ] = $value; |
|
| 104 | } |
|
| 105 | } |
|
| 106 | ||
| 107 | return $response_data; |
|
| 108 | } |
|
| 109 | ||
| 110 | /** |
|
| 111 | * Verify that user can access Publicize data |
|