@@ -18,18 +18,18 @@ discard block |
||
18 | 18 | public function __construct() { |
19 | 19 | $this->api = new WP_REST_React_Controller(); |
20 | 20 | |
21 | - add_action( 'rest_api_init', array( $this->api, 'register_routes' ) ); |
|
21 | + add_action('rest_api_init', array($this->api, 'register_routes')); |
|
22 | 22 | |
23 | - if ( is_admin() ) { |
|
23 | + if (is_admin()) { |
|
24 | 24 | return; |
25 | 25 | } |
26 | 26 | |
27 | 27 | $this->enqueue(); |
28 | 28 | |
29 | - add_action( 'wp_head', array( $this, 'print_settings' ) ); |
|
30 | - add_action( 'wp_footer', array( $this, 'print_selector' ) ); |
|
29 | + add_action('wp_head', array($this, 'print_settings')); |
|
30 | + add_action('wp_footer', array($this, 'print_selector')); |
|
31 | 31 | |
32 | - add_filter( 'the_content', array( $this, 'the_content' ) ); |
|
32 | + add_filter('the_content', array($this, 'the_content')); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | public static function init() { |
41 | 41 | static $instance; |
42 | 42 | |
43 | - if ( ! $instance ) { |
|
43 | + if (!$instance) { |
|
44 | 44 | $instance = new React; |
45 | 45 | } |
46 | 46 | |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | * Enqueue relevant JS and CSS |
67 | 67 | */ |
68 | 68 | public function enqueue() { |
69 | - wp_enqueue_style( 'react-emoji', REACT_URL . '/static/react.css' ); |
|
69 | + wp_enqueue_style('react-emoji', REACT_URL . '/static/react.css'); |
|
70 | 70 | |
71 | - wp_enqueue_script( 'react-emoji', REACT_URL . '/static/react.js', array(), false, true ); |
|
71 | + wp_enqueue_script('react-emoji', REACT_URL . '/static/react.js', array(), false, true); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -76,34 +76,34 @@ discard block |
||
76 | 76 | * @param string $content The content HTML |
77 | 77 | * @return string The content HTML, with the react buttons attached |
78 | 78 | */ |
79 | - public function the_content( $content ) { |
|
79 | + public function the_content($content) { |
|
80 | 80 | $post_id = get_the_ID(); |
81 | - if ( ! $post_id ) { |
|
81 | + if (!$post_id) { |
|
82 | 82 | return $content; |
83 | 83 | } |
84 | 84 | |
85 | - $reactions = get_comments( array( |
|
85 | + $reactions = get_comments(array( |
|
86 | 86 | 'post_id' => $post_id, |
87 | 87 | 'type' => 'reaction', |
88 | - ) ); |
|
88 | + )); |
|
89 | 89 | |
90 | 90 | $reactions_summary = array(); |
91 | - foreach ( $reactions as $reaction ) { |
|
92 | - if ( ! isset( $reactions_summary[ $reaction->comment_content ] ) ) { |
|
93 | - $reactions_summary[ $reaction->comment_content ] = 0; |
|
91 | + foreach ($reactions as $reaction) { |
|
92 | + if (!isset($reactions_summary[$reaction->comment_content])) { |
|
93 | + $reactions_summary[$reaction->comment_content] = 0; |
|
94 | 94 | } |
95 | 95 | |
96 | - $reactions_summary[ $reaction->comment_content ]++; |
|
96 | + $reactions_summary[$reaction->comment_content]++; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | $content .= '<div class="emoji-reactions">'; |
100 | 100 | |
101 | - foreach ( $reactions_summary as $emoji => $count ) { |
|
101 | + foreach ($reactions_summary as $emoji => $count) { |
|
102 | 102 | $content .= "<div data-emoji='$emoji' data-count='$count' data-post='$post_id' class='emoji-reaction'><div class='emoji'>$emoji</div><div class='count'>$count</div></div>"; |
103 | 103 | } |
104 | 104 | |
105 | 105 | /* translators: This is the emoji used for the "Add new emoji reaction" button */ |
106 | - $content .= "<div data-post='$post_id' class='emoji-reaction-add'><div class='emoji'>" . __( ' |
@@ -1,52 +1,52 @@ |
||
1 | 1 | <?php |
2 | 2 | // Compile emoji data list into an autocompleteable list |
3 | 3 | |
4 | -$contents = file_get_contents( 'https://raw.githubusercontent.com/iamcal/emoji-data/master/emoji.json' ); |
|
5 | -file_put_contents( dirname( __DIR__ ) . '/static/emoji-raw.json', $contents ); |
|
4 | +$contents = file_get_contents('https://raw.githubusercontent.com/iamcal/emoji-data/master/emoji.json'); |
|
5 | +file_put_contents(dirname(__DIR__) . '/static/emoji-raw.json', $contents); |
|
6 | 6 | |
7 | -$data = json_decode( $contents ); |
|
7 | +$data = json_decode($contents); |
|
8 | 8 | $map = array(); |
9 | 9 | |
10 | -$categories = array( 'People', 'Nature', 'Foods', 'Activity', 'Places', 'Objects', 'Symbols', 'Flags' ); |
|
10 | +$categories = array('People', 'Nature', 'Foods', 'Activity', 'Places', 'Objects', 'Symbols', 'Flags'); |
|
11 | 11 | |
12 | -foreach ( $data as $emoji ) { |
|
12 | +foreach ($data as $emoji) { |
|
13 | 13 | // Exclude any not supported by Twemoji |
14 | - if ( empty( $emoji->has_img_twitter ) ) { |
|
14 | + if (empty($emoji->has_img_twitter)) { |
|
15 | 15 | continue; |
16 | 16 | } |
17 | 17 | |
18 | - $category = array_search( $emoji->category, $categories ); |
|
19 | - if ( false === $category ) { |
|
20 | - if ( 0 === strpos( $emoji->short_name, 'flag-' ) ) { |
|
18 | + $category = array_search($emoji->category, $categories); |
|
19 | + if (false === $category) { |
|
20 | + if (0 === strpos($emoji->short_name, 'flag-')) { |
|
21 | 21 | $category = 7; |
22 | 22 | } else { |
23 | 23 | $category = 100; |
24 | 24 | } |
25 | 25 | } |
26 | 26 | $code = "0x" . $emoji->unified; |
27 | - $code = str_replace( '-', "-0x", $code ); |
|
28 | - $code = explode( '-', $code ); |
|
27 | + $code = str_replace('-', "-0x", $code); |
|
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 | ); |
34 | 34 | } |
35 | 35 | |
36 | -ksort( $map ); |
|
36 | +ksort($map); |
|
37 | 37 | |
38 | -foreach ( $map as $category => $emoji_list ) { |
|
39 | - usort( $map[ $category ], function( $a, $b ) { |
|
40 | - if ( $a['sort_order'] == $b['sort_order'] ) { |
|
38 | +foreach ($map as $category => $emoji_list) { |
|
39 | + usort($map[$category], function($a, $b) { |
|
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 | |
52 | -file_put_contents( dirname( __DIR__ ) . '/static/emoji.json', json_encode( $map ) ); |
|
52 | +file_put_contents(dirname(__DIR__) . '/static/emoji.json', json_encode($map)); |