@@ -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__ ) . '/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__).'/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 | - $code = "0x" . $emoji->unified; |
|
27 | - $code = str_replace( '-', "-0x", $code ); |
|
28 | - $code = explode( '-', $code ); |
|
26 | + $code = "0x".$emoji->unified; |
|
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__ ) . '/emoji.json', json_encode( $map ) ); |
|
52 | +file_put_contents(dirname(__DIR__).'/emoji.json', json_encode($map)); |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | public function __construct() { |
13 | 13 | $this->enqueue(); |
14 | 14 | |
15 | - add_action( 'wp_head', array( $this, 'print_settings' ) ); |
|
16 | - add_action( 'wp_footer', array( $this, 'print_selector' ) ); |
|
15 | + add_action('wp_head', array($this, 'print_settings')); |
|
16 | + add_action('wp_footer', array($this, 'print_selector')); |
|
17 | 17 | |
18 | - add_filter( 'the_content', array( $this, 'the_content' ) ); |
|
18 | + add_filter('the_content', array($this, 'the_content')); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | public static function init() { |
27 | 27 | static $instance; |
28 | 28 | |
29 | - if ( ! $instance ) { |
|
29 | + if ( ! $instance) { |
|
30 | 30 | $instance = new React; |
31 | 31 | } |
32 | 32 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | window.wp = window.wp || {}; |
43 | 43 | window.wp.react = window.wp.react || {}; |
44 | 44 | window.wp.react.settings = { |
45 | - emoji_url: '<?php echo plugins_url( 'emoji.json', __FILE__ ) ?>' |
|
45 | + emoji_url: '<?php echo plugins_url('emoji.json', __FILE__) ?>' |
|
46 | 46 | } |
47 | 47 | </script> |
48 | 48 | <?php |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | * Enqueue relevant JS and CSS |
53 | 53 | */ |
54 | 54 | public function enqueue() { |
55 | - wp_enqueue_style( 'react-emoji', plugins_url( 'emoji.css', __FILE__ ) ); |
|
55 | + wp_enqueue_style('react-emoji', plugins_url('emoji.css', __FILE__)); |
|
56 | 56 | |
57 | - wp_enqueue_script( 'react-emoji', plugins_url( 'emoji.js', __FILE__ ), array(), false, true ); |
|
57 | + wp_enqueue_script('react-emoji', plugins_url('emoji.js', __FILE__), array(), false, true); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -62,34 +62,34 @@ discard block |
||
62 | 62 | * @param string $content The content HTML |
63 | 63 | * @return string The content HTML, with the react buttons attached |
64 | 64 | */ |
65 | - public function the_content( $content ) { |
|
65 | + public function the_content($content) { |
|
66 | 66 | $post_id = get_the_ID(); |
67 | - if ( ! $post_id ) { |
|
67 | + if ( ! $post_id) { |
|
68 | 68 | return $content; |
69 | 69 | } |
70 | 70 | |
71 | - $reactions = get_comments( array( |
|
71 | + $reactions = get_comments(array( |
|
72 | 72 | 'post_id' => $post_id, |
73 | 73 | 'type' => 'reaction', |
74 | - ) ); |
|
74 | + )); |
|
75 | 75 | |
76 | 76 | $reactions_summary = array(); |
77 | - foreach( $reactions as $reaction ) { |
|
78 | - if ( ! isset( $reactions_summary[ $reaction->comment_content ] ) ) { |
|
79 | - $reactions_summary[ $reaction->comment_content ] = 0; |
|
77 | + foreach ($reactions as $reaction) { |
|
78 | + if ( ! isset($reactions_summary[$reaction->comment_content])) { |
|
79 | + $reactions_summary[$reaction->comment_content] = 0; |
|
80 | 80 | } |
81 | 81 | |
82 | - $reactions_summary[ $reaction->comment_content ]++; |
|
82 | + $reactions_summary[$reaction->comment_content]++; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | $content .= '<div class="emoji-reactions">'; |
86 | 86 | |
87 | - foreach ( $reactions_summary as $emoji => $count ) { |
|
87 | + foreach ($reactions_summary as $emoji => $count) { |
|
88 | 88 | $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>"; |
89 | 89 | } |
90 | 90 | |
91 | 91 | /* translators: This is the emoji used for the "Add new emoji reaction" button */ |
92 | - $content .= '<div data-post="$post_id" class="emoji-reaction-add"><div class="emoji">' . __( ' |