@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | /** |
36 | 36 | * @since 2.1.0 |
37 | 37 | */ |
38 | - public function __construct( $slug ) { |
|
38 | + public function __construct($slug) { |
|
39 | 39 | |
40 | 40 | $hooks = wordpoints_hooks(); |
41 | 41 | |
42 | - $this->router = $hooks->get_sub_app( 'router' ); |
|
42 | + $this->router = $hooks->get_sub_app('router'); |
|
43 | 43 | |
44 | - parent::__construct( $slug ); |
|
44 | + parent::__construct($slug); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function init() { |
51 | 51 | |
52 | - $this->sub_apps()->register( 'args', 'WordPoints_Class_Registry_Children' ); |
|
52 | + $this->sub_apps()->register('args', 'WordPoints_Class_Registry_Children'); |
|
53 | 53 | |
54 | 54 | parent::init(); |
55 | 55 | } |
@@ -73,27 +73,27 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return bool Whether the event was registered. |
75 | 75 | */ |
76 | - public function register( $slug, $class, array $args = array() ) { |
|
76 | + public function register($slug, $class, array $args = array()) { |
|
77 | 77 | |
78 | - parent::register( $slug, $class, $args ); |
|
78 | + parent::register($slug, $class, $args); |
|
79 | 79 | |
80 | - if ( isset( $args['actions'] ) ) { |
|
81 | - foreach ( $args['actions'] as $type => $actions ) { |
|
82 | - foreach ( (array) $actions as $action_slug ) { |
|
83 | - $this->router->add_event_to_action( $slug, $action_slug, $type ); |
|
80 | + if (isset($args['actions'])) { |
|
81 | + foreach ($args['actions'] as $type => $actions) { |
|
82 | + foreach ((array) $actions as $action_slug) { |
|
83 | + $this->router->add_event_to_action($slug, $action_slug, $type); |
|
84 | 84 | } |
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | - if ( isset( $args['args'] ) ) { |
|
89 | - $args_registry = $this->get_sub_app( 'args' ); |
|
88 | + if (isset($args['args'])) { |
|
89 | + $args_registry = $this->get_sub_app('args'); |
|
90 | 90 | |
91 | - foreach ( $args['args'] as $arg_slug => $class ) { |
|
92 | - $args_registry->register( $slug, $arg_slug, $class ); |
|
91 | + foreach ($args['args'] as $arg_slug => $class) { |
|
92 | + $args_registry->register($slug, $arg_slug, $class); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
96 | - $this->event_data[ $slug ] = $args; |
|
96 | + $this->event_data[$slug] = $args; |
|
97 | 97 | |
98 | 98 | return true; |
99 | 99 | } |
@@ -101,23 +101,23 @@ discard block |
||
101 | 101 | /** |
102 | 102 | * @since 2.1.0 |
103 | 103 | */ |
104 | - public function deregister( $slug ) { |
|
104 | + public function deregister($slug) { |
|
105 | 105 | |
106 | - if ( ! $this->is_registered( $slug ) ) { |
|
106 | + if ( ! $this->is_registered($slug)) { |
|
107 | 107 | return; |
108 | 108 | } |
109 | 109 | |
110 | - parent::deregister( $slug ); |
|
110 | + parent::deregister($slug); |
|
111 | 111 | |
112 | - foreach ( (array) $this->event_data[ $slug ]['actions'] as $type => $actions ) { |
|
113 | - foreach ( (array) $actions as $action_slug ) { |
|
114 | - $this->router->remove_event_from_action( $slug, $action_slug, $type ); |
|
112 | + foreach ((array) $this->event_data[$slug]['actions'] as $type => $actions) { |
|
113 | + foreach ((array) $actions as $action_slug) { |
|
114 | + $this->router->remove_event_from_action($slug, $action_slug, $type); |
|
115 | 115 | } |
116 | 116 | } |
117 | 117 | |
118 | - $this->get_sub_app( 'args' )->deregister_children( $slug ); |
|
118 | + $this->get_sub_app('args')->deregister_children($slug); |
|
119 | 119 | |
120 | - unset( $this->event_data[ $slug ] ); |
|
120 | + unset($this->event_data[$slug]); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | */ |
22 | 22 | public function get_title() { |
23 | 23 | |
24 | - return __( 'Upload Media', 'wordpoints' ); |
|
24 | + return __('Upload Media', 'wordpoints'); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -29,14 +29,14 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public function get_description() { |
31 | 31 | |
32 | - return __( 'When a file is uploaded to the Media Library.', 'wordpoints' ); |
|
32 | + return __('When a file is uploaded to the Media Library.', 'wordpoints'); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
36 | 36 | * @since 2.1.0 |
37 | 37 | */ |
38 | 38 | public function get_reversal_text() { |
39 | - return __( 'Media file deleted.', 'wordpoints' ); |
|
39 | + return __('Media file deleted.', 'wordpoints'); |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 |
@@ -26,20 +26,20 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function get_title() { |
28 | 28 | |
29 | - $parsed = wordpoints_parse_dynamic_slug( $this->slug ); |
|
29 | + $parsed = wordpoints_parse_dynamic_slug($this->slug); |
|
30 | 30 | |
31 | - switch ( $parsed['dynamic'] ) { |
|
31 | + switch ($parsed['dynamic']) { |
|
32 | 32 | |
33 | 33 | case 'post': |
34 | - return __( 'Publish Post', 'wordpoints' ); |
|
34 | + return __('Publish Post', 'wordpoints'); |
|
35 | 35 | |
36 | 36 | case 'page': |
37 | - return __( 'Publish Page', 'wordpoints' ); |
|
37 | + return __('Publish Page', 'wordpoints'); |
|
38 | 38 | |
39 | 39 | default: |
40 | 40 | return sprintf( |
41 | 41 | // translators: singular name of the post type |
42 | - __( 'Publish %s', 'wordpoints' ) |
|
42 | + __('Publish %s', 'wordpoints') |
|
43 | 43 | , $this->get_entity_title() |
44 | 44 | ); |
45 | 45 | } |
@@ -50,20 +50,20 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function get_description() { |
52 | 52 | |
53 | - $parsed = wordpoints_parse_dynamic_slug( $this->slug ); |
|
53 | + $parsed = wordpoints_parse_dynamic_slug($this->slug); |
|
54 | 54 | |
55 | - switch ( $parsed['dynamic'] ) { |
|
55 | + switch ($parsed['dynamic']) { |
|
56 | 56 | |
57 | 57 | case 'post': |
58 | - return __( 'When a Post is published.', 'wordpoints' ); |
|
58 | + return __('When a Post is published.', 'wordpoints'); |
|
59 | 59 | |
60 | 60 | case 'page': |
61 | - return __( 'When a Page is published.', 'wordpoints' ); |
|
61 | + return __('When a Page is published.', 'wordpoints'); |
|
62 | 62 | |
63 | 63 | default: |
64 | 64 | return sprintf( |
65 | 65 | // translators: singular name of the post type |
66 | - __( 'When a %s is published.', 'wordpoints' ) |
|
66 | + __('When a %s is published.', 'wordpoints') |
|
67 | 67 | , $this->get_entity_title() |
68 | 68 | ); |
69 | 69 | } |
@@ -74,20 +74,20 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function get_reversal_text() { |
76 | 76 | |
77 | - $parsed = wordpoints_parse_dynamic_slug( $this->slug ); |
|
77 | + $parsed = wordpoints_parse_dynamic_slug($this->slug); |
|
78 | 78 | |
79 | - switch ( $parsed['dynamic'] ) { |
|
79 | + switch ($parsed['dynamic']) { |
|
80 | 80 | |
81 | 81 | case 'post': |
82 | - return __( 'Post removed.', 'wordpoints' ); |
|
82 | + return __('Post removed.', 'wordpoints'); |
|
83 | 83 | |
84 | 84 | case 'page': |
85 | - return __( 'Page removed.', 'wordpoints' ); |
|
85 | + return __('Page removed.', 'wordpoints'); |
|
86 | 86 | |
87 | 87 | default: |
88 | 88 | return sprintf( |
89 | 89 | // translators: singular name of the post type |
90 | - _x( '%s removed.', 'post type', 'wordpoints' ) |
|
90 | + _x('%s removed.', 'post type', 'wordpoints') |
|
91 | 91 | , $this->get_entity_title() |
92 | 92 | ); |
93 | 93 | } |
@@ -73,30 +73,30 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @param WordPoints_Hook_ArgI[] $args The hook args. |
75 | 75 | */ |
76 | - public function __construct( array $args ) { |
|
76 | + public function __construct(array $args) { |
|
77 | 77 | |
78 | 78 | parent::__construct(); |
79 | 79 | |
80 | - foreach ( $args as $arg ) { |
|
80 | + foreach ($args as $arg) { |
|
81 | 81 | |
82 | 82 | $entity = $arg->get_entity(); |
83 | 83 | $slug = $arg->get_slug(); |
84 | 84 | |
85 | - if ( ! $entity instanceof WordPoints_Entity ) { |
|
85 | + if ( ! $entity instanceof WordPoints_Entity) { |
|
86 | 86 | continue; |
87 | 87 | } |
88 | 88 | |
89 | - $this->entities[ $slug ] = $entity; |
|
89 | + $this->entities[$slug] = $entity; |
|
90 | 90 | |
91 | - if ( ! $arg->is_stateful() ) { |
|
91 | + if ( ! $arg->is_stateful()) { |
|
92 | 92 | |
93 | 93 | // If any of the args aren't stateful the event isn't repeatable. |
94 | 94 | $this->is_repeatable = false; |
95 | 95 | |
96 | - $this->signature_args[ $slug ] = $entity; |
|
96 | + $this->signature_args[$slug] = $entity; |
|
97 | 97 | |
98 | 98 | // Back-compat. Some events have multiple "primary" args. |
99 | - if ( ! $this->primary_arg_slug ) { |
|
99 | + if ( ! $this->primary_arg_slug) { |
|
100 | 100 | $this->primary_arg_slug = $slug; |
101 | 101 | } |
102 | 102 | } |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | public function get_signature_args() { |
134 | 134 | |
135 | - if ( ! $this->signature_args ) { |
|
135 | + if ( ! $this->signature_args) { |
|
136 | 136 | return false; |
137 | 137 | } |
138 | 138 | |
@@ -156,11 +156,11 @@ discard block |
||
156 | 156 | , __CLASS__ . '::get_signature_args()' |
157 | 157 | ); |
158 | 158 | |
159 | - if ( ! $this->primary_arg_slug ) { |
|
159 | + if ( ! $this->primary_arg_slug) { |
|
160 | 160 | return false; |
161 | 161 | } |
162 | 162 | |
163 | - return $this->entities[ $this->primary_arg_slug ]; |
|
163 | + return $this->entities[$this->primary_arg_slug]; |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /** |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | */ |
173 | 173 | public function get_stateful_args() { |
174 | 174 | |
175 | - return array_diff_key( $this->entities, $this->signature_args ); |
|
175 | + return array_diff_key($this->entities, $this->signature_args); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -193,50 +193,50 @@ discard block |
||
193 | 193 | * |
194 | 194 | * @param WordPoints_Hook_Reaction_Validator $validator The validator. |
195 | 195 | */ |
196 | - public function set_validator( WordPoints_Hook_Reaction_Validator $validator ) { |
|
196 | + public function set_validator(WordPoints_Hook_Reaction_Validator $validator) { |
|
197 | 197 | $this->validator = $validator; |
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
201 | 201 | * @since 2.1.0 |
202 | 202 | */ |
203 | - public function descend( $child_slug ) { |
|
203 | + public function descend($child_slug) { |
|
204 | 204 | |
205 | - $result = parent::descend( $child_slug ); |
|
205 | + $result = parent::descend($child_slug); |
|
206 | 206 | |
207 | 207 | // Just in case no validator has been set. |
208 | - if ( ! $this->validator ) { |
|
208 | + if ( ! $this->validator) { |
|
209 | 209 | return $result; |
210 | 210 | } |
211 | 211 | |
212 | - if ( ! $result ) { |
|
212 | + if ( ! $result) { |
|
213 | 213 | |
214 | - if ( ! isset( $this->current ) ) { |
|
214 | + if ( ! isset($this->current)) { |
|
215 | 215 | |
216 | 216 | $this->validator->add_error( |
217 | 217 | sprintf( |
218 | - __( 'The “%s” arg is not registered for this event.', 'wordpoints' ) |
|
218 | + __('The “%s” arg is not registered for this event.', 'wordpoints') |
|
219 | 219 | , $child_slug |
220 | 220 | ) |
221 | 221 | ); |
222 | 222 | |
223 | - } elseif ( ! ( $this->current instanceof WordPoints_Entity_ParentI ) ) { |
|
223 | + } elseif ( ! ($this->current instanceof WordPoints_Entity_ParentI)) { |
|
224 | 224 | |
225 | 225 | $this->validator->add_error( |
226 | 226 | sprintf( |
227 | - __( 'Cannot get descendant of %s: not a parent.', 'wordpoints' ) |
|
227 | + __('Cannot get descendant of %s: not a parent.', 'wordpoints') |
|
228 | 228 | , $this->current->get_title() |
229 | 229 | ) |
230 | 230 | ); |
231 | 231 | |
232 | 232 | } else { |
233 | 233 | |
234 | - $child_arg = $this->current->get_child( $child_slug ); |
|
234 | + $child_arg = $this->current->get_child($child_slug); |
|
235 | 235 | |
236 | - if ( ! $child_arg ) { |
|
236 | + if ( ! $child_arg) { |
|
237 | 237 | $this->validator->add_error( |
238 | 238 | sprintf( |
239 | - __( '%1$s does not have a child “%2$s”.', 'wordpoints' ) |
|
239 | + __('%1$s does not have a child “%2$s”.', 'wordpoints') |
|
240 | 240 | , $this->current->get_slug() |
241 | 241 | , $child_slug |
242 | 242 | ) |
@@ -245,9 +245,9 @@ discard block |
||
245 | 245 | } |
246 | 246 | } |
247 | 247 | |
248 | - } elseif ( $this->push_on_descend ) { |
|
248 | + } elseif ($this->push_on_descend) { |
|
249 | 249 | |
250 | - $this->validator->push_field( $child_slug ); |
|
250 | + $this->validator->push_field($child_slug); |
|
251 | 251 | |
252 | 252 | } // End if ( ! $result ) elseif ( $this->push_on_descend ). |
253 | 253 | |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | |
262 | 262 | $ascended = parent::ascend(); |
263 | 263 | |
264 | - if ( $ascended && $this->validator ) { |
|
264 | + if ($ascended && $this->validator) { |
|
265 | 265 | $this->validator->pop_field(); |
266 | 266 | } |
267 | 267 | |
@@ -271,10 +271,10 @@ discard block |
||
271 | 271 | /** |
272 | 272 | * @since 2.1.0 |
273 | 273 | */ |
274 | - public function get_from_hierarchy( array $hierarchy ) { |
|
274 | + public function get_from_hierarchy(array $hierarchy) { |
|
275 | 275 | |
276 | 276 | $this->push_on_descend = false; |
277 | - $entityish = parent::get_from_hierarchy( $hierarchy ); |
|
277 | + $entityish = parent::get_from_hierarchy($hierarchy); |
|
278 | 278 | $this->push_on_descend = true; |
279 | 279 | |
280 | 280 | return $entityish; |
@@ -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 |
@@ -18,14 +18,14 @@ |
||
18 | 18 | * @since 2.1.0 |
19 | 19 | */ |
20 | 20 | public function get_title() { |
21 | - return __( 'Visit', 'wordpoints' ); |
|
21 | + return __('Visit', 'wordpoints'); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
25 | 25 | * @since 2.1.0 |
26 | 26 | */ |
27 | 27 | public function get_description() { |
28 | - return __( 'When a logged-in user or guest visits the site.', 'wordpoints' ); |
|
28 | + return __('When a logged-in user or guest visits the site.', 'wordpoints'); |
|
29 | 29 | } |
30 | 30 | } |
31 | 31 |
@@ -20,21 +20,21 @@ |
||
20 | 20 | * @since 2.1.0 |
21 | 21 | */ |
22 | 22 | public function get_title() { |
23 | - return __( 'Register', 'wordpoints' ); |
|
23 | + return __('Register', 'wordpoints'); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | /** |
27 | 27 | * @since 2.1.0 |
28 | 28 | */ |
29 | 29 | public function get_description() { |
30 | - return __( 'Registering.', 'wordpoints' ); |
|
30 | + return __('Registering.', 'wordpoints'); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
34 | 34 | * @since 2.1.0 |
35 | 35 | */ |
36 | 36 | public function get_reversal_text() { |
37 | - return __( 'User removed.', 'wordpoints' ); |
|
37 | + return __('User removed.', 'wordpoints'); |
|
38 | 38 | } |
39 | 39 | } |
40 | 40 |
@@ -26,23 +26,23 @@ discard block |
||
26 | 26 | */ |
27 | 27 | public function get_title() { |
28 | 28 | |
29 | - $parsed = wordpoints_parse_dynamic_slug( $this->slug ); |
|
29 | + $parsed = wordpoints_parse_dynamic_slug($this->slug); |
|
30 | 30 | |
31 | - switch ( $parsed['dynamic'] ) { |
|
31 | + switch ($parsed['dynamic']) { |
|
32 | 32 | |
33 | 33 | case 'post': |
34 | - return __( 'Comment on a Post', 'wordpoints' ); |
|
34 | + return __('Comment on a Post', 'wordpoints'); |
|
35 | 35 | |
36 | 36 | case 'page': |
37 | - return __( 'Comment on a Page', 'wordpoints' ); |
|
37 | + return __('Comment on a Page', 'wordpoints'); |
|
38 | 38 | |
39 | 39 | case 'attachment': |
40 | - return __( 'Comment on a Media Upload', 'wordpoints' ); |
|
40 | + return __('Comment on a Media Upload', 'wordpoints'); |
|
41 | 41 | |
42 | 42 | default: |
43 | 43 | return sprintf( |
44 | 44 | // translators: singular name of the post type |
45 | - __( 'Comment on a %s', 'wordpoints' ) |
|
45 | + __('Comment on a %s', 'wordpoints') |
|
46 | 46 | , $this->get_entity_title() |
47 | 47 | ); |
48 | 48 | } |
@@ -53,23 +53,23 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function get_description() { |
55 | 55 | |
56 | - $parsed = wordpoints_parse_dynamic_slug( $this->slug ); |
|
56 | + $parsed = wordpoints_parse_dynamic_slug($this->slug); |
|
57 | 57 | |
58 | - switch ( $parsed['dynamic'] ) { |
|
58 | + switch ($parsed['dynamic']) { |
|
59 | 59 | |
60 | 60 | case 'post': |
61 | - return __( 'When a user leaves a comment on a Post.', 'wordpoints' ); |
|
61 | + return __('When a user leaves a comment on a Post.', 'wordpoints'); |
|
62 | 62 | |
63 | 63 | case 'page': |
64 | - return __( 'When a user leaves a comment on a Page.', 'wordpoints' ); |
|
64 | + return __('When a user leaves a comment on a Page.', 'wordpoints'); |
|
65 | 65 | |
66 | 66 | case 'attachment': |
67 | - return __( 'When a user leaves a comment on a file uploaded to the Media Library.', 'wordpoints' ); |
|
67 | + return __('When a user leaves a comment on a file uploaded to the Media Library.', 'wordpoints'); |
|
68 | 68 | |
69 | 69 | default: |
70 | 70 | return sprintf( |
71 | 71 | // translators: singular name of the post type |
72 | - __( 'When a user leaves a comment on a %s.', 'wordpoints' ) |
|
72 | + __('When a user leaves a comment on a %s.', 'wordpoints') |
|
73 | 73 | , $this->get_entity_title() |
74 | 74 | ); |
75 | 75 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @since 2.1.0 |
80 | 80 | */ |
81 | 81 | public function get_reversal_text() { |
82 | - return __( 'Comment removed.', 'wordpoints' ); |
|
82 | + return __('Comment removed.', 'wordpoints'); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 |
@@ -30,7 +30,7 @@ |
||
30 | 30 | * @since 2.1.0 |
31 | 31 | */ |
32 | 32 | public function get_title() { |
33 | - return __( 'Visitor', 'wordpoints' ); |
|
33 | + return __('Visitor', 'wordpoints'); |
|
34 | 34 | } |
35 | 35 | } |
36 | 36 |