@@ -37,13 +37,13 @@ discard block |
||
37 | 37 | /** |
38 | 38 | * @since 1.0.0 |
39 | 39 | */ |
40 | - public function __construct( $slug, WordPoints_Hook_ActionI $action = null ) { |
|
40 | + public function __construct($slug, WordPoints_Hook_ActionI $action = null) { |
|
41 | 41 | |
42 | - parent::__construct( $slug, $action ); |
|
42 | + parent::__construct($slug, $action); |
|
43 | 43 | |
44 | - $parts = wordpoints_parse_dynamic_slug( $this->slug ); |
|
44 | + $parts = wordpoints_parse_dynamic_slug($this->slug); |
|
45 | 45 | |
46 | - if ( $parts['dynamic'] ) { |
|
46 | + if ($parts['dynamic']) { |
|
47 | 47 | $this->arg_slug = $parts['generic']; |
48 | 48 | } else { |
49 | 49 | $this->arg_slug = $this->slug; |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | $value = parent::get_value(); |
60 | 60 | |
61 | 61 | // If not, then we check for an arg with the generic name. |
62 | - if ( null === $value && $this->action instanceof WordPoints_Hook_ActionI ) { |
|
63 | - $value = $this->action->get_arg_value( $this->arg_slug ); |
|
62 | + if (null === $value && $this->action instanceof WordPoints_Hook_ActionI) { |
|
63 | + $value = $this->action->get_arg_value($this->arg_slug); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | return $value; |
@@ -46,17 +46,17 @@ |
||
46 | 46 | */ |
47 | 47 | protected function get_entity_title() { |
48 | 48 | |
49 | - $parts = wordpoints_parse_dynamic_slug( $this->slug ); |
|
49 | + $parts = wordpoints_parse_dynamic_slug($this->slug); |
|
50 | 50 | |
51 | - if ( $parts['dynamic'] ) { |
|
51 | + if ($parts['dynamic']) { |
|
52 | 52 | $entity_slug = "{$this->generic_entity_slug}\\{$parts['dynamic']}"; |
53 | 53 | } else { |
54 | 54 | $entity_slug = $this->generic_entity_slug; |
55 | 55 | } |
56 | 56 | |
57 | - $entity = wordpoints_entities()->get( $entity_slug ); |
|
57 | + $entity = wordpoints_entities()->get($entity_slug); |
|
58 | 58 | |
59 | - if ( ! $entity instanceof WordPoints_Entity ) { |
|
59 | + if ( ! $entity instanceof WordPoints_Entity) { |
|
60 | 60 | return $this->slug; |
61 | 61 | } |
62 | 62 |
@@ -24,20 +24,20 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function get_title() { |
26 | 26 | |
27 | - $parsed = wordpoints_parse_dynamic_slug( $this->slug ); |
|
27 | + $parsed = wordpoints_parse_dynamic_slug($this->slug); |
|
28 | 28 | |
29 | - switch ( $parsed['dynamic'] ) { |
|
29 | + switch ($parsed['dynamic']) { |
|
30 | 30 | |
31 | 31 | case 'post': |
32 | - return __( 'Publish Post', 'wordpoints' ); |
|
32 | + return __('Publish Post', 'wordpoints'); |
|
33 | 33 | |
34 | 34 | case 'page': |
35 | - return __( 'Publish Page', 'wordpoints' ); |
|
35 | + return __('Publish Page', 'wordpoints'); |
|
36 | 36 | |
37 | 37 | default: |
38 | 38 | return sprintf( |
39 | 39 | // translators: singular name of the post type |
40 | - __( 'Publish %s', 'wordpoints' ) |
|
40 | + __('Publish %s', 'wordpoints') |
|
41 | 41 | , $this->get_entity_title() |
42 | 42 | ); |
43 | 43 | } |
@@ -48,20 +48,20 @@ discard block |
||
48 | 48 | */ |
49 | 49 | public function get_description() { |
50 | 50 | |
51 | - $parsed = wordpoints_parse_dynamic_slug( $this->slug ); |
|
51 | + $parsed = wordpoints_parse_dynamic_slug($this->slug); |
|
52 | 52 | |
53 | - switch ( $parsed['dynamic'] ) { |
|
53 | + switch ($parsed['dynamic']) { |
|
54 | 54 | |
55 | 55 | case 'post': |
56 | - return __( 'When a Post is published.', 'wordpoints' ); |
|
56 | + return __('When a Post is published.', 'wordpoints'); |
|
57 | 57 | |
58 | 58 | case 'page': |
59 | - return __( 'When a Page is published.', 'wordpoints' ); |
|
59 | + return __('When a Page is published.', 'wordpoints'); |
|
60 | 60 | |
61 | 61 | default: |
62 | 62 | return sprintf( |
63 | 63 | // translators: singular name of the post type |
64 | - __( 'When a %s is published.', 'wordpoints' ) |
|
64 | + __('When a %s is published.', 'wordpoints') |
|
65 | 65 | , $this->get_entity_title() |
66 | 66 | ); |
67 | 67 | } |
@@ -24,23 +24,23 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function get_title() { |
26 | 26 | |
27 | - $parsed = wordpoints_parse_dynamic_slug( $this->slug ); |
|
27 | + $parsed = wordpoints_parse_dynamic_slug($this->slug); |
|
28 | 28 | |
29 | - switch ( $parsed['dynamic'] ) { |
|
29 | + switch ($parsed['dynamic']) { |
|
30 | 30 | |
31 | 31 | case 'post': |
32 | - return __( 'Comment on a Post', 'wordpoints' ); |
|
32 | + return __('Comment on a Post', 'wordpoints'); |
|
33 | 33 | |
34 | 34 | case 'page': |
35 | - return __( 'Comment on a Page', 'wordpoints' ); |
|
35 | + return __('Comment on a Page', 'wordpoints'); |
|
36 | 36 | |
37 | 37 | case 'attachment': |
38 | - return __( 'Comment on a Media Upload', 'wordpoints' ); |
|
38 | + return __('Comment on a Media Upload', 'wordpoints'); |
|
39 | 39 | |
40 | 40 | default: |
41 | 41 | return sprintf( |
42 | 42 | // translators: singular name of the post type |
43 | - __( 'Comment on a %s', 'wordpoints' ) |
|
43 | + __('Comment on a %s', 'wordpoints') |
|
44 | 44 | , $this->get_entity_title() |
45 | 45 | ); |
46 | 46 | } |
@@ -51,23 +51,23 @@ discard block |
||
51 | 51 | */ |
52 | 52 | public function get_description() { |
53 | 53 | |
54 | - $parsed = wordpoints_parse_dynamic_slug( $this->slug ); |
|
54 | + $parsed = wordpoints_parse_dynamic_slug($this->slug); |
|
55 | 55 | |
56 | - switch ( $parsed['dynamic'] ) { |
|
56 | + switch ($parsed['dynamic']) { |
|
57 | 57 | |
58 | 58 | case 'post': |
59 | - return __( 'When a user leaves a comment on a Post.', 'wordpoints' ); |
|
59 | + return __('When a user leaves a comment on a Post.', 'wordpoints'); |
|
60 | 60 | |
61 | 61 | case 'page': |
62 | - return __( 'When a user leaves a comment on a Page.', 'wordpoints' ); |
|
62 | + return __('When a user leaves a comment on a Page.', 'wordpoints'); |
|
63 | 63 | |
64 | 64 | case 'attachment': |
65 | - return __( 'When a user leaves a comment on a file uploaded to the Media Library.', 'wordpoints' ); |
|
65 | + return __('When a user leaves a comment on a file uploaded to the Media Library.', 'wordpoints'); |
|
66 | 66 | |
67 | 67 | default: |
68 | 68 | return sprintf( |
69 | 69 | // translators: singular name of the post type |
70 | - __( 'When a user leaves a comment on a %s.', 'wordpoints' ) |
|
70 | + __('When a user leaves a comment on a %s.', 'wordpoints') |
|
71 | 71 | , $this->get_entity_title() |
72 | 72 | ); |
73 | 73 | } |
@@ -17,20 +17,20 @@ discard block |
||
17 | 17 | /** |
18 | 18 | * @since 1.0.0 |
19 | 19 | */ |
20 | - public function __construct( $slug ) { |
|
20 | + public function __construct($slug) { |
|
21 | 21 | |
22 | - parent::__construct( $slug ); |
|
22 | + parent::__construct($slug); |
|
23 | 23 | |
24 | - $parts = wordpoints_parse_dynamic_slug( $this->slug ); |
|
24 | + $parts = wordpoints_parse_dynamic_slug($this->slug); |
|
25 | 25 | |
26 | - if ( $parts['dynamic'] ) { |
|
26 | + if ($parts['dynamic']) { |
|
27 | 27 | |
28 | - $parsed = $this->parse_slug( $this->related_entity_slug ); |
|
28 | + $parsed = $this->parse_slug($this->related_entity_slug); |
|
29 | 29 | |
30 | 30 | $this->primary_entity_slug = "{$this->primary_entity_slug}\\{$parts['dynamic']}"; |
31 | 31 | $this->related_entity_slug = "{$parsed['slug']}\\{$parts['dynamic']}"; |
32 | 32 | |
33 | - if ( $parsed['is_array'] ) { |
|
33 | + if ($parsed['is_array']) { |
|
34 | 34 | $this->related_entity_slug .= '{}'; |
35 | 35 | } |
36 | 36 | } |
@@ -41,11 +41,11 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public function get_title() { |
43 | 43 | |
44 | - $parsed = $this->parse_slug( $this->related_entity_slug ); |
|
44 | + $parsed = $this->parse_slug($this->related_entity_slug); |
|
45 | 45 | |
46 | - $entity = wordpoints_entities()->get( $parsed['slug'] ); |
|
46 | + $entity = wordpoints_entities()->get($parsed['slug']); |
|
47 | 47 | |
48 | - if ( $entity instanceof WordPoints_Entity ) { |
|
48 | + if ($entity instanceof WordPoints_Entity) { |
|
49 | 49 | return $entity->get_title(); |
50 | 50 | } else { |
51 | 51 | return $this->related_entity_slug; |
@@ -33,9 +33,9 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @param WordPoints_Class_Registry_Persistent $reactors The reactors registry. |
35 | 35 | */ |
36 | -function wordpoints_hook_reactors_init( $reactors ) { |
|
36 | +function wordpoints_hook_reactors_init($reactors) { |
|
37 | 37 | |
38 | - $reactors->register( 'points', 'WordPoints_Hook_Reactor_Points' ); |
|
38 | + $reactors->register('points', 'WordPoints_Hook_Reactor_Points'); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** |
@@ -47,10 +47,10 @@ discard block |
||
47 | 47 | * |
48 | 48 | * @param WordPoints_Class_Registry_Persistent $extensions The extension registry. |
49 | 49 | */ |
50 | -function wordpoints_hook_extension_init( $extensions ) { |
|
50 | +function wordpoints_hook_extension_init($extensions) { |
|
51 | 51 | |
52 | - $extensions->register( 'conditions', 'WordPoints_Hook_Extension_Conditions' ); |
|
53 | - $extensions->register( 'periods', 'WordPoints_Hook_Extension_Periods' ); |
|
52 | + $extensions->register('conditions', 'WordPoints_Hook_Extension_Conditions'); |
|
53 | + $extensions->register('periods', 'WordPoints_Hook_Extension_Periods'); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * |
63 | 63 | * @param WordPoints_Class_Registry_Children $conditions The conditions registry. |
64 | 64 | */ |
65 | -function wordpoints_hook_conditions_init( $conditions ) { |
|
65 | +function wordpoints_hook_conditions_init($conditions) { |
|
66 | 66 | |
67 | 67 | $conditions->register( |
68 | 68 | 'text' |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @param WordPoints_Hook_Actions $actions The action registry. |
100 | 100 | */ |
101 | -function wordpoints_hook_actions_init( $actions ) { |
|
101 | +function wordpoints_hook_actions_init($actions) { |
|
102 | 102 | |
103 | 103 | $actions->register( |
104 | 104 | 'comment_approve' |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | , array( |
107 | 107 | 'action' => 'transition_comment_status', |
108 | 108 | 'data' => array( |
109 | - 'arg_index' => array( 'comment' => 2 ), |
|
110 | - 'requirements' => array( 0 => 'approved' ), |
|
109 | + 'arg_index' => array('comment' => 2), |
|
110 | + 'requirements' => array(0 => 'approved'), |
|
111 | 111 | ), |
112 | 112 | ) |
113 | 113 | ); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | , array( |
119 | 119 | 'action' => 'wp_insert_comment', |
120 | 120 | 'data' => array( |
121 | - 'arg_index' => array( 'comment' => 1 ), |
|
121 | + 'arg_index' => array('comment' => 1), |
|
122 | 122 | ), |
123 | 123 | ) |
124 | 124 | ); |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | , array( |
130 | 130 | 'action' => 'transition_comment_status', |
131 | 131 | 'data' => array( |
132 | - 'arg_index' => array( 'comment' => 2 ), |
|
133 | - 'requirements' => array( 1 => 'approved' ), |
|
132 | + 'arg_index' => array('comment' => 2), |
|
133 | + 'requirements' => array(1 => 'approved'), |
|
134 | 134 | ), |
135 | 135 | ) |
136 | 136 | ); |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | , array( |
143 | 143 | 'action' => 'transition_post_status', |
144 | 144 | 'data' => array( |
145 | - 'arg_index' => array( 'post' => 2 ), |
|
146 | - 'requirements' => array( 0 => 'publish' ), |
|
145 | + 'arg_index' => array('post' => 2), |
|
146 | + 'requirements' => array(0 => 'publish'), |
|
147 | 147 | ), |
148 | 148 | ) |
149 | 149 | ); |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | , array( |
155 | 155 | 'action' => 'add_attachment', |
156 | 156 | 'data' => array( |
157 | - 'arg_index' => array( 'post\attachment' => 0 ), |
|
157 | + 'arg_index' => array('post\attachment' => 0), |
|
158 | 158 | ), |
159 | 159 | ) |
160 | 160 | ); |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | , array( |
166 | 166 | 'action' => 'post_delete', |
167 | 167 | 'data' => array( |
168 | - 'arg_index' => array( 'post' => 0 ), |
|
168 | + 'arg_index' => array('post' => 0), |
|
169 | 169 | ), |
170 | 170 | ) |
171 | 171 | ); |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | , array( |
177 | 177 | 'action' => 'user_register', |
178 | 178 | 'data' => array( |
179 | - 'arg_index' => array( 'user' => 0 ), |
|
179 | + 'arg_index' => array('user' => 0), |
|
180 | 180 | ), |
181 | 181 | ) |
182 | 182 | ); |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | , array( |
188 | 188 | 'action' => is_multisite() ? 'wpmu_delete_user' : 'delete_user', |
189 | 189 | 'data' => array( |
190 | - 'arg_index' => array( 'user' => 0 ), |
|
190 | + 'arg_index' => array('user' => 0), |
|
191 | 191 | ), |
192 | 192 | ) |
193 | 193 | ); |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * |
211 | 211 | * @param WordPoints_Hook_Events $events The event registry. |
212 | 212 | */ |
213 | -function wordpoints_hook_events_init( $events ) { |
|
213 | +function wordpoints_hook_events_init($events) { |
|
214 | 214 | |
215 | 215 | $events->register( |
216 | 216 | 'user_register' |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | ); |
241 | 241 | |
242 | 242 | // Register events for all of the public post types. |
243 | - $post_types = get_post_types( array( 'public' => true ) ); |
|
243 | + $post_types = get_post_types(array('public' => true)); |
|
244 | 244 | |
245 | 245 | /** |
246 | 246 | * Filter which post types to register hook events for. |
@@ -249,20 +249,20 @@ discard block |
||
249 | 249 | * |
250 | 250 | * @param string[] The post type slugs ("names"). |
251 | 251 | */ |
252 | - $post_types = apply_filters( 'wordpoints_register_hook_events_for_post_types', $post_types ); |
|
252 | + $post_types = apply_filters('wordpoints_register_hook_events_for_post_types', $post_types); |
|
253 | 253 | |
254 | - foreach ( $post_types as $slug ) { |
|
255 | - wordpoints_register_post_type_hook_events( $slug ); |
|
254 | + foreach ($post_types as $slug) { |
|
255 | + wordpoints_register_post_type_hook_events($slug); |
|
256 | 256 | } |
257 | 257 | |
258 | - if ( is_multisite() ) { |
|
258 | + if (is_multisite()) { |
|
259 | 259 | |
260 | 260 | $event_slugs = array( |
261 | 261 | 'user_visit', |
262 | 262 | 'user_register', |
263 | 263 | ); |
264 | 264 | |
265 | - foreach ( $event_slugs as $event_slug ) { |
|
265 | + foreach ($event_slugs as $event_slug) { |
|
266 | 266 | // TODO network hooks |
267 | 267 | $events->args->register( |
268 | 268 | $event_slug |
@@ -282,11 +282,11 @@ discard block |
||
282 | 282 | * |
283 | 283 | * @param WordPoints_Class_Registry_Persistent $firers The firer registry. |
284 | 284 | */ |
285 | -function wordpoints_hook_firers_init( $firers ) { |
|
285 | +function wordpoints_hook_firers_init($firers) { |
|
286 | 286 | |
287 | - $firers->register( 'fire', 'WordPoints_Hook_Firer' ); |
|
288 | - $firers->register( 'reverse', 'WordPoints_Hook_Firer_Reverse' ); |
|
289 | - $firers->register( 'spam', 'WordPoints_Hook_Firer_Spam' ); |
|
287 | + $firers->register('fire', 'WordPoints_Hook_Firer'); |
|
288 | + $firers->register('reverse', 'WordPoints_Hook_Firer_Reverse'); |
|
289 | + $firers->register('spam', 'WordPoints_Hook_Firer_Spam'); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
@@ -298,9 +298,9 @@ discard block |
||
298 | 298 | * |
299 | 299 | * @param WordPoints_App_Registry $entities The entities app. |
300 | 300 | */ |
301 | -function wordpoints_entities_app_init( $entities ) { |
|
301 | +function wordpoints_entities_app_init($entities) { |
|
302 | 302 | |
303 | - $entities->sub_apps->register( 'children', 'WordPoints_Class_Registry_Children' ); |
|
303 | + $entities->sub_apps->register('children', 'WordPoints_Class_Registry_Children'); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | /** |
@@ -312,18 +312,18 @@ discard block |
||
312 | 312 | * |
313 | 313 | * @param WordPoints_App_Registry $entities The entities app. |
314 | 314 | */ |
315 | -function wordpoints_entities_init( $entities ) { |
|
315 | +function wordpoints_entities_init($entities) { |
|
316 | 316 | |
317 | 317 | $children = $entities->children; |
318 | 318 | |
319 | - $entities->register( 'user', 'WordPoints_Entity_User' ); |
|
320 | - $children->register( 'user', 'roles', 'WordPoints_Entity_User_Roles' ); |
|
319 | + $entities->register('user', 'WordPoints_Entity_User'); |
|
320 | + $children->register('user', 'roles', 'WordPoints_Entity_User_Roles'); |
|
321 | 321 | |
322 | - $entities->register( 'user_role', 'WordPoints_Entity_User_Role' ); |
|
323 | - $children->register( 'user_role', 'name', 'WordPoints_Entity_User_Role_Name' ); |
|
322 | + $entities->register('user_role', 'WordPoints_Entity_User_Role'); |
|
323 | + $children->register('user_role', 'name', 'WordPoints_Entity_User_Role_Name'); |
|
324 | 324 | |
325 | 325 | // Register entities for all of the public post types. |
326 | - $post_types = get_post_types( array( 'public' => true ) ); |
|
326 | + $post_types = get_post_types(array('public' => true)); |
|
327 | 327 | |
328 | 328 | /** |
329 | 329 | * Filter which post types to register entities for. |
@@ -332,14 +332,14 @@ discard block |
||
332 | 332 | * |
333 | 333 | * @param string[] The post type slugs ("names"). |
334 | 334 | */ |
335 | - $post_types = apply_filters( 'wordpoints_register_entities_for_post_types', $post_types ); |
|
335 | + $post_types = apply_filters('wordpoints_register_entities_for_post_types', $post_types); |
|
336 | 336 | |
337 | - foreach ( $post_types as $slug ) { |
|
338 | - wordpoints_register_post_type_entities( $slug ); |
|
337 | + foreach ($post_types as $slug) { |
|
338 | + wordpoints_register_post_type_entities($slug); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | // Register entities for all of the public taxonomies. |
342 | - $taxonomies = get_taxonomies( array( 'public' => true ) ); |
|
342 | + $taxonomies = get_taxonomies(array('public' => true)); |
|
343 | 343 | |
344 | 344 | /** |
345 | 345 | * Filter which taxonomies to register entities for. |
@@ -348,10 +348,10 @@ discard block |
||
348 | 348 | * |
349 | 349 | * @param string[] The taxonomy slugs. |
350 | 350 | */ |
351 | - $taxonomies = apply_filters( 'wordpoints_register_entities_for_taxonomies', $taxonomies ); |
|
351 | + $taxonomies = apply_filters('wordpoints_register_entities_for_taxonomies', $taxonomies); |
|
352 | 352 | |
353 | - foreach ( $taxonomies as $slug ) { |
|
354 | - wordpoints_register_taxonomy_entities( $slug ); |
|
353 | + foreach ($taxonomies as $slug) { |
|
354 | + wordpoints_register_taxonomy_entities($slug); |
|
355 | 355 | } |
356 | 356 | } |
357 | 357 | |
@@ -362,28 +362,28 @@ discard block |
||
362 | 362 | * |
363 | 363 | * @param string $slug The slug of the post type. |
364 | 364 | */ |
365 | -function wordpoints_register_post_type_entities( $slug ) { |
|
365 | +function wordpoints_register_post_type_entities($slug) { |
|
366 | 366 | |
367 | 367 | $entities = wordpoints_entities(); |
368 | 368 | $children = $entities->children; |
369 | 369 | |
370 | - $entities->register( "post\\{$slug}", 'WordPoints_Entity_Post' ); |
|
371 | - $children->register( "post\\{$slug}", 'author', 'WordPoints_Entity_Post_Author' ); |
|
370 | + $entities->register("post\\{$slug}", 'WordPoints_Entity_Post'); |
|
371 | + $children->register("post\\{$slug}", 'author', 'WordPoints_Entity_Post_Author'); |
|
372 | 372 | |
373 | - $supports = get_all_post_type_supports( $slug ); |
|
373 | + $supports = get_all_post_type_supports($slug); |
|
374 | 374 | |
375 | - if ( isset( $supports['editor'] ) ) { |
|
376 | - $children->register( "post\\{$slug}", 'content', 'WordPoints_Entity_Post_Content' ); |
|
375 | + if (isset($supports['editor'])) { |
|
376 | + $children->register("post\\{$slug}", 'content', 'WordPoints_Entity_Post_Content'); |
|
377 | 377 | } |
378 | 378 | |
379 | - if ( isset( $supports['comments'] ) ) { |
|
380 | - $entities->register( "comment\\{$slug}", 'WordPoints_Entity_Comment' ); |
|
381 | - $children->register( "comment\\{$slug}", "post\\{$slug}", 'WordPoints_Entity_Comment_Post' ); |
|
382 | - $children->register( "comment\\{$slug}", 'author', 'WordPoints_Entity_Comment_Author' ); |
|
379 | + if (isset($supports['comments'])) { |
|
380 | + $entities->register("comment\\{$slug}", 'WordPoints_Entity_Comment'); |
|
381 | + $children->register("comment\\{$slug}", "post\\{$slug}", 'WordPoints_Entity_Comment_Post'); |
|
382 | + $children->register("comment\\{$slug}", 'author', 'WordPoints_Entity_Comment_Author'); |
|
383 | 383 | } |
384 | 384 | |
385 | - foreach ( get_object_taxonomies( $slug ) as $taxonomy_slug ) { |
|
386 | - $children->register( "post\\{$slug}", "terms\\{$taxonomy_slug}", 'WordPoints_Entity_Post_Terms' ); |
|
385 | + foreach (get_object_taxonomies($slug) as $taxonomy_slug) { |
|
386 | + $children->register("post\\{$slug}", "terms\\{$taxonomy_slug}", 'WordPoints_Entity_Post_Terms'); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | /** |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | * |
394 | 394 | * @param string $slug The slug ("name") of the post type. |
395 | 395 | */ |
396 | - do_action( 'wordpoints_register_post_type_entities', $slug ); |
|
396 | + do_action('wordpoints_register_post_type_entities', $slug); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | /** |
@@ -403,13 +403,13 @@ discard block |
||
403 | 403 | * |
404 | 404 | * @param string $slug The slug of the post type. |
405 | 405 | */ |
406 | -function wordpoints_register_post_type_hook_events( $slug ) { |
|
406 | +function wordpoints_register_post_type_hook_events($slug) { |
|
407 | 407 | |
408 | 408 | $event_slugs = array(); |
409 | 409 | |
410 | 410 | $events = wordpoints_hooks()->events; |
411 | 411 | |
412 | - if ( 'attachment' === $slug ) { |
|
412 | + if ('attachment' === $slug) { |
|
413 | 413 | |
414 | 414 | $event_slugs[] = 'media_upload'; |
415 | 415 | |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | ); |
447 | 447 | } |
448 | 448 | |
449 | - if ( post_type_supports( $slug, 'comments' ) ) { |
|
449 | + if (post_type_supports($slug, 'comments')) { |
|
450 | 450 | |
451 | 451 | $event_slugs[] = "comment_leave\\{$slug}"; |
452 | 452 | |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | , 'WordPoints_Hook_Event_Comment_Leave' |
456 | 456 | , array( |
457 | 457 | 'actions' => array( |
458 | - 'fire' => array( 'comment_approve', 'comment_new' ), |
|
458 | + 'fire' => array('comment_approve', 'comment_new'), |
|
459 | 459 | 'reverse' => 'comment_deapprove', |
460 | 460 | 'spam' => 'comment_spam', |
461 | 461 | ), |
@@ -466,8 +466,8 @@ discard block |
||
466 | 466 | ); |
467 | 467 | } |
468 | 468 | |
469 | - if ( is_multisite() ) { |
|
470 | - foreach ( $event_slugs as $event_slug ) { |
|
469 | + if (is_multisite()) { |
|
470 | + foreach ($event_slugs as $event_slug) { |
|
471 | 471 | $events->args->register( |
472 | 472 | $event_slug |
473 | 473 | , 'current:site' |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | * |
484 | 484 | * @param string $slug The slug ("name") of the post type. |
485 | 485 | */ |
486 | - do_action( 'wordpoints_register_post_type_hook_events', $slug ); |
|
486 | + do_action('wordpoints_register_post_type_hook_events', $slug); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | /** |
@@ -493,13 +493,13 @@ discard block |
||
493 | 493 | * |
494 | 494 | * @param string $slug The slug of the taxonomy. |
495 | 495 | */ |
496 | -function wordpoints_register_taxonomy_entities( $slug ) { |
|
496 | +function wordpoints_register_taxonomy_entities($slug) { |
|
497 | 497 | |
498 | 498 | $entities = wordpoints_entities(); |
499 | 499 | $children = $entities->children; |
500 | 500 | |
501 | - $entities->register( "term\\{$slug}", 'WordPoints_Entity_Term' ); |
|
502 | - $children->register( "term\\{$slug}", 'id', 'WordPoints_Entity_Term_Id' ); |
|
501 | + $entities->register("term\\{$slug}", 'WordPoints_Entity_Term'); |
|
502 | + $children->register("term\\{$slug}", 'id', 'WordPoints_Entity_Term_Id'); |
|
503 | 503 | |
504 | 504 | /** |
505 | 505 | * Fired when registering the entities for a taxonomy. |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | * |
509 | 509 | * @param string $slug The taxonomy's slug. |
510 | 510 | */ |
511 | - do_action( 'wordpoints_register_taxonomy_entities', $slug ); |
|
511 | + do_action('wordpoints_register_taxonomy_entities', $slug); |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | /** |
@@ -520,10 +520,10 @@ discard block |
||
520 | 520 | * |
521 | 521 | * @param WordPoints_Class_RegistryI $data_types The data types registry. |
522 | 522 | */ |
523 | -function wordpoints_data_types_init( $data_types ) { |
|
523 | +function wordpoints_data_types_init($data_types) { |
|
524 | 524 | |
525 | - $data_types->register( 'integer', 'WordPoints_Data_Type_Integer' ); |
|
526 | - $data_types->register( 'text', 'WordPoints_Data_Type_Text' ); |
|
525 | + $data_types->register('integer', 'WordPoints_Data_Type_Integer'); |
|
526 | + $data_types->register('text', 'WordPoints_Data_Type_Text'); |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | /** |
@@ -538,9 +538,9 @@ discard block |
||
538 | 538 | * |
539 | 539 | * @return bool Whether the user can view the points log. |
540 | 540 | */ |
541 | -function wordpoints_hooks_user_can_view_points_log( $can_view, $log ) { |
|
541 | +function wordpoints_hooks_user_can_view_points_log($can_view, $log) { |
|
542 | 542 | |
543 | - if ( ! $can_view ) { |
|
543 | + if ( ! $can_view) { |
|
544 | 544 | return $can_view; |
545 | 545 | } |
546 | 546 | |
@@ -549,11 +549,11 @@ discard block |
||
549 | 549 | $event_slug = $log->log_type; |
550 | 550 | |
551 | 551 | /** @var WordPoints_Hook_Arg $arg */ |
552 | - foreach ( wordpoints_hooks()->events->args->get_children( $event_slug ) as $slug => $arg ) { |
|
552 | + foreach (wordpoints_hooks()->events->args->get_children($event_slug) as $slug => $arg) { |
|
553 | 553 | |
554 | - $value = wordpoints_get_points_log_meta( $log->id, $slug, true ); |
|
554 | + $value = wordpoints_get_points_log_meta($log->id, $slug, true); |
|
555 | 555 | |
556 | - if ( ! $value ) { |
|
556 | + if ( ! $value) { |
|
557 | 557 | continue; |
558 | 558 | } |
559 | 559 | |
@@ -563,7 +563,7 @@ discard block |
||
563 | 563 | , $value |
564 | 564 | ); |
565 | 565 | |
566 | - if ( ! $can_view ) { |
|
566 | + if ( ! $can_view) { |
|
567 | 567 | break; |
568 | 568 | } |
569 | 569 | } |
@@ -582,20 +582,20 @@ discard block |
||
582 | 582 | * |
583 | 583 | * @return bool Whether the user can view this entity. |
584 | 584 | */ |
585 | -function wordpoints_entity_user_can_view( $user_id, $entity_slug, $entity_id ) { |
|
585 | +function wordpoints_entity_user_can_view($user_id, $entity_slug, $entity_id) { |
|
586 | 586 | |
587 | - $entity = wordpoints_entities()->get( $entity_slug ); |
|
587 | + $entity = wordpoints_entities()->get($entity_slug); |
|
588 | 588 | |
589 | 589 | // If this entity type is not found, we have no way of determining whether it is |
590 | 590 | // safe for the user to view it. |
591 | - if ( ! ( $entity instanceof WordPoints_Entity ) ) { |
|
591 | + if ( ! ($entity instanceof WordPoints_Entity)) { |
|
592 | 592 | return false; |
593 | 593 | } |
594 | 594 | |
595 | 595 | $can_view = true; |
596 | 596 | |
597 | - if ( $entity instanceof WordPoints_Entity_Restricted_VisibilityI ) { |
|
598 | - $can_view = $entity->user_can_view( $user_id, $entity_id ); |
|
597 | + if ($entity instanceof WordPoints_Entity_Restricted_VisibilityI) { |
|
598 | + $can_view = $entity->user_can_view($user_id, $entity_id); |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | /** |
@@ -626,8 +626,8 @@ discard block |
||
626 | 626 | */ |
627 | 627 | function wordpoints_apps() { |
628 | 628 | |
629 | - if ( ! isset( WordPoints_App::$main ) ) { |
|
630 | - WordPoints_App::$main = new WordPoints_App( 'apps' ); |
|
629 | + if ( ! isset(WordPoints_App::$main)) { |
|
630 | + WordPoints_App::$main = new WordPoints_App('apps'); |
|
631 | 631 | } |
632 | 632 | |
633 | 633 | return WordPoints_App::$main; |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | */ |
643 | 643 | function wordpoints_hooks() { |
644 | 644 | |
645 | - if ( ! isset( WordPoints_App::$main ) ) { |
|
645 | + if ( ! isset(WordPoints_App::$main)) { |
|
646 | 646 | wordpoints_apps(); |
647 | 647 | } |
648 | 648 | |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | */ |
659 | 659 | function wordpoints_entities() { |
660 | 660 | |
661 | - if ( ! isset( WordPoints_App::$main ) ) { |
|
661 | + if ( ! isset(WordPoints_App::$main)) { |
|
662 | 662 | wordpoints_apps(); |
663 | 663 | } |
664 | 664 | |
@@ -674,13 +674,13 @@ discard block |
||
674 | 674 | * |
675 | 675 | * @param WordPoints_App $app The main apps app. |
676 | 676 | */ |
677 | -function wordpoints_apps_init( $app ) { |
|
677 | +function wordpoints_apps_init($app) { |
|
678 | 678 | |
679 | 679 | $apps = $app->sub_apps; |
680 | 680 | |
681 | - $apps->register( 'hooks', 'WordPoints_Hooks' ); |
|
682 | - $apps->register( 'entities', 'WordPoints_App_Registry' ); |
|
683 | - $apps->register( 'data_types', 'WordPoints_Class_Registry' ); |
|
681 | + $apps->register('hooks', 'WordPoints_Hooks'); |
|
682 | + $apps->register('entities', 'WordPoints_App_Registry'); |
|
683 | + $apps->register('data_types', 'WordPoints_Class_Registry'); |
|
684 | 684 | } |
685 | 685 | |
686 | 686 | /** |
@@ -693,19 +693,19 @@ discard block |
||
693 | 693 | * |
694 | 694 | * @return object|false The constructed object, or false if to many args were passed. |
695 | 695 | */ |
696 | -function wordpoints_construct_class_with_args( $class_name, array $args ) { |
|
696 | +function wordpoints_construct_class_with_args($class_name, array $args) { |
|
697 | 697 | |
698 | - switch ( count( $args ) ) { |
|
698 | + switch (count($args)) { |
|
699 | 699 | case 0: |
700 | 700 | return new $class_name(); |
701 | 701 | case 1: |
702 | - return new $class_name( $args[0] ); |
|
702 | + return new $class_name($args[0]); |
|
703 | 703 | case 2: |
704 | - return new $class_name( $args[0], $args[1] ); |
|
704 | + return new $class_name($args[0], $args[1]); |
|
705 | 705 | case 3: |
706 | - return new $class_name( $args[0], $args[1], $args[2] ); |
|
706 | + return new $class_name($args[0], $args[1], $args[2]); |
|
707 | 707 | case 4: |
708 | - return new $class_name( $args[0], $args[1], $args[2], $args[3] ); |
|
708 | + return new $class_name($args[0], $args[1], $args[2], $args[3]); |
|
709 | 709 | default: |
710 | 710 | return false; |
711 | 711 | } |
@@ -727,13 +727,13 @@ discard block |
||
727 | 727 | * @return array The slug parsed into the 'generic' and 'dynamic' portions. If the |
728 | 728 | * slug is not dynamic, the value of each of those keys will be false. |
729 | 729 | */ |
730 | -function wordpoints_parse_dynamic_slug( $slug ) { |
|
730 | +function wordpoints_parse_dynamic_slug($slug) { |
|
731 | 731 | |
732 | - $parsed = array( 'dynamic' => false, 'generic' => false ); |
|
732 | + $parsed = array('dynamic' => false, 'generic' => false); |
|
733 | 733 | |
734 | - $parts = explode( '\\', $slug, 2 ); |
|
734 | + $parts = explode('\\', $slug, 2); |
|
735 | 735 | |
736 | - if ( isset( $parts[1] ) ) { |
|
736 | + if (isset($parts[1])) { |
|
737 | 737 | $parsed['dynamic'] = $parts[1]; |
738 | 738 | $parsed['generic'] = $parts[0]; |
739 | 739 | } |