@@ -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 | ); |
@@ -35,17 +35,17 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | ksort( $map ); |
| 37 | 37 | |
| 38 | -foreach( $map as $category => $emoji_list ) { |
|
| 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 | - foreach( $map[ $category ] as $id => $emoji ) { |
|
| 48 | - $map[ $category ][ $id ] = $emoji['code']; |
|
| 47 | + foreach ( $map[ $category ] as $id => $emoji ) { |
|
| 48 | + $map[ $category ][ $id ] = $emoji[ 'code' ]; |
|
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | |
@@ -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 __( ' |
|
@@ -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 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | $query_result = $query->query( $prepared_args ); |
| 95 | 95 | |
| 96 | 96 | $reactions_count = array(); |
| 97 | - foreach( $query_result as $reaction ) { |
|
| 97 | + foreach ( $query_result as $reaction ) { |
|
| 98 | 98 | if ( empty( $reactions_count[ $reaction->comment_content ] ) ) { |
| 99 | 99 | $reactions_count[ $reaction->comment_content ] = array( |
| 100 | 100 | 'count' => 0, |
@@ -106,15 +106,15 @@ discard block |
||
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | $reactions = array(); |
| 109 | - foreach( $reactions_count as $emoji => $data ) { |
|
| 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; |
@@ -197,9 +197,9 @@ discard block |
||
| 197 | 197 | */ |
| 198 | 198 | public function prepare_item_for_response( $reaction, $request ) { |
| 199 | 199 | $data = array( |
| 200 | - 'emoji' => $reaction['emoji'], |
|
| 201 | - 'count' => (int) $reaction['count'], |
|
| 202 | - 'post_id' => (int) $reaction['post_id'], |
|
| 200 | + 'emoji' => $reaction[ 'emoji' ], |
|
| 201 | + 'count' => (int) $reaction[ 'count' ], |
|
| 202 | + 'post_id' => (int) $reaction[ 'post_id' ], |
|
| 203 | 203 | ); |
| 204 | 204 | |
| 205 | 205 | // Wrap the data in a response object |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | $data = (array) $response->get_data(); |
| 234 | 234 | $links = WP_REST_Server::get_response_links( $response ); |
| 235 | 235 | if ( ! empty( $links ) ) { |
| 236 | - $data['_links'] = $links; |
|
| 236 | + $data[ '_links' ] = $links; |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | return $data; |
@@ -255,13 +255,13 @@ discard block |
||
| 255 | 255 | ), |
| 256 | 256 | ); |
| 257 | 257 | |
| 258 | - if ( 0 !== (int) $reaction['post_id'] ) { |
|
| 259 | - $post = get_post( $reaction['post_id'] ); |
|
| 258 | + if ( 0 !== (int) $reaction[ 'post_id' ] ) { |
|
| 259 | + $post = get_post( $reaction[ 'post_id' ] ); |
|
| 260 | 260 | if ( ! empty( $post->ID ) ) { |
| 261 | 261 | $obj = get_post_type_object( $post->post_type ); |
| 262 | 262 | $base = ! empty( $obj->rest_base ) ? $obj->rest_base : $obj->name; |
| 263 | - $links['up'] = array( |
|
| 264 | - 'href' => rest_url( '/wp/v2/' . $base . '/' . $reaction['post_id'] ), |
|
| 263 | + $links[ 'up' ] = array( |
|
| 264 | + 'href' => rest_url( '/wp/v2/' . $base . '/' . $reaction[ 'post_id' ] ), |
|
| 265 | 265 | 'embeddable' => true, |
| 266 | 266 | 'post_type' => $post->post_type, |
| 267 | 267 | ); |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | public function get_collection_params() { |
| 280 | 280 | $query_params = array(); |
| 281 | 281 | |
| 282 | - $query_params['post'] = array( |
|
| 282 | + $query_params[ 'post' ] = array( |
|
| 283 | 283 | 'default' => array(), |
| 284 | 284 | 'description' => __( 'Limit result set to resources assigned to specific post ids.' ), |
| 285 | 285 | 'type' => 'array', |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | public function get_creation_params() { |
| 298 | 298 | $query_params = array(); |
| 299 | 299 | |
| 300 | - $query_params['post'] = array( |
|
| 300 | + $query_params[ 'post' ] = array( |
|
| 301 | 301 | 'default' => array(), |
| 302 | 302 | 'description' => __( 'The post ID to add a reaction to.' ), |
| 303 | 303 | 'type' => 'integer', |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | 'validate_callback' => 'rest_validate_request_arg', |
| 306 | 306 | ); |
| 307 | 307 | |
| 308 | - $query_params['emoji'] = array( |
|
| 308 | + $query_params[ 'emoji' ] = array( |
|
| 309 | 309 | 'default' => array(), |
| 310 | 310 | 'description' => __( 'The reaction emoji.' ), |
| 311 | 311 | 'type' => 'string', |