@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | /** |
28 | 28 | * @since 2.1.0 |
29 | 29 | */ |
30 | - protected $action_types = array( 'fire', 'toggle_on', 'toggle_off' ); |
|
30 | + protected $action_types = array('fire', 'toggle_on', 'toggle_off'); |
|
31 | 31 | |
32 | 32 | /** |
33 | 33 | * @since 2.1.0 |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function get_settings_fields() { |
60 | 60 | |
61 | - $this->settings_fields['points']['label'] = _x( 'Points', 'form label', 'wordpoints' ); |
|
62 | - $this->settings_fields['log_text']['label'] = _x( 'Log Text', 'form label', 'wordpoints' ); |
|
63 | - $this->settings_fields['description']['label'] = _x( 'Description', 'form label', 'wordpoints' ); |
|
61 | + $this->settings_fields['points']['label'] = _x('Points', 'form label', 'wordpoints'); |
|
62 | + $this->settings_fields['log_text']['label'] = _x('Log Text', 'form label', 'wordpoints'); |
|
63 | + $this->settings_fields['description']['label'] = _x('Description', 'form label', 'wordpoints'); |
|
64 | 64 | |
65 | 65 | return parent::get_settings_fields(); |
66 | 66 | } |
@@ -72,8 +72,8 @@ discard block |
||
72 | 72 | |
73 | 73 | $data = parent::get_ui_script_data(); |
74 | 74 | |
75 | - $data['target_label'] = __( 'Award To', 'wordpoints' ); |
|
76 | - $data['periods_label'] = __( 'Award each user no more than once in:', 'wordpoints' ); |
|
75 | + $data['target_label'] = __('Award To', 'wordpoints'); |
|
76 | + $data['periods_label'] = __('Award each user no more than once in:', 'wordpoints'); |
|
77 | 77 | |
78 | 78 | return $data; |
79 | 79 | } |
@@ -87,23 +87,23 @@ discard block |
||
87 | 87 | WordPoints_Hook_Event_Args $event_args |
88 | 88 | ) { |
89 | 89 | |
90 | - if ( ! isset( $settings['points'] ) || false === wordpoints_int( $settings['points'] ) ) { |
|
91 | - $validator->add_error( __( 'Points must be an integer.', 'wordpoints' ), 'points' ); |
|
90 | + if ( ! isset($settings['points']) || false === wordpoints_int($settings['points'])) { |
|
91 | + $validator->add_error(__('Points must be an integer.', 'wordpoints'), 'points'); |
|
92 | 92 | } |
93 | 93 | |
94 | - if ( ! isset( $settings['points_type'] ) || ! wordpoints_is_points_type( $settings['points_type'] ) ) { |
|
95 | - $validator->add_error( __( 'Invalid points type.', 'wordpoints' ), 'points_type' ); |
|
94 | + if ( ! isset($settings['points_type']) || ! wordpoints_is_points_type($settings['points_type'])) { |
|
95 | + $validator->add_error(__('Invalid points type.', 'wordpoints'), 'points_type'); |
|
96 | 96 | } |
97 | 97 | |
98 | - if ( ! isset( $settings['description'] ) ) { |
|
99 | - $validator->add_error( __( 'Description is required.', 'wordpoints' ), 'description' ); |
|
98 | + if ( ! isset($settings['description'])) { |
|
99 | + $validator->add_error(__('Description is required.', 'wordpoints'), 'description'); |
|
100 | 100 | } |
101 | 101 | |
102 | - if ( ! isset( $settings['log_text'] ) ) { |
|
103 | - $validator->add_error( __( 'Log Text is required.', 'wordpoints' ), 'log_text' ); |
|
102 | + if ( ! isset($settings['log_text'])) { |
|
103 | + $validator->add_error(__('Log Text is required.', 'wordpoints'), 'log_text'); |
|
104 | 104 | } |
105 | 105 | |
106 | - return parent::validate_settings( $settings, $validator, $event_args ); |
|
106 | + return parent::validate_settings($settings, $validator, $event_args); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -114,59 +114,59 @@ discard block |
||
114 | 114 | array $settings |
115 | 115 | ) { |
116 | 116 | |
117 | - parent::update_settings( $reaction, $settings ); |
|
117 | + parent::update_settings($reaction, $settings); |
|
118 | 118 | |
119 | - $reaction->update_meta( 'points', $settings['points'] ); |
|
120 | - $reaction->update_meta( 'points_type', $settings['points_type'] ); |
|
121 | - $reaction->update_meta( 'description', $settings['description'] ); |
|
122 | - $reaction->update_meta( 'log_text', $settings['log_text'] ); |
|
119 | + $reaction->update_meta('points', $settings['points']); |
|
120 | + $reaction->update_meta('points_type', $settings['points_type']); |
|
121 | + $reaction->update_meta('description', $settings['description']); |
|
122 | + $reaction->update_meta('log_text', $settings['log_text']); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
126 | 126 | * @since 2.1.0 |
127 | 127 | */ |
128 | - public function hit( WordPoints_Hook_Fire $fire ) { |
|
128 | + public function hit(WordPoints_Hook_Fire $fire) { |
|
129 | 129 | |
130 | - if ( 'toggle_off' === $fire->action_type ) { |
|
131 | - $this->reverse_hit( $fire ); |
|
130 | + if ('toggle_off' === $fire->action_type) { |
|
131 | + $this->reverse_hit($fire); |
|
132 | 132 | return; |
133 | 133 | } |
134 | 134 | |
135 | 135 | $reaction = $fire->reaction; |
136 | 136 | |
137 | 137 | $target = $fire->event_args->get_from_hierarchy( |
138 | - $reaction->get_meta( 'target' ) |
|
138 | + $reaction->get_meta('target') |
|
139 | 139 | ); |
140 | 140 | |
141 | - if ( ! $target instanceof WordPoints_Entity ) { |
|
141 | + if ( ! $target instanceof WordPoints_Entity) { |
|
142 | 142 | return; |
143 | 143 | } |
144 | 144 | |
145 | - $meta = array( 'hook_hit_id' => $fire->hit_id ); |
|
145 | + $meta = array('hook_hit_id' => $fire->hit_id); |
|
146 | 146 | |
147 | - foreach ( $fire->event_args->get_entities() as $entity ) { |
|
148 | - $meta[ $entity->get_slug() ] = $entity->get_the_id(); |
|
149 | - $meta[ $entity->get_slug() . '_guid' ] = $entity->get_the_guid(); |
|
147 | + foreach ($fire->event_args->get_entities() as $entity) { |
|
148 | + $meta[$entity->get_slug()] = $entity->get_the_id(); |
|
149 | + $meta[$entity->get_slug() . '_guid'] = $entity->get_the_guid(); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | wordpoints_alter_points( |
153 | 153 | $target->get_the_id() |
154 | - , $reaction->get_meta( 'points' ) |
|
155 | - , $reaction->get_meta( 'points_type' ) |
|
154 | + , $reaction->get_meta('points') |
|
155 | + , $reaction->get_meta('points_type') |
|
156 | 156 | , $reaction->get_event_slug() |
157 | 157 | , $meta |
158 | - , $reaction->get_meta( 'log_text' ) |
|
158 | + , $reaction->get_meta('log_text') |
|
159 | 159 | ); |
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
163 | 163 | * @since 2.1.0 |
164 | 164 | */ |
165 | - public function reverse_hit( WordPoints_Hook_Fire $fire ) { |
|
165 | + public function reverse_hit(WordPoints_Hook_Fire $fire) { |
|
166 | 166 | |
167 | - $hit_ids = $this->get_hit_ids_to_be_reversed( $fire ); |
|
167 | + $hit_ids = $this->get_hit_ids_to_be_reversed($fire); |
|
168 | 168 | |
169 | - if ( empty( $hit_ids ) ) { |
|
169 | + if (empty($hit_ids)) { |
|
170 | 170 | return; |
171 | 171 | } |
172 | 172 | |
@@ -184,11 +184,11 @@ discard block |
||
184 | 184 | |
185 | 185 | $logs = $query->get(); |
186 | 186 | |
187 | - if ( ! $logs ) { |
|
187 | + if ( ! $logs) { |
|
188 | 188 | return; |
189 | 189 | } |
190 | 190 | |
191 | - $this->reverse_logs( $logs, $fire ); |
|
191 | + $this->reverse_logs($logs, $fire); |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | /** |
@@ -200,10 +200,10 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @return array The IDs of the hits to be reversed. |
202 | 202 | */ |
203 | - protected function get_hit_ids_to_be_reversed( WordPoints_Hook_Fire $fire ) { |
|
203 | + protected function get_hit_ids_to_be_reversed(WordPoints_Hook_Fire $fire) { |
|
204 | 204 | |
205 | 205 | // We closely integrate with the reversals extension to get the hit IDs. |
206 | - if ( ! isset( $fire->data['reversals']['hit_ids'] ) ) { |
|
206 | + if ( ! isset($fire->data['reversals']['hit_ids'])) { |
|
207 | 207 | return array(); |
208 | 208 | } |
209 | 209 | |
@@ -218,28 +218,28 @@ discard block |
||
218 | 218 | * @param object[] $logs The logs to reverse. |
219 | 219 | * @param WordPoints_Hook_Fire $fire The fire object. |
220 | 220 | */ |
221 | - protected function reverse_logs( $logs, WordPoints_Hook_Fire $fire ) { |
|
221 | + protected function reverse_logs($logs, WordPoints_Hook_Fire $fire) { |
|
222 | 222 | |
223 | - $event = wordpoints_hooks()->get_sub_app( 'events' )->get( |
|
223 | + $event = wordpoints_hooks()->get_sub_app('events')->get( |
|
224 | 224 | $fire->reaction->get_event_slug() |
225 | 225 | ); |
226 | 226 | |
227 | - if ( $event instanceof WordPoints_Hook_Event_ReversingI ) { |
|
227 | + if ($event instanceof WordPoints_Hook_Event_ReversingI) { |
|
228 | 228 | |
229 | 229 | /* translators: 1: log text for transaction that is being reversed, 2: the reason that this is being reversed. */ |
230 | - $template = __( 'Reversed “%1$s” (%2$s)', 'wordpoints' ); |
|
230 | + $template = __('Reversed “%1$s” (%2$s)', 'wordpoints'); |
|
231 | 231 | |
232 | 232 | $event_description = $event->get_reversal_text(); |
233 | 233 | |
234 | 234 | } else { |
235 | 235 | |
236 | 236 | /* translators: 1: log text for transaction that is being reversed. */ |
237 | - $template = __( 'Reversed “%1$s”', 'wordpoints' ); |
|
237 | + $template = __('Reversed “%1$s”', 'wordpoints'); |
|
238 | 238 | |
239 | 239 | $event_description = ''; |
240 | 240 | } |
241 | 241 | |
242 | - foreach ( $logs as $log ) { |
|
242 | + foreach ($logs as $log) { |
|
243 | 243 | |
244 | 244 | $log_id = wordpoints_alter_points( |
245 | 245 | $log->user_id |
@@ -250,11 +250,11 @@ discard block |
||
250 | 250 | 'original_log_id' => $log->id, |
251 | 251 | 'hook_hit_id' => $fire->hit_id, |
252 | 252 | ) |
253 | - , sprintf( $template, $log->text, $event_description ) |
|
253 | + , sprintf($template, $log->text, $event_description) |
|
254 | 254 | ); |
255 | 255 | |
256 | 256 | // Mark the old log as reversed by this one. |
257 | - wordpoints_update_points_log_meta( $log->id, 'auto_reversed', $log_id ); |
|
257 | + wordpoints_update_points_log_meta($log->id, 'auto_reversed', $log_id); |
|
258 | 258 | } |
259 | 259 | } |
260 | 260 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | public function get_title() { |
25 | 25 | |
26 | 26 | // translators: hook event title. |
27 | - return sprintf( __( '%s (Legacy)', 'wordpoints' ), parent::get_title() ); |
|
27 | + return sprintf(__('%s (Legacy)', 'wordpoints'), parent::get_title()); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -45,20 +45,20 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function get_reversal_text() { |
47 | 47 | |
48 | - $parsed = wordpoints_parse_dynamic_slug( $this->slug ); |
|
48 | + $parsed = wordpoints_parse_dynamic_slug($this->slug); |
|
49 | 49 | |
50 | - switch ( $parsed['dynamic'] ) { |
|
50 | + switch ($parsed['dynamic']) { |
|
51 | 51 | |
52 | 52 | case 'post': |
53 | - return __( 'Post deleted.', 'wordpoints' ); |
|
53 | + return __('Post deleted.', 'wordpoints'); |
|
54 | 54 | |
55 | 55 | case 'page': |
56 | - return __( 'Page deleted.', 'wordpoints' ); |
|
56 | + return __('Page deleted.', 'wordpoints'); |
|
57 | 57 | |
58 | 58 | default: |
59 | 59 | return sprintf( |
60 | 60 | // translators: singular name of the post type |
61 | - _x( '%s deleted.', 'post type', 'wordpoints' ) |
|
61 | + _x('%s deleted.', 'post type', 'wordpoints') |
|
62 | 62 | , $this->get_entity_title() |
63 | 63 | ); |
64 | 64 | } |
@@ -27,21 +27,21 @@ discard block |
||
27 | 27 | array $settings |
28 | 28 | ) { |
29 | 29 | |
30 | - if ( isset( $settings['legacy_log_type'] ) ) { |
|
30 | + if (isset($settings['legacy_log_type'])) { |
|
31 | 31 | $reaction->update_meta( |
32 | 32 | 'legacy_log_type', |
33 | 33 | $settings['legacy_log_type'] |
34 | 34 | ); |
35 | 35 | } |
36 | 36 | |
37 | - if ( isset( $settings['legacy_meta_key'] ) ) { |
|
37 | + if (isset($settings['legacy_meta_key'])) { |
|
38 | 38 | $reaction->update_meta( |
39 | 39 | 'legacy_meta_key', |
40 | 40 | $settings['legacy_meta_key'] |
41 | 41 | ); |
42 | 42 | } |
43 | 43 | |
44 | - parent::update_settings( $reaction, $settings ); |
|
44 | + parent::update_settings($reaction, $settings); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | /** |
60 | 60 | * @since 2.1.0 |
61 | 61 | */ |
62 | - public function reverse_hit( WordPoints_Hook_Fire $fire ) { |
|
62 | + public function reverse_hit(WordPoints_Hook_Fire $fire) { |
|
63 | 63 | |
64 | - if ( isset( $fire->data['points_legacy_reversals']['points_logs'] ) ) { |
|
64 | + if (isset($fire->data['points_legacy_reversals']['points_logs'])) { |
|
65 | 65 | |
66 | 66 | $this->reverse_logs( |
67 | 67 | $fire->data['points_legacy_reversals']['points_logs'] |
@@ -69,17 +69,17 @@ discard block |
||
69 | 69 | ); |
70 | 70 | |
71 | 71 | } else { |
72 | - parent::reverse_hit( $fire ); |
|
72 | + parent::reverse_hit($fire); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
77 | 77 | * @since 2.1.0 |
78 | 78 | */ |
79 | - protected function get_hit_ids_to_be_reversed( WordPoints_Hook_Fire $fire ) { |
|
79 | + protected function get_hit_ids_to_be_reversed(WordPoints_Hook_Fire $fire) { |
|
80 | 80 | |
81 | 81 | // We closely integrate with the legacy reversals extension to get the IDs. |
82 | - if ( ! isset( $fire->data['points_legacy_reversals']['hit_ids'] ) ) { |
|
82 | + if ( ! isset($fire->data['points_legacy_reversals']['hit_ids'])) { |
|
83 | 83 | return array(); |
84 | 84 | } |
85 | 85 |
@@ -30,21 +30,21 @@ discard block |
||
30 | 30 | /** |
31 | 31 | * @since 1.8.0 |
32 | 32 | */ |
33 | - public function __construct( $title, $args ) { |
|
33 | + public function __construct($title, $args) { |
|
34 | 34 | |
35 | 35 | $defaults = array( |
36 | - 'post_type_filter' => array( $this, 'post_type_supports_comments' ), |
|
36 | + 'post_type_filter' => array($this, 'post_type_supports_comments'), |
|
37 | 37 | ); |
38 | 38 | |
39 | - $args = array_merge( $defaults, $args ); |
|
39 | + $args = array_merge($defaults, $args); |
|
40 | 40 | |
41 | - parent::__construct( $title, $args ); |
|
41 | + parent::__construct($title, $args); |
|
42 | 42 | |
43 | - add_action( 'transition_comment_status', array( $this, 'hook' ), 10, 3 ); |
|
44 | - add_action( 'transition_comment_status', array( $this, 'reverse_hook' ), 10, 3 ); |
|
45 | - add_action( 'wp_insert_comment', array( $this, 'new_comment_hook' ), 10, 2 ); |
|
43 | + add_action('transition_comment_status', array($this, 'hook'), 10, 3); |
|
44 | + add_action('transition_comment_status', array($this, 'reverse_hook'), 10, 3); |
|
45 | + add_action('wp_insert_comment', array($this, 'new_comment_hook'), 10, 2); |
|
46 | 46 | |
47 | - add_action( 'delete_comment', array( $this, 'clean_logs_on_comment_deletion' ) ); |
|
47 | + add_action('delete_comment', array($this, 'clean_logs_on_comment_deletion')); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
@@ -62,46 +62,46 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @return void |
64 | 64 | */ |
65 | - public function hook( $new_status, $old_status, $comment ) { |
|
65 | + public function hook($new_status, $old_status, $comment) { |
|
66 | 66 | |
67 | - if ( $this->shortcircuit_hook( $new_status, $old_status, $comment ) ) { |
|
67 | + if ($this->shortcircuit_hook($new_status, $old_status, $comment)) { |
|
68 | 68 | return; |
69 | 69 | } |
70 | 70 | |
71 | - $post = get_post( $comment->comment_post_ID ); |
|
71 | + $post = get_post($comment->comment_post_ID); |
|
72 | 72 | |
73 | - if ( ! $post ) { |
|
73 | + if ( ! $post) { |
|
74 | 74 | return; |
75 | 75 | } |
76 | 76 | |
77 | - foreach ( $this->get_instances() as $number => $instance ) { |
|
77 | + foreach ($this->get_instances() as $number => $instance) { |
|
78 | 78 | |
79 | - $instance = array_merge( $this->defaults, $instance ); |
|
79 | + $instance = array_merge($this->defaults, $instance); |
|
80 | 80 | |
81 | - $points_type = $this->points_type( $number ); |
|
81 | + $points_type = $this->points_type($number); |
|
82 | 82 | |
83 | - $meta_key = $this->get_last_status_comment_meta_key( $points_type ); |
|
83 | + $meta_key = $this->get_last_status_comment_meta_key($points_type); |
|
84 | 84 | |
85 | - $last_status = get_comment_meta( $comment->comment_ID, $meta_key, true ); |
|
85 | + $last_status = get_comment_meta($comment->comment_ID, $meta_key, true); |
|
86 | 86 | |
87 | 87 | if ( |
88 | 88 | 'approved' === $last_status |
89 | - || ! $this->is_matching_post_type( $post->post_type, $instance['post_type'] ) |
|
89 | + || ! $this->is_matching_post_type($post->post_type, $instance['post_type']) |
|
90 | 90 | ) { |
91 | 91 | continue; |
92 | 92 | } |
93 | 93 | |
94 | 94 | wordpoints_add_points( |
95 | - $this->select_user_to_award( $comment, $post ) |
|
95 | + $this->select_user_to_award($comment, $post) |
|
96 | 96 | , $instance['points'] |
97 | 97 | , $points_type |
98 | 98 | , $this->log_type |
99 | - , array( 'comment_id' => $comment->comment_ID ) |
|
99 | + , array('comment_id' => $comment->comment_ID) |
|
100 | 100 | ); |
101 | 101 | |
102 | 102 | update_comment_meta( |
103 | 103 | $comment->comment_ID |
104 | - , wp_slash( $meta_key ) |
|
104 | + , wp_slash($meta_key) |
|
105 | 105 | , 'approved' |
106 | 106 | , $last_status |
107 | 107 | ); |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | * |
120 | 120 | * @return bool Whether the hook should shortcircuit and not award any points. |
121 | 121 | */ |
122 | - protected function shortcircuit_hook( $new_status, $old_status, $comment ) { |
|
122 | + protected function shortcircuit_hook($new_status, $old_status, $comment) { |
|
123 | 123 | |
124 | - if ( 'approved' !== $new_status || $old_status === $new_status ) { |
|
124 | + if ('approved' !== $new_status || $old_status === $new_status) { |
|
125 | 125 | return true; |
126 | 126 | } |
127 | 127 | |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | * |
148 | 148 | * @return void |
149 | 149 | */ |
150 | - public function new_comment_hook( $comment_id, $comment ) { |
|
150 | + public function new_comment_hook($comment_id, $comment) { |
|
151 | 151 | |
152 | - switch ( $comment->comment_approved ) { |
|
152 | + switch ($comment->comment_approved) { |
|
153 | 153 | |
154 | 154 | // Comment hasn't been approved yet. |
155 | 155 | case 0: return; |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | $old_status = 'approved'; |
167 | 167 | } |
168 | 168 | |
169 | - $this->hook( $new_status, $old_status, $comment ); |
|
169 | + $this->hook($new_status, $old_status, $comment); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | /** |
@@ -182,14 +182,14 @@ discard block |
||
182 | 182 | * |
183 | 183 | * @return void |
184 | 184 | */ |
185 | - public function reverse_hook( $new_status, $old_status, $comment ) { |
|
185 | + public function reverse_hook($new_status, $old_status, $comment) { |
|
186 | 186 | |
187 | - if ( 'approved' !== $old_status || $old_status === $new_status ) { |
|
187 | + if ('approved' !== $old_status || $old_status === $new_status) { |
|
188 | 188 | return; |
189 | 189 | } |
190 | 190 | |
191 | - $post_type = get_post_field( 'post_type', $comment->comment_post_ID ); |
|
192 | - if ( ! $this->should_do_auto_reversals_for_post_type( $post_type ) ) { |
|
191 | + $post_type = get_post_field('post_type', $comment->comment_post_ID); |
|
192 | + if ( ! $this->should_do_auto_reversals_for_post_type($post_type)) { |
|
193 | 193 | return; |
194 | 194 | } |
195 | 195 | |
@@ -200,17 +200,17 @@ discard block |
||
200 | 200 | ) |
201 | 201 | ); |
202 | 202 | |
203 | - foreach ( $logs as $log ) { |
|
203 | + foreach ($logs as $log) { |
|
204 | 204 | |
205 | - $meta_key = $this->get_last_status_comment_meta_key( $log->points_type ); |
|
205 | + $meta_key = $this->get_last_status_comment_meta_key($log->points_type); |
|
206 | 206 | |
207 | - if ( 'approved' !== get_comment_meta( $comment->comment_ID, $meta_key, true ) ) { |
|
207 | + if ('approved' !== get_comment_meta($comment->comment_ID, $meta_key, true)) { |
|
208 | 208 | continue; |
209 | 209 | } |
210 | 210 | |
211 | - $this->auto_reverse_log( $log ); |
|
211 | + $this->auto_reverse_log($log); |
|
212 | 212 | |
213 | - delete_comment_meta( $comment->comment_ID, wp_slash( $meta_key ) ); |
|
213 | + delete_comment_meta($comment->comment_ID, wp_slash($meta_key)); |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | * |
229 | 229 | * @return int The ID of the user the points should be awarded to. |
230 | 230 | */ |
231 | - protected function select_user_to_award( $comment, $post ) { |
|
231 | + protected function select_user_to_award($comment, $post) { |
|
232 | 232 | return $comment->user_id; |
233 | 233 | } |
234 | 234 | |
@@ -248,30 +248,30 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @return string |
250 | 250 | */ |
251 | - public function logs( $text, $points, $points_type, $user_id, $log_type, $meta ) { |
|
251 | + public function logs($text, $points, $points_type, $user_id, $log_type, $meta) { |
|
252 | 252 | |
253 | 253 | $reverse = ''; |
254 | 254 | |
255 | - if ( "reverse_{$this->log_type}" === $log_type ) { |
|
255 | + if ("reverse_{$this->log_type}" === $log_type) { |
|
256 | 256 | $reverse = '_reverse'; |
257 | 257 | } |
258 | 258 | |
259 | 259 | $comment = false; |
260 | 260 | |
261 | - if ( isset( $meta['comment_id'] ) ) { |
|
262 | - $comment = get_comment( $meta['comment_id'] ); |
|
261 | + if (isset($meta['comment_id'])) { |
|
262 | + $comment = get_comment($meta['comment_id']); |
|
263 | 263 | } |
264 | 264 | |
265 | - if ( ! $comment ) { |
|
265 | + if ( ! $comment) { |
|
266 | 266 | |
267 | - $text = parent::logs( $text, $points, $points_type, $user_id, $log_type, $meta ); |
|
267 | + $text = parent::logs($text, $points, $points_type, $user_id, $log_type, $meta); |
|
268 | 268 | |
269 | 269 | } else { |
270 | 270 | |
271 | 271 | $text = $this->log_with_post_title_link( |
272 | 272 | $comment->comment_post_ID |
273 | 273 | , $reverse |
274 | - , get_comment_link( $comment ) |
|
274 | + , get_comment_link($comment) |
|
275 | 275 | ); |
276 | 276 | } |
277 | 277 | |
@@ -287,11 +287,11 @@ discard block |
||
287 | 287 | * |
288 | 288 | * @return string The meta key where the last status is stored. |
289 | 289 | */ |
290 | - protected function get_last_status_comment_meta_key( $points_type ) { |
|
290 | + protected function get_last_status_comment_meta_key($points_type) { |
|
291 | 291 | |
292 | - $meta_key = $this->get_option( 'last_status_meta_key' ); |
|
292 | + $meta_key = $this->get_option('last_status_meta_key'); |
|
293 | 293 | |
294 | - if ( empty( $meta_key ) ) { |
|
294 | + if (empty($meta_key)) { |
|
295 | 295 | $meta_key = "wordpoints_last_status-{$this->log_type}"; |
296 | 296 | } |
297 | 297 | |
@@ -313,16 +313,16 @@ discard block |
||
313 | 313 | * |
314 | 314 | * @param int $comment_id The ID of the comment being deleted. |
315 | 315 | */ |
316 | - public function clean_logs_on_comment_deletion( $comment_id ) { |
|
316 | + public function clean_logs_on_comment_deletion($comment_id) { |
|
317 | 317 | |
318 | 318 | $post_id = false; |
319 | - $comment = get_comment( $comment_id ); |
|
319 | + $comment = get_comment($comment_id); |
|
320 | 320 | |
321 | - if ( $comment ) { |
|
321 | + if ($comment) { |
|
322 | 322 | $post_id = $comment->comment_post_ID; |
323 | 323 | } |
324 | 324 | |
325 | - $this->clean_logs( 'comment_id', $comment_id, 'post_id', $post_id ); |
|
325 | + $this->clean_logs('comment_id', $comment_id, 'post_id', $post_id); |
|
326 | 326 | } |
327 | 327 | |
328 | 328 | /** |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | * |
341 | 341 | * @return bool Whether the user can view this log. |
342 | 342 | */ |
343 | - public function user_can_view( $can_view, $log, $user_id ) { |
|
343 | + public function user_can_view($can_view, $log, $user_id) { |
|
344 | 344 | |
345 | 345 | _deprecated_function( |
346 | 346 | __METHOD__ |
@@ -348,13 +348,13 @@ discard block |
||
348 | 348 | , 'the points logs viewing restrictions API' |
349 | 349 | ); |
350 | 350 | |
351 | - if ( $can_view ) { |
|
351 | + if ($can_view) { |
|
352 | 352 | |
353 | 353 | $restriction = new WordPoints_Points_Logs_Viewing_Restriction_Read_Post( |
354 | 354 | $log |
355 | 355 | ); |
356 | 356 | |
357 | - $can_view = $restriction->user_can( $user_id ); |
|
357 | + $can_view = $restriction->user_can($user_id); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | return $can_view; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @type array $defaults |
26 | 26 | */ |
27 | - protected $defaults = array( 'period' => DAY_IN_SECONDS, 'points' => 10 ); |
|
27 | + protected $defaults = array('period' => DAY_IN_SECONDS, 'points' => 10); |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * Initialize the hook. |
@@ -37,13 +37,13 @@ discard block |
||
37 | 37 | public function __construct() { |
38 | 38 | |
39 | 39 | $this->init( |
40 | - _x( 'Periodic Points', 'points hook name', 'wordpoints' ) |
|
41 | - , array( 'description' => __( 'Visiting the site at least once in a given time period.', 'wordpoints' ) ) |
|
40 | + _x('Periodic Points', 'points hook name', 'wordpoints') |
|
41 | + , array('description' => __('Visiting the site at least once in a given time period.', 'wordpoints')) |
|
42 | 42 | ); |
43 | 43 | |
44 | - add_action( 'init', array( $this, 'hook' ) ); |
|
44 | + add_action('init', array($this, 'hook')); |
|
45 | 45 | |
46 | - add_filter( 'wordpoints_points_log-periodic', array( $this, 'logs' ), 10, 6 ); |
|
46 | + add_filter('wordpoints_points_log-periodic', array($this, 'logs'), 10, 6); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -59,33 +59,33 @@ discard block |
||
59 | 59 | |
60 | 60 | $user_id = get_current_user_id(); |
61 | 61 | |
62 | - if ( ! $user_id ) { |
|
62 | + if ( ! $user_id) { |
|
63 | 63 | return; |
64 | 64 | } |
65 | 65 | |
66 | - $last_visit = get_user_option( 'wordpoints_points_period_start', $user_id ); |
|
66 | + $last_visit = get_user_option('wordpoints_points_period_start', $user_id); |
|
67 | 67 | |
68 | - if ( ! is_array( $last_visit ) ) { |
|
68 | + if ( ! is_array($last_visit)) { |
|
69 | 69 | $last_visit = array(); |
70 | 70 | } |
71 | 71 | |
72 | - $now = current_time( 'timestamp' ); |
|
72 | + $now = current_time('timestamp'); |
|
73 | 73 | |
74 | 74 | $awarded_points = false; |
75 | 75 | |
76 | - foreach ( $this->get_instances() as $number => $instance ) { |
|
76 | + foreach ($this->get_instances() as $number => $instance) { |
|
77 | 77 | |
78 | - $instance = array_merge( $this->defaults, $instance ); |
|
78 | + $instance = array_merge($this->defaults, $instance); |
|
79 | 79 | |
80 | - $points_type = $this->points_type( $number ); |
|
80 | + $points_type = $this->points_type($number); |
|
81 | 81 | |
82 | - if ( ! $points_type ) { |
|
82 | + if ( ! $points_type) { |
|
83 | 83 | continue; |
84 | 84 | } |
85 | 85 | |
86 | 86 | if ( |
87 | - ! isset( $last_visit[ $points_type ] ) |
|
88 | - || (int) ( $last_visit[ $points_type ] / $instance['period'] ) < (int) ( $now / $instance['period'] ) |
|
87 | + ! isset($last_visit[$points_type]) |
|
88 | + || (int) ($last_visit[$points_type] / $instance['period']) < (int) ($now / $instance['period']) |
|
89 | 89 | ) { |
90 | 90 | |
91 | 91 | wordpoints_add_points( |
@@ -93,23 +93,23 @@ discard block |
||
93 | 93 | , $instance['points'] |
94 | 94 | , $points_type |
95 | 95 | , 'periodic' |
96 | - , array( 'period' => $instance['period'] ) |
|
96 | + , array('period' => $instance['period']) |
|
97 | 97 | ); |
98 | 98 | |
99 | - $last_visit[ $points_type ] = $now; |
|
99 | + $last_visit[$points_type] = $now; |
|
100 | 100 | |
101 | 101 | $awarded_points = true; |
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
105 | - if ( $awarded_points ) { |
|
105 | + if ($awarded_points) { |
|
106 | 106 | |
107 | - $global = ( ! is_multisite() || is_wordpoints_network_active() ); |
|
107 | + $global = ( ! is_multisite() || is_wordpoints_network_active()); |
|
108 | 108 | |
109 | 109 | update_user_option( |
110 | 110 | $user_id |
111 | 111 | , 'wordpoints_points_period_start' |
112 | - , wp_slash( $last_visit ) |
|
112 | + , wp_slash($last_visit) |
|
113 | 113 | , $global |
114 | 114 | ); |
115 | 115 | } |
@@ -131,28 +131,28 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @return string |
133 | 133 | */ |
134 | - public function logs( $text, $points, $points_type, $user_id, $log_type, $meta ) { |
|
134 | + public function logs($text, $points, $points_type, $user_id, $log_type, $meta) { |
|
135 | 135 | |
136 | - switch ( $meta['period'] ) { |
|
136 | + switch ($meta['period']) { |
|
137 | 137 | |
138 | 138 | case HOUR_IN_SECONDS: |
139 | - $message = _x( 'Hourly points.', 'points log description', 'wordpoints' ); |
|
139 | + $message = _x('Hourly points.', 'points log description', 'wordpoints'); |
|
140 | 140 | break; |
141 | 141 | |
142 | 142 | case DAY_IN_SECONDS: |
143 | - $message = _x( 'Daily points.', 'points log description', 'wordpoints' ); |
|
143 | + $message = _x('Daily points.', 'points log description', 'wordpoints'); |
|
144 | 144 | break; |
145 | 145 | |
146 | 146 | case WEEK_IN_SECONDS: |
147 | - $message = _x( 'Weekly points.', 'points log description', 'wordpoints' ); |
|
147 | + $message = _x('Weekly points.', 'points log description', 'wordpoints'); |
|
148 | 148 | break; |
149 | 149 | |
150 | 150 | case 30 * DAY_IN_SECONDS: |
151 | - $message = _x( 'Monthly points.', 'points log description', 'wordpoints' ); |
|
151 | + $message = _x('Monthly points.', 'points log description', 'wordpoints'); |
|
152 | 152 | break; |
153 | 153 | |
154 | 154 | default: |
155 | - $message = _x( 'Periodic points.', 'points log description', 'wordpoints' ); |
|
155 | + $message = _x('Periodic points.', 'points log description', 'wordpoints'); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | return $message; |
@@ -167,30 +167,30 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @return string A description for the hook instance. |
169 | 169 | */ |
170 | - protected function generate_description( $instance = array() ) { |
|
170 | + protected function generate_description($instance = array()) { |
|
171 | 171 | |
172 | - if ( ! empty( $instance['period'] ) ) { |
|
172 | + if ( ! empty($instance['period'])) { |
|
173 | 173 | |
174 | - switch ( $instance['period'] ) { |
|
174 | + switch ($instance['period']) { |
|
175 | 175 | |
176 | 176 | case HOUR_IN_SECONDS: |
177 | - return __( 'Visiting the site at least once in an hour.', 'wordpoints' ); |
|
177 | + return __('Visiting the site at least once in an hour.', 'wordpoints'); |
|
178 | 178 | |
179 | 179 | case DAY_IN_SECONDS: |
180 | - return __( 'Visiting the site at least once in a day.', 'wordpoints' ); |
|
180 | + return __('Visiting the site at least once in a day.', 'wordpoints'); |
|
181 | 181 | |
182 | 182 | case WEEK_IN_SECONDS: |
183 | - return __( 'Visiting the site at least once in a week.', 'wordpoints' ); |
|
183 | + return __('Visiting the site at least once in a week.', 'wordpoints'); |
|
184 | 184 | |
185 | 185 | case 30 * DAY_IN_SECONDS: |
186 | - return __( 'Visiting the site at least once in a month.', 'wordpoints' ); |
|
186 | + return __('Visiting the site at least once in a month.', 'wordpoints'); |
|
187 | 187 | |
188 | 188 | default: |
189 | - return __( 'Visiting the site periodically.', 'wordpoints' ); |
|
189 | + return __('Visiting the site periodically.', 'wordpoints'); |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | |
193 | - return parent::generate_description( $instance ); |
|
193 | + return parent::generate_description($instance); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
@@ -203,12 +203,12 @@ discard block |
||
203 | 203 | * |
204 | 204 | * @return array Settings to save. |
205 | 205 | */ |
206 | - protected function update( $new_instance, $old_instance ) { |
|
206 | + protected function update($new_instance, $old_instance) { |
|
207 | 207 | |
208 | - $new_instance = array_merge( $this->defaults, $old_instance, $new_instance ); |
|
208 | + $new_instance = array_merge($this->defaults, $old_instance, $new_instance); |
|
209 | 209 | |
210 | - wordpoints_posint( $new_instance['points'] ); |
|
211 | - wordpoints_posint( $new_instance['period'] ); |
|
210 | + wordpoints_posint($new_instance['points']); |
|
211 | + wordpoints_posint($new_instance['period']); |
|
212 | 212 | |
213 | 213 | return $new_instance; |
214 | 214 | } |
@@ -222,25 +222,25 @@ discard block |
||
222 | 222 | * |
223 | 223 | * @return bool True. |
224 | 224 | */ |
225 | - protected function form( $instance ) { |
|
225 | + protected function form($instance) { |
|
226 | 226 | |
227 | - $instance = array_merge( $this->defaults, $instance ); |
|
227 | + $instance = array_merge($this->defaults, $instance); |
|
228 | 228 | |
229 | 229 | $dropdown_args = array( |
230 | 230 | 'selected' => $instance['period'], |
231 | - 'id' => $this->get_field_id( 'period' ), |
|
232 | - 'name' => $this->get_field_name( 'period' ), |
|
231 | + 'id' => $this->get_field_id('period'), |
|
232 | + 'name' => $this->get_field_name('period'), |
|
233 | 233 | 'class' => 'widefat wordpoints-append-to-hook-title', |
234 | 234 | ); |
235 | 235 | |
236 | - $dropdown = new WordPoints_Dropdown_Builder( $this->get_periods(), $dropdown_args ); |
|
236 | + $dropdown = new WordPoints_Dropdown_Builder($this->get_periods(), $dropdown_args); |
|
237 | 237 | |
238 | - parent::form( $instance ); |
|
238 | + parent::form($instance); |
|
239 | 239 | |
240 | 240 | ?> |
241 | 241 | |
242 | 242 | <p> |
243 | - <label for="<?php $this->the_field_id( 'period' ); ?>"><?php echo esc_html_x( 'Period:', 'length of time', 'wordpoints' ); ?></label> |
|
243 | + <label for="<?php $this->the_field_id('period'); ?>"><?php echo esc_html_x('Period:', 'length of time', 'wordpoints'); ?></label> |
|
244 | 244 | <?php $dropdown->display(); ?> |
245 | 245 | </p> |
246 | 246 | |
@@ -261,10 +261,10 @@ discard block |
||
261 | 261 | protected function get_periods() { |
262 | 262 | |
263 | 263 | $periods = array( |
264 | - HOUR_IN_SECONDS => __( 'hourly', 'wordpoints' ), |
|
265 | - DAY_IN_SECONDS => __( 'daily', 'wordpoints' ), |
|
266 | - WEEK_IN_SECONDS => __( 'weekly', 'wordpoints' ), |
|
267 | - 30 * DAY_IN_SECONDS => __( 'monthly', 'wordpoints' ), |
|
264 | + HOUR_IN_SECONDS => __('hourly', 'wordpoints'), |
|
265 | + DAY_IN_SECONDS => __('daily', 'wordpoints'), |
|
266 | + WEEK_IN_SECONDS => __('weekly', 'wordpoints'), |
|
267 | + 30 * DAY_IN_SECONDS => __('monthly', 'wordpoints'), |
|
268 | 268 | ); |
269 | 269 | |
270 | 270 | /** |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | * @param array $periods The default periods. Values are period names, keys |
276 | 276 | * length of periods in seconds. |
277 | 277 | */ |
278 | - return apply_filters( 'wordpoints_points_periods', $periods ); |
|
278 | + return apply_filters('wordpoints_points_periods', $periods); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | } // class WordPoints_Periodic_Points_Hook |
@@ -52,37 +52,37 @@ discard block |
||
52 | 52 | public function __construct() { |
53 | 53 | |
54 | 54 | parent::__construct( |
55 | - _x( 'Post Publish', 'points hook name', 'wordpoints' ) |
|
55 | + _x('Post Publish', 'points hook name', 'wordpoints') |
|
56 | 56 | , array( |
57 | - 'description' => __( 'New post published.', 'wordpoints' ), |
|
57 | + 'description' => __('New post published.', 'wordpoints'), |
|
58 | 58 | /* translators: the post type name. */ |
59 | - 'post_type_description' => __( 'New %s published.', 'wordpoints' ), |
|
59 | + 'post_type_description' => __('New %s published.', 'wordpoints'), |
|
60 | 60 | /* translators: %s will be a link to the post. */ |
61 | - 'log_text_post_title' => _x( 'Post %s published.', 'points log description', 'wordpoints' ), |
|
61 | + 'log_text_post_title' => _x('Post %s published.', 'points log description', 'wordpoints'), |
|
62 | 62 | /* translators: 1 is the post type name, 2 is a link to the post. */ |
63 | - 'log_text_post_title_and_type' => _x( '%2$s %1$s published.', 'points log description', 'wordpoints' ), |
|
63 | + 'log_text_post_title_and_type' => _x('%2$s %1$s published.', 'points log description', 'wordpoints'), |
|
64 | 64 | /* translators: %s is the name of a post type. */ |
65 | - 'log_text_post_type' => _x( '%s published.', 'points log description', 'wordpoints' ), |
|
66 | - 'log_text_no_post_title' => _x( 'Post published.', 'points log description', 'wordpoints' ), |
|
65 | + 'log_text_post_type' => _x('%s published.', 'points log description', 'wordpoints'), |
|
66 | + 'log_text_no_post_title' => _x('Post published.', 'points log description', 'wordpoints'), |
|
67 | 67 | /* translators: %s is the name of a post type. */ |
68 | - 'log_text_post_type_reverse' => _x( '%s deleted.', 'points log description', 'wordpoints' ), |
|
68 | + 'log_text_post_type_reverse' => _x('%s deleted.', 'points log description', 'wordpoints'), |
|
69 | 69 | /* translators: 1 is the post type name, 2 is the post title. */ |
70 | - 'log_text_post_title_and_type_reverse' => _x( '%1$s “%2$s” deleted.', 'points log description', 'wordpoints' ), |
|
70 | + 'log_text_post_title_and_type_reverse' => _x('%1$s “%2$s” deleted.', 'points log description', 'wordpoints'), |
|
71 | 71 | /* translators: %s will be the post title. */ |
72 | - 'log_text_post_title_reverse' => _x( 'Post “%s” deleted.', 'points log description', 'wordpoints' ), |
|
73 | - 'log_text_no_post_title_reverse' => _x( 'Post deleted.', 'points log description', 'wordpoints' ), |
|
72 | + 'log_text_post_title_reverse' => _x('Post “%s” deleted.', 'points log description', 'wordpoints'), |
|
73 | + 'log_text_no_post_title_reverse' => _x('Post deleted.', 'points log description', 'wordpoints'), |
|
74 | 74 | ) |
75 | 75 | ); |
76 | 76 | |
77 | - if ( get_site_option( 'wordpoints_post_hook_legacy' ) ) { |
|
77 | + if (get_site_option('wordpoints_post_hook_legacy')) { |
|
78 | 78 | $this->set_option( |
79 | 79 | 'disable_auto_reverse_label' |
80 | - , __( 'Revoke the points if the post is permanently deleted.', 'wordpoints' ) |
|
80 | + , __('Revoke the points if the post is permanently deleted.', 'wordpoints') |
|
81 | 81 | ); |
82 | 82 | } |
83 | 83 | |
84 | - add_action( 'transition_post_status', array( $this, 'hook' ), 10, 3 ); |
|
85 | - add_action( 'delete_post', array( $this, 'reverse_hook' ) ); |
|
84 | + add_action('transition_post_status', array($this, 'hook'), 10, 3); |
|
85 | + add_action('delete_post', array($this, 'reverse_hook')); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -98,29 +98,29 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @return void |
100 | 100 | */ |
101 | - public function hook( $new_status, $old_status, $post ) { |
|
101 | + public function hook($new_status, $old_status, $post) { |
|
102 | 102 | |
103 | - if ( 'publish' !== $new_status ) { |
|
103 | + if ('publish' !== $new_status) { |
|
104 | 104 | return; |
105 | 105 | } |
106 | 106 | |
107 | - foreach ( $this->get_instances() as $number => $instance ) { |
|
107 | + foreach ($this->get_instances() as $number => $instance) { |
|
108 | 108 | |
109 | - $instance = array_merge( $this->defaults, $instance ); |
|
109 | + $instance = array_merge($this->defaults, $instance); |
|
110 | 110 | |
111 | - $points_type = $this->points_type( $number ); |
|
111 | + $points_type = $this->points_type($number); |
|
112 | 112 | |
113 | 113 | if ( |
114 | - $this->is_matching_post_type( $post->post_type, $instance['post_type'] ) |
|
115 | - && ! $this->awarded_points_already( $post->ID, $points_type ) |
|
114 | + $this->is_matching_post_type($post->post_type, $instance['post_type']) |
|
115 | + && ! $this->awarded_points_already($post->ID, $points_type) |
|
116 | 116 | ) { |
117 | 117 | |
118 | - if ( isset( $instance['publish'] ) ) { |
|
119 | - _deprecated_argument( __METHOD__, '1.4.0', 'The "publish" hook setting is no longer used to hold the value for the points. Use "points" instead.' ); |
|
118 | + if (isset($instance['publish'])) { |
|
119 | + _deprecated_argument(__METHOD__, '1.4.0', 'The "publish" hook setting is no longer used to hold the value for the points. Use "points" instead.'); |
|
120 | 120 | $instance['points'] = $instance['publish']; |
121 | 121 | } |
122 | 122 | |
123 | - if ( ! isset( $instance['points'] ) ) { |
|
123 | + if ( ! isset($instance['points'])) { |
|
124 | 124 | continue; |
125 | 125 | } |
126 | 126 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | , $instance['points'] |
130 | 130 | , $points_type |
131 | 131 | , 'post_publish' |
132 | - , array( 'post_id' => $post->ID ) |
|
132 | + , array('post_id' => $post->ID) |
|
133 | 133 | ); |
134 | 134 | } |
135 | 135 | } |
@@ -147,11 +147,11 @@ discard block |
||
147 | 147 | * |
148 | 148 | * @return void |
149 | 149 | */ |
150 | - public function publish_hook( $new_status, $old_status, $post ) { |
|
150 | + public function publish_hook($new_status, $old_status, $post) { |
|
151 | 151 | |
152 | - _deprecated_function( __METHOD__, '2.0.0', __CLASS__ . '::hook' ); |
|
152 | + _deprecated_function(__METHOD__, '2.0.0', __CLASS__ . '::hook'); |
|
153 | 153 | |
154 | - $this->hook( $new_status, $old_status, $post ); |
|
154 | + $this->hook($new_status, $old_status, $post); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -163,10 +163,10 @@ discard block |
||
163 | 163 | * |
164 | 164 | * @param int $post_id The ID of the post being deleted. |
165 | 165 | */ |
166 | - public function reverse_hook( $post_id ) { |
|
166 | + public function reverse_hook($post_id) { |
|
167 | 167 | |
168 | - $post_type = get_post_field( 'post_type', $post_id ); |
|
169 | - if ( ! $this->should_do_auto_reversals_for_post_type( $post_type ) ) { |
|
168 | + $post_type = get_post_field('post_type', $post_id); |
|
169 | + if ( ! $this->should_do_auto_reversals_for_post_type($post_type)) { |
|
170 | 170 | return; |
171 | 171 | } |
172 | 172 | |
@@ -177,8 +177,8 @@ discard block |
||
177 | 177 | ) |
178 | 178 | ); |
179 | 179 | |
180 | - foreach ( $logs as $log ) { |
|
181 | - $this->auto_reverse_log( $log ); |
|
180 | + foreach ($logs as $log) { |
|
181 | + $this->auto_reverse_log($log); |
|
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
@@ -197,11 +197,11 @@ discard block |
||
197 | 197 | * |
198 | 198 | * @return string |
199 | 199 | */ |
200 | - public function publish_logs( $text, $points, $points_type, $user_id, $log_type, $meta ) { |
|
200 | + public function publish_logs($text, $points, $points_type, $user_id, $log_type, $meta) { |
|
201 | 201 | |
202 | - _deprecated_function( __METHOD__, '2.0.0', __CLASS__ . '::logs' ); |
|
202 | + _deprecated_function(__METHOD__, '2.0.0', __CLASS__ . '::logs'); |
|
203 | 203 | |
204 | - return $this->logs( $text, $points, $points_type, $user_id, $log_type, $meta ); |
|
204 | + return $this->logs($text, $points, $points_type, $user_id, $log_type, $meta); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | * |
215 | 215 | * @return bool Whether points have been awarded for publishing this post before. |
216 | 216 | */ |
217 | - public function awarded_points_already( $post_id, $points_type ) { |
|
217 | + public function awarded_points_already($post_id, $points_type) { |
|
218 | 218 | |
219 | 219 | $query = new WordPoints_Points_Logs_Query( |
220 | 220 | array( |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | ) |
227 | 227 | ); |
228 | 228 | |
229 | - return ( $query->count() > 0 ); |
|
229 | + return ($query->count() > 0); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | } // class WordPoints_Post_Points_Hook |
@@ -36,29 +36,29 @@ discard block |
||
36 | 36 | public function __construct() { |
37 | 37 | |
38 | 38 | parent::__construct( |
39 | - _x( 'Comment', 'points hook name', 'wordpoints' ) |
|
39 | + _x('Comment', 'points hook name', 'wordpoints') |
|
40 | 40 | , array( |
41 | - 'description' => __( 'Leaving a new comment.', 'wordpoints' ), |
|
41 | + 'description' => __('Leaving a new comment.', 'wordpoints'), |
|
42 | 42 | /* translators: the post type name. */ |
43 | - 'post_type_description' => __( 'Leaving a new comment on a %s.', 'wordpoints' ), |
|
43 | + 'post_type_description' => __('Leaving a new comment on a %s.', 'wordpoints'), |
|
44 | 44 | /* translators: %s will be the post's title. */ |
45 | - 'log_text_post_title' => _x( 'Comment on %s.', 'points log description', 'wordpoints' ), |
|
46 | - 'log_text_no_post_title' => _x( 'Comment', 'points log description', 'wordpoints' ), |
|
45 | + 'log_text_post_title' => _x('Comment on %s.', 'points log description', 'wordpoints'), |
|
46 | + 'log_text_no_post_title' => _x('Comment', 'points log description', 'wordpoints'), |
|
47 | 47 | /* translators: %s is the name of a post type. */ |
48 | - 'log_text_post_type' => _x( 'Comment on a %s.', 'points log description', 'wordpoints' ), |
|
48 | + 'log_text_post_type' => _x('Comment on a %s.', 'points log description', 'wordpoints'), |
|
49 | 49 | /* translators: %s will be the post's title. */ |
50 | - 'log_text_post_title_reverse' => _x( 'Comment on %s removed.', 'points log description', 'wordpoints' ), |
|
51 | - 'log_text_no_post_title_reverse' => _x( 'Comment removed.', 'points log description', 'wordpoints' ), |
|
50 | + 'log_text_post_title_reverse' => _x('Comment on %s removed.', 'points log description', 'wordpoints'), |
|
51 | + 'log_text_no_post_title_reverse' => _x('Comment removed.', 'points log description', 'wordpoints'), |
|
52 | 52 | /* translators: %s is the name of a post type. */ |
53 | - 'log_text_post_type_reverse' => _x( 'Comment on a %s removed.', 'points log description', 'wordpoints' ), |
|
53 | + 'log_text_post_type_reverse' => _x('Comment on a %s removed.', 'points log description', 'wordpoints'), |
|
54 | 54 | 'last_status_meta_key' => 'wordpoints_last_status', |
55 | 55 | ) |
56 | 56 | ); |
57 | 57 | |
58 | - if ( get_site_option( 'wordpoints_comment_hook_legacy' ) ) { |
|
58 | + if (get_site_option('wordpoints_comment_hook_legacy')) { |
|
59 | 59 | $this->set_option( |
60 | 60 | 'disable_auto_reverse_label' |
61 | - , __( 'Revoke the points if the comment is removed.', 'wordpoints' ) |
|
61 | + , __('Revoke the points if the comment is removed.', 'wordpoints') |
|
62 | 62 | ); |
63 | 63 | } |
64 | 64 | } |
@@ -90,19 +90,19 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return bool Whether points have been awarded. |
92 | 92 | */ |
93 | - public function awarded_points_already( $comment_id, $points_type ) { |
|
93 | + public function awarded_points_already($comment_id, $points_type) { |
|
94 | 94 | |
95 | - _deprecated_function( __METHOD__, '1.8.0' ); |
|
95 | + _deprecated_function(__METHOD__, '1.8.0'); |
|
96 | 96 | |
97 | - $meta_key = $this->get_last_status_comment_meta_key( $points_type ); |
|
97 | + $meta_key = $this->get_last_status_comment_meta_key($points_type); |
|
98 | 98 | |
99 | - $last_status = get_comment_meta( $comment_id, $meta_key, true ); |
|
99 | + $last_status = get_comment_meta($comment_id, $meta_key, true); |
|
100 | 100 | |
101 | - if ( 'approved' !== $last_status ) { |
|
101 | + if ('approved' !== $last_status) { |
|
102 | 102 | |
103 | 103 | update_comment_meta( |
104 | 104 | $comment_id |
105 | - , wp_slash( $meta_key ) |
|
105 | + , wp_slash($meta_key) |
|
106 | 106 | , 'approved' |
107 | 107 | , $last_status |
108 | 108 | ); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @type array $defaults |
25 | 25 | */ |
26 | - protected $defaults = array( 'points' => 100 ); |
|
26 | + protected $defaults = array('points' => 100); |
|
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Construct the class. |
@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | public function __construct() { |
37 | 37 | |
38 | 38 | $this->init( |
39 | - _x( 'Registration', 'points hook name', 'wordpoints' ) |
|
40 | - , array( 'description' => _x( 'Registering with the site.', 'points hook description', 'wordpoints' ) ) |
|
39 | + _x('Registration', 'points hook name', 'wordpoints') |
|
40 | + , array('description' => _x('Registering with the site.', 'points hook description', 'wordpoints')) |
|
41 | 41 | ); |
42 | 42 | |
43 | - add_action( 'user_register', array( $this, 'hook' ) ); |
|
44 | - add_filter( 'wordpoints_points_log-register', array( $this, 'logs' ) ); |
|
43 | + add_action('user_register', array($this, 'hook')); |
|
44 | + add_filter('wordpoints_points_log-register', array($this, 'logs')); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @return void |
57 | 57 | */ |
58 | - public function hook( $user_id ) { |
|
58 | + public function hook($user_id) { |
|
59 | 59 | |
60 | - foreach ( $this->get_instances() as $number => $instance ) { |
|
60 | + foreach ($this->get_instances() as $number => $instance) { |
|
61 | 61 | |
62 | - if ( isset( $instance['points'] ) ) { |
|
63 | - wordpoints_add_points( $user_id, $instance['points'], $this->points_type( $number ), 'register' ); |
|
62 | + if (isset($instance['points'])) { |
|
63 | + wordpoints_add_points($user_id, $instance['points'], $this->points_type($number), 'register'); |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function logs() { |
78 | 78 | |
79 | - return _x( 'Registration.', 'points log description', 'wordpoints' ); |
|
79 | + return _x('Registration.', 'points log description', 'wordpoints'); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | } // class WordPoints_Registration_Points_Hook |
@@ -33,21 +33,21 @@ discard block |
||
33 | 33 | public function __construct() { |
34 | 34 | |
35 | 35 | parent::__construct( |
36 | - _x( 'Comment Received', 'points hook name', 'wordpoints' ) |
|
36 | + _x('Comment Received', 'points hook name', 'wordpoints') |
|
37 | 37 | , array( |
38 | - 'description' => __( 'Receiving a comment.', 'wordpoints' ), |
|
38 | + 'description' => __('Receiving a comment.', 'wordpoints'), |
|
39 | 39 | /* translators: the post type name. */ |
40 | - 'post_type_description' => __( 'Receiving a comment on a %s.', 'wordpoints' ), |
|
40 | + 'post_type_description' => __('Receiving a comment on a %s.', 'wordpoints'), |
|
41 | 41 | /* translators: %s will be the post's title. */ |
42 | - 'log_text_post_title' => _x( 'Received a comment on %s.', 'points log description', 'wordpoints' ), |
|
43 | - 'log_text_no_post_title' => _x( 'Received a comment.', 'points log description', 'wordpoints' ), |
|
42 | + 'log_text_post_title' => _x('Received a comment on %s.', 'points log description', 'wordpoints'), |
|
43 | + 'log_text_no_post_title' => _x('Received a comment.', 'points log description', 'wordpoints'), |
|
44 | 44 | /* translators: %s will be the post's title. */ |
45 | - 'log_text_post_title_reverse' => _x( 'Comment received on %s removed.', 'points log description', 'wordpoints' ), |
|
46 | - 'log_text_no_post_title_reverse' => _x( 'Comment received removed.', 'points log description', 'wordpoints' ), |
|
45 | + 'log_text_post_title_reverse' => _x('Comment received on %s removed.', 'points log description', 'wordpoints'), |
|
46 | + 'log_text_no_post_title_reverse' => _x('Comment received removed.', 'points log description', 'wordpoints'), |
|
47 | 47 | /* translators: %s is the name of a post type. */ |
48 | - 'log_text_post_type' => _x( 'Received a comment on a %s.', 'points log description', 'wordpoints' ), |
|
48 | + 'log_text_post_type' => _x('Received a comment on a %s.', 'points log description', 'wordpoints'), |
|
49 | 49 | /* translators: %s is the name of a post type. */ |
50 | - 'log_text_post_type_reverse' => _x( 'Comment received on a %s removed.', 'points log description', 'wordpoints' ), |
|
50 | + 'log_text_post_type_reverse' => _x('Comment received on a %s removed.', 'points log description', 'wordpoints'), |
|
51 | 51 | ) |
52 | 52 | ); |
53 | 53 | } |
@@ -55,15 +55,15 @@ discard block |
||
55 | 55 | /** |
56 | 56 | * @since 1.8.0 |
57 | 57 | */ |
58 | - protected function shortcircuit_hook( $new_status, $old_status, $comment ) { |
|
58 | + protected function shortcircuit_hook($new_status, $old_status, $comment) { |
|
59 | 59 | |
60 | - if ( parent::shortcircuit_hook( $new_status, $old_status, $comment ) ) { |
|
60 | + if (parent::shortcircuit_hook($new_status, $old_status, $comment)) { |
|
61 | 61 | return true; |
62 | 62 | } |
63 | 63 | |
64 | - $post = get_post( $comment->comment_post_ID ); |
|
64 | + $post = get_post($comment->comment_post_ID); |
|
65 | 65 | |
66 | - if ( $post && (int) $post->post_author === (int) $comment->user_id ) { |
|
66 | + if ($post && (int) $post->post_author === (int) $comment->user_id) { |
|
67 | 67 | return true; |
68 | 68 | } |
69 | 69 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | /** |
74 | 74 | * @since 1.8.0 |
75 | 75 | */ |
76 | - protected function select_user_to_award( $comment, $post ) { |
|
76 | + protected function select_user_to_award($comment, $post) { |
|
77 | 77 | return $post->post_author; |
78 | 78 | } |
79 | 79 |