@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * Check if a given request has access to create a reaction |
118 | 118 | * |
119 | 119 | * @param WP_REST_Request $request Full details about the request. |
120 | - * @return WP_Error|boolean |
|
120 | + * @return boolean |
|
121 | 121 | */ |
122 | 122 | public function create_item_permissions_check( $request ) { |
123 | 123 | return true; |
@@ -166,7 +166,6 @@ discard block |
||
166 | 166 | /** |
167 | 167 | * Prepare links for the request. |
168 | 168 | * |
169 | - * @param array $comment Reaction. |
|
170 | 169 | * @return array Links for the given reaction. |
171 | 170 | */ |
172 | 171 | protected function prepare_links( $reaction ) { |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | * @return WP_Error|boolean |
41 | 41 | */ |
42 | 42 | public function get_items_permissions_check( $request ) { |
43 | - if ( ! empty( $request['post'] ) ) { |
|
44 | - foreach ( (array) $request['post'] as $post_id ) { |
|
43 | + if ( ! empty( $request[ 'post' ] ) ) { |
|
44 | + foreach ( (array) $request[ 'post' ] as $post_id ) { |
|
45 | 45 | $post = get_post( $post_id ); |
46 | 46 | if ( ! empty( $post_id ) && $post && ! $this->check_read_post_permission( $post ) ) { |
47 | 47 | return new WP_Error( 'rest_cannot_read_post', __( 'Sorry, you cannot read the post for this reaction.' ), array( 'status' => rest_authorization_required_code() ) ); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function get_items( $request ) { |
64 | 64 | $prepared_args = array( |
65 | - 'post__in' => $request['post'], |
|
65 | + 'post__in' => $request[ 'post' ], |
|
66 | 66 | 'type' => 'reaction', |
67 | 67 | ); |
68 | 68 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $query_result = $query->query( $prepared_args ); |
81 | 81 | |
82 | 82 | $reactions_count = array(); |
83 | - foreach( $query_result as $reaction ) { |
|
83 | + foreach ( $query_result as $reaction ) { |
|
84 | 84 | if ( empty( $reactions_count[ $reaction->comment_content ] ) ) { |
85 | 85 | $reactions_count[ $reaction->comment_content ] = array( |
86 | 86 | 'count' => 0, |
@@ -92,15 +92,15 @@ discard block |
||
92 | 92 | } |
93 | 93 | |
94 | 94 | $reactions = array(); |
95 | - foreach( $reactions_count as $emoji => $data ) { |
|
95 | + foreach ( $reactions_count as $emoji => $data ) { |
|
96 | 96 | $reaction = array( |
97 | 97 | 'emoji' => $emoji, |
98 | - 'count' => $data['count'], |
|
99 | - 'post_id' => $data['post_id'], |
|
98 | + 'count' => $data[ 'count' ], |
|
99 | + 'post_id' => $data[ 'post_id' ], |
|
100 | 100 | ); |
101 | 101 | |
102 | 102 | $data = $this->prepare_item_for_response( $reaction, $request ); |
103 | - $reactions[] = $this->prepare_response_for_collection( $data ); |
|
103 | + $reactions[ ] = $this->prepare_response_for_collection( $data ); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | $total_reactions = (int) $query->found_comments; |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | */ |
142 | 142 | public function prepare_item_for_response( $reaction, $request ) { |
143 | 143 | $data = array( |
144 | - 'emoji' => $reaction['emoji'], |
|
145 | - 'count' => (int) $reaction['count'], |
|
146 | - 'post_id' => (int) $reaction['post_id'], |
|
144 | + 'emoji' => $reaction[ 'emoji' ], |
|
145 | + 'count' => (int) $reaction[ 'count' ], |
|
146 | + 'post_id' => (int) $reaction[ 'post_id' ], |
|
147 | 147 | ); |
148 | 148 | |
149 | 149 | // Wrap the data in a response object |
@@ -179,13 +179,13 @@ discard block |
||
179 | 179 | ), |
180 | 180 | ); |
181 | 181 | |
182 | - if ( 0 !== (int) $reaction['post_id'] ) { |
|
183 | - $post = get_post( $reaction['post_id'] ); |
|
182 | + if ( 0 !== (int) $reaction[ 'post_id' ] ) { |
|
183 | + $post = get_post( $reaction[ 'post_id' ] ); |
|
184 | 184 | if ( ! empty( $post->ID ) ) { |
185 | 185 | $obj = get_post_type_object( $post->post_type ); |
186 | 186 | $base = ! empty( $obj->rest_base ) ? $obj->rest_base : $obj->name; |
187 | - $links['up'] = array( |
|
188 | - 'href' => rest_url( '/wp/v2/' . $base . '/' . $reaction['post_id'] ), |
|
187 | + $links[ 'up' ] = array( |
|
188 | + 'href' => rest_url( '/wp/v2/' . $base . '/' . $reaction[ 'post_id' ] ), |
|
189 | 189 | 'embeddable' => true, |
190 | 190 | 'post_type' => $post->post_type, |
191 | 191 | ); |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | public function get_collection_params() { |
204 | 204 | $query_params = array(); |
205 | 205 | |
206 | - $query_params['post'] = array( |
|
206 | + $query_params[ 'post' ] = array( |
|
207 | 207 | 'default' => array(), |
208 | 208 | 'description' => __( 'Limit result set to resources assigned to specific post ids.' ), |
209 | 209 | 'type' => 'array', |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | public function get_creation_params() { |
222 | 222 | $query_params = array(); |
223 | 223 | |
224 | - $query_params['post'] = array( |
|
224 | + $query_params[ 'post' ] = array( |
|
225 | 225 | 'default' => array(), |
226 | 226 | 'description' => __( 'The post ID to add a reaction to.' ), |
227 | 227 | 'type' => 'integer', |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | 'validate_callback' => 'rest_validate_request_arg', |
230 | 230 | ); |
231 | 231 | |
232 | - $query_params['emoji'] = array( |
|
232 | + $query_params[ 'emoji' ] = array( |
|
233 | 233 | 'default' => array(), |
234 | 234 | 'description' => __( 'The reaction emoji.' ), |
235 | 235 | 'type' => 'string', |
@@ -25,10 +25,10 @@ discard block |
||
25 | 25 | |
26 | 26 | add_action( 'rest_api_init', array( $this->api, 'register_routes' ) ); |
27 | 27 | |
28 | - add_action( 'wp_head', array( $this, 'print_settings' ) ); |
|
29 | - add_action( 'wp_footer', array( $this, 'print_selector' ) ); |
|
28 | + add_action( 'wp_head', array( $this, 'print_settings' ) ); |
|
29 | + add_action( 'wp_footer', array( $this, 'print_selector' ) ); |
|
30 | 30 | |
31 | - add_filter( 'the_content', array( $this, 'the_content' ) ); |
|
31 | + add_filter( 'the_content', array( $this, 'the_content' ) ); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | ) ); |
88 | 88 | |
89 | 89 | $reactions_summary = array(); |
90 | - foreach( $reactions as $reaction ) { |
|
90 | + foreach ( $reactions as $reaction ) { |
|
91 | 91 | if ( ! isset( $reactions_summary[ $reaction->comment_content ] ) ) { |
92 | 92 | $reactions_summary[ $reaction->comment_content ] = 0; |
93 | 93 | } |
@@ -111,14 +111,14 @@ discard block |
||
111 | 111 | ?> |
112 | 112 | <div id="emoji-reaction-selector" style="display: none;"> |
113 | 113 | <div class="tabs"> |
114 | - <div data-tab="0" alt="<?php echo __( 'People', 'reactions' ); ?>" class="emoji-reaction-tab"><?php echo __( ' |