@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | $code = str_replace( '-', "-0x", $code ); |
28 | 28 | $code = explode( '-', $code ); |
29 | 29 | |
30 | - $map[ $category ][] = array( |
|
30 | + $map[ $category ][ ] = array( |
|
31 | 31 | 'code' => $code, |
32 | 32 | 'sort_order' => $emoji->sort_order, |
33 | 33 | ); |
@@ -37,15 +37,15 @@ discard block |
||
37 | 37 | |
38 | 38 | foreach ( $map as $category => $emoji_list ) { |
39 | 39 | usort( $map[ $category ], function( $a, $b ) { |
40 | - if ( $a['sort_order'] == $b['sort_order'] ) { |
|
40 | + if ( $a[ 'sort_order' ] == $b[ 'sort_order' ] ) { |
|
41 | 41 | return 0; |
42 | 42 | } |
43 | 43 | |
44 | - return ( $a['sort_order'] < $b['sort_order'] ) ? -1 : 1; |
|
44 | + return ( $a[ 'sort_order' ] < $b[ 'sort_order' ] ) ? -1 : 1; |
|
45 | 45 | } ); |
46 | 46 | |
47 | 47 | foreach ( $map[ $category ] as $id => $emoji ) { |
48 | - $map[ $category ][ $id ] = $emoji['code']; |
|
48 | + $map[ $category ][ $id ] = $emoji[ 'code' ]; |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 |
@@ -54,8 +54,8 @@ discard block |
||
54 | 54 | * @return WP_Error|boolean |
55 | 55 | */ |
56 | 56 | public function get_items_permissions_check( $request ) { |
57 | - if ( ! empty( $request['post'] ) ) { |
|
58 | - foreach ( (array) $request['post'] as $post_id ) { |
|
57 | + if ( ! empty( $request[ 'post' ] ) ) { |
|
58 | + foreach ( (array) $request[ 'post' ] as $post_id ) { |
|
59 | 59 | $post = get_post( $post_id ); |
60 | 60 | if ( ! empty( $post_id ) && $post && ! $this->check_read_post_permission( $post ) ) { |
61 | 61 | return new WP_Error( 'rest_cannot_read_post', __( 'Sorry, you cannot read the post for this reaction.' ), array( 'status' => rest_authorization_required_code() ) ); |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function get_items( $request ) { |
78 | 78 | $prepared_args = array( |
79 | - 'post__in' => $request['post'], |
|
79 | + 'post__in' => $request[ 'post' ], |
|
80 | 80 | 'type' => 'reaction', |
81 | 81 | ); |
82 | 82 | |
@@ -109,12 +109,12 @@ discard block |
||
109 | 109 | foreach ( $reactions_count as $emoji => $data ) { |
110 | 110 | $reaction = array( |
111 | 111 | 'emoji' => $emoji, |
112 | - 'count' => $data['count'], |
|
113 | - 'post_id' => $data['post_id'], |
|
112 | + 'count' => $data[ 'count' ], |
|
113 | + 'post_id' => $data[ 'post_id' ], |
|
114 | 114 | ); |
115 | 115 | |
116 | 116 | $data = $this->prepare_item_for_response( $reaction, $request ); |
117 | - $reactions[] = $this->prepare_response_for_collection( $data ); |
|
117 | + $reactions[ ] = $this->prepare_response_for_collection( $data ); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | $total_reactions = (int) $query->found_comments; |
@@ -232,9 +232,9 @@ discard block |
||
232 | 232 | */ |
233 | 233 | public function prepare_item_for_response( $reaction, $request ) { |
234 | 234 | $data = array( |
235 | - 'emoji' => $reaction['emoji'], |
|
236 | - 'count' => (int) $reaction['count'], |
|
237 | - 'post_id' => (int) $reaction['post_id'], |
|
235 | + 'emoji' => $reaction[ 'emoji' ], |
|
236 | + 'count' => (int) $reaction[ 'count' ], |
|
237 | + 'post_id' => (int) $reaction[ 'post_id' ], |
|
238 | 238 | ); |
239 | 239 | |
240 | 240 | // Wrap the data in a response object |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | $data = (array) $response->get_data(); |
269 | 269 | $links = WP_REST_Server::get_response_links( $response ); |
270 | 270 | if ( ! empty( $links ) ) { |
271 | - $data['_links'] = $links; |
|
271 | + $data[ '_links' ] = $links; |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | return $data; |
@@ -290,13 +290,13 @@ discard block |
||
290 | 290 | ), |
291 | 291 | ); |
292 | 292 | |
293 | - if ( 0 !== (int) $reaction['post_id'] ) { |
|
294 | - $post = get_post( $reaction['post_id'] ); |
|
293 | + if ( 0 !== (int) $reaction[ 'post_id' ] ) { |
|
294 | + $post = get_post( $reaction[ 'post_id' ] ); |
|
295 | 295 | if ( ! empty( $post->ID ) ) { |
296 | 296 | $obj = get_post_type_object( $post->post_type ); |
297 | 297 | $base = ! empty( $obj->rest_base ) ? $obj->rest_base : $obj->name; |
298 | - $links['up'] = array( |
|
299 | - 'href' => rest_url( '/wp/v2/' . $base . '/' . $reaction['post_id'] ), |
|
298 | + $links[ 'up' ] = array( |
|
299 | + 'href' => rest_url( '/wp/v2/' . $base . '/' . $reaction[ 'post_id' ] ), |
|
300 | 300 | 'embeddable' => true, |
301 | 301 | 'post_type' => $post->post_type, |
302 | 302 | ); |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | public function get_collection_params() { |
315 | 315 | $query_params = array(); |
316 | 316 | |
317 | - $query_params['post'] = array( |
|
317 | + $query_params[ 'post' ] = array( |
|
318 | 318 | 'default' => array(), |
319 | 319 | 'description' => __( 'Limit result set to resources assigned to specific post ids.' ), |
320 | 320 | 'type' => 'array', |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | public function get_creation_params() { |
333 | 333 | $query_params = array(); |
334 | 334 | |
335 | - $query_params['post'] = array( |
|
335 | + $query_params[ 'post' ] = array( |
|
336 | 336 | 'default' => array(), |
337 | 337 | 'description' => __( 'The post ID to add a reaction to.' ), |
338 | 338 | 'type' => 'integer', |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | 'validate_callback' => 'rest_validate_request_arg', |
341 | 341 | ); |
342 | 342 | |
343 | - $query_params['emoji'] = array( |
|
343 | + $query_params[ 'emoji' ] = array( |
|
344 | 344 | 'default' => array(), |
345 | 345 | 'description' => __( 'The reaction emoji.' ), |
346 | 346 | '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 | /** |
@@ -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 __( ' |