@@ -21,7 +21,7 @@ |
||
21 | 21 | * |
22 | 22 | * @param WordPoints_Hook_Fire $fire The hook fire object. |
23 | 23 | */ |
24 | - public function after_hit( WordPoints_Hook_Fire $fire ); |
|
24 | + public function after_hit(WordPoints_Hook_Fire $fire); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | // EOF |
@@ -20,6 +20,7 @@ |
||
20 | 20 | * @since 2.1.0 |
21 | 21 | * |
22 | 22 | * @param WordPoints_Hook_Fire $fire The hook fire object. |
23 | + * @return void |
|
23 | 24 | */ |
24 | 25 | public function after_hit( WordPoints_Hook_Fire $fire ); |
25 | 26 | } |
@@ -21,7 +21,7 @@ |
||
21 | 21 | * |
22 | 22 | * @param WordPoints_Hook_Fire $fire The fire that was a miss. |
23 | 23 | */ |
24 | - public function after_miss( WordPoints_Hook_Fire $fire ); |
|
24 | + public function after_miss(WordPoints_Hook_Fire $fire); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | // EOF |
@@ -20,6 +20,7 @@ |
||
20 | 20 | * @since 2.1.0 |
21 | 21 | * |
22 | 22 | * @param WordPoints_Hook_Fire $fire The fire that was a miss. |
23 | + * @return void |
|
23 | 24 | */ |
24 | 25 | public function after_miss( WordPoints_Hook_Fire $fire ); |
25 | 26 | } |
@@ -22,22 +22,22 @@ |
||
22 | 22 | /** |
23 | 23 | * @since 2.1.0 |
24 | 24 | */ |
25 | - protected function validate_action_type_settings( $settings ) { |
|
25 | + protected function validate_action_type_settings($settings) { |
|
26 | 26 | return (bool) $settings; |
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
30 | 30 | * @since 2.1.0 |
31 | 31 | */ |
32 | - public function should_hit( WordPoints_Hook_Fire $fire ) { |
|
32 | + public function should_hit(WordPoints_Hook_Fire $fire) { |
|
33 | 33 | |
34 | - $block_repeats = (bool) $this->get_settings_from_fire( $fire ); |
|
34 | + $block_repeats = (bool) $this->get_settings_from_fire($fire); |
|
35 | 35 | |
36 | - if ( ! $block_repeats ) { |
|
36 | + if ( ! $block_repeats) { |
|
37 | 37 | return true; |
38 | 38 | } |
39 | 39 | |
40 | - if ( $fire->get_matching_hits_query()->count() > 0 ) { |
|
40 | + if ($fire->get_matching_hits_query()->count() > 0) { |
|
41 | 41 | return false; |
42 | 42 | } |
43 | 43 |
@@ -64,7 +64,7 @@ |
||
64 | 64 | * |
65 | 65 | * @return bool Whether this condition is met. |
66 | 66 | */ |
67 | - public function is_met( array $settings, WordPoints_Hook_Event_Args $args ); |
|
67 | + public function is_met(array $settings, WordPoints_Hook_Event_Args $args); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | // EOF |
@@ -36,7 +36,7 @@ |
||
36 | 36 | * |
37 | 37 | * @return bool Whether the target should be hit by this hook firing. |
38 | 38 | */ |
39 | - public function should_hit( WordPoints_Hook_Fire $fire ); |
|
39 | + public function should_hit(WordPoints_Hook_Fire $fire); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | // EOF |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | public function __construct() { |
30 | 30 | |
31 | - $this->router = wordpoints_hooks()->get_sub_app( 'router' ); |
|
31 | + $this->router = wordpoints_hooks()->get_sub_app('router'); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -40,23 +40,23 @@ discard block |
||
40 | 40 | * |
41 | 41 | * @return object|false The action object, or false if not found. |
42 | 42 | */ |
43 | - public function get( $slug, array $action_args = array(), array $args = array() ) { |
|
43 | + public function get($slug, array $action_args = array(), array $args = array()) { |
|
44 | 44 | |
45 | - if ( ! isset( $this->classes[ $slug ] ) ) { |
|
45 | + if ( ! isset($this->classes[$slug])) { |
|
46 | 46 | return false; |
47 | 47 | } |
48 | 48 | |
49 | - return new $this->classes[ $slug ]( $slug, $action_args, $args ); |
|
49 | + return new $this->classes[$slug]($slug, $action_args, $args); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @since 2.1.0 |
54 | 54 | */ |
55 | - public function register( $slug, $class, array $args = array() ) { |
|
55 | + public function register($slug, $class, array $args = array()) { |
|
56 | 56 | |
57 | - parent::register( $slug, $class, $args ); |
|
57 | + parent::register($slug, $class, $args); |
|
58 | 58 | |
59 | - $this->router->add_action( $slug, $args ); |
|
59 | + $this->router->add_action($slug, $args); |
|
60 | 60 | |
61 | 61 | return true; |
62 | 62 | } |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | /** |
65 | 65 | * @since 2.1.0 |
66 | 66 | */ |
67 | - public function deregister( $slug ) { |
|
67 | + public function deregister($slug) { |
|
68 | 68 | |
69 | - parent::deregister( $slug ); |
|
69 | + parent::deregister($slug); |
|
70 | 70 | |
71 | - $this->router->remove_action( $slug ); |
|
71 | + $this->router->remove_action($slug); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @since 2.1.0 |
19 | 19 | */ |
20 | 20 | public function get_title() { |
21 | - return __( 'Contains', 'wordpoints' ); |
|
21 | + return __('Contains', 'wordpoints'); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | return array( |
29 | 29 | 'value' => array( |
30 | 30 | 'type' => 'text', |
31 | - 'label' => __( 'Word or phrase (case sensitive)', 'wordpoints' ), |
|
31 | + 'label' => __('Word or phrase (case sensitive)', 'wordpoints'), |
|
32 | 32 | 'required' => true, |
33 | 33 | ), |
34 | 34 | ); |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | /** |
38 | 38 | * @since 2.1.0 |
39 | 39 | */ |
40 | - public function is_met( array $settings, WordPoints_Hook_Event_Args $args ) { |
|
40 | + public function is_met(array $settings, WordPoints_Hook_Event_Args $args) { |
|
41 | 41 | |
42 | 42 | return false !== strpos( |
43 | 43 | $args->get_current()->get_the_value() |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | */ |
48 | 48 | public function __construct() { |
49 | 49 | |
50 | - $this->conditions_extension = wordpoints_hooks()->get_sub_app( 'extensions' )->get( |
|
50 | + $this->conditions_extension = wordpoints_hooks()->get_sub_app('extensions')->get( |
|
51 | 51 | 'conditions' |
52 | 52 | ); |
53 | 53 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @since 2.1.0 |
57 | 57 | */ |
58 | 58 | public function get_title() { |
59 | - return __( 'Contains', 'wordpoints' ); |
|
59 | + return __('Contains', 'wordpoints'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | return array( |
67 | 67 | 'min' => array( |
68 | 68 | 'slug' => 'min', |
69 | - 'label' => __( 'Minimum number of items', 'wordpoints' ), |
|
69 | + 'label' => __('Minimum number of items', 'wordpoints'), |
|
70 | 70 | 'type' => 'number', |
71 | 71 | 'default' => 1, |
72 | 72 | ), |
73 | 73 | 'max' => array( |
74 | 74 | 'slug' => 'max', |
75 | - 'label' => __( 'Maximum number of items', 'wordpoints' ), |
|
75 | + 'label' => __('Maximum number of items', 'wordpoints'), |
|
76 | 76 | 'type' => 'number', |
77 | 77 | ), |
78 | 78 | ); |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | |
93 | 93 | $this->validate_count(); |
94 | 94 | |
95 | - if ( isset( $settings['conditions'] ) ) { |
|
96 | - $this->validate_conditions( $arg ); |
|
95 | + if (isset($settings['conditions'])) { |
|
96 | + $this->validate_conditions($arg); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | return $this->settings; |
@@ -107,31 +107,31 @@ discard block |
||
107 | 107 | protected function validate_count() { |
108 | 108 | |
109 | 109 | if ( |
110 | - ! empty( $this->settings['max'] ) |
|
111 | - && ! wordpoints_posint( $this->settings['max'] ) |
|
110 | + ! empty($this->settings['max']) |
|
111 | + && ! wordpoints_posint($this->settings['max']) |
|
112 | 112 | ) { |
113 | 113 | $this->validator->add_error( |
114 | - __( 'The maximum must be a positive integer.', 'wordpoints' ) |
|
114 | + __('The maximum must be a positive integer.', 'wordpoints') |
|
115 | 115 | , 'max' |
116 | 116 | ); |
117 | 117 | } |
118 | 118 | |
119 | - if ( ! empty( $this->settings['min'] ) ) { |
|
119 | + if ( ! empty($this->settings['min'])) { |
|
120 | 120 | |
121 | - if ( ! wordpoints_posint( $this->settings['min'] ) ) { |
|
121 | + if ( ! wordpoints_posint($this->settings['min'])) { |
|
122 | 122 | |
123 | 123 | $this->validator->add_error( |
124 | - __( 'The minimum must be a positive integer.', 'wordpoints' ) |
|
124 | + __('The minimum must be a positive integer.', 'wordpoints') |
|
125 | 125 | , 'min' |
126 | 126 | ); |
127 | 127 | |
128 | 128 | } elseif ( |
129 | - ! empty( $this->settings['max'] ) |
|
129 | + ! empty($this->settings['max']) |
|
130 | 130 | && $this->settings['max'] < $this->settings['min'] |
131 | 131 | ) { |
132 | 132 | |
133 | 133 | $this->validator->add_error( |
134 | - __( 'The minimum must be less than the maximum.', 'wordpoints' ) |
|
134 | + __('The minimum must be less than the maximum.', 'wordpoints') |
|
135 | 135 | , 'min' |
136 | 136 | ); |
137 | 137 | } |
@@ -145,24 +145,24 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @param WordPoints_EntityishI $current_arg The current arg. |
147 | 147 | */ |
148 | - protected function validate_conditions( $current_arg ) { |
|
148 | + protected function validate_conditions($current_arg) { |
|
149 | 149 | |
150 | - $args = new WordPoints_Hook_Event_Args( array() ); |
|
150 | + $args = new WordPoints_Hook_Event_Args(array()); |
|
151 | 151 | |
152 | - if ( $current_arg instanceof WordPoints_Entity_Array ) { |
|
152 | + if ($current_arg instanceof WordPoints_Entity_Array) { |
|
153 | 153 | |
154 | 154 | $entity = wordpoints_entities()->get( |
155 | 155 | $current_arg->get_entity_slug() |
156 | 156 | ); |
157 | 157 | |
158 | - if ( $entity instanceof WordPoints_Entity ) { |
|
159 | - $args->add_entity( $entity ); |
|
158 | + if ($entity instanceof WordPoints_Entity) { |
|
159 | + $args->add_entity($entity); |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | |
163 | - $args->set_validator( $this->validator ); |
|
163 | + $args->set_validator($this->validator); |
|
164 | 164 | |
165 | - $this->validator->push_field( 'conditions' ); |
|
165 | + $this->validator->push_field('conditions'); |
|
166 | 166 | |
167 | 167 | $this->settings['conditions'] = $this->conditions_extension->validate_conditions( |
168 | 168 | $this->settings['conditions'] |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | /** |
176 | 176 | * @since 2.1.0 |
177 | 177 | */ |
178 | - public function is_met( array $settings, WordPoints_Hook_Event_Args $args ) { |
|
178 | + public function is_met(array $settings, WordPoints_Hook_Event_Args $args) { |
|
179 | 179 | |
180 | 180 | $this->settings = $settings; |
181 | 181 | |
@@ -183,16 +183,16 @@ discard block |
||
183 | 183 | |
184 | 184 | $entities = array(); |
185 | 185 | |
186 | - if ( $arg instanceof WordPoints_Entity_Array ) { |
|
186 | + if ($arg instanceof WordPoints_Entity_Array) { |
|
187 | 187 | |
188 | 188 | $entities = $arg->get_the_entities(); |
189 | 189 | |
190 | - if ( isset( $this->settings['conditions'] ) ) { |
|
191 | - $entities = $this->filter_entities( $entities ); |
|
190 | + if (isset($this->settings['conditions'])) { |
|
191 | + $entities = $this->filter_entities($entities); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
195 | - return $this->check_count( count( $entities ) ); |
|
195 | + return $this->check_count(count($entities)); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
@@ -204,20 +204,20 @@ discard block |
||
204 | 204 | * |
205 | 205 | * @return WordPoints_Entity[] The entities that matched the sub-conditions. |
206 | 206 | */ |
207 | - protected function filter_entities( $entities ) { |
|
207 | + protected function filter_entities($entities) { |
|
208 | 208 | |
209 | - foreach ( $entities as $index => $entity ) { |
|
209 | + foreach ($entities as $index => $entity) { |
|
210 | 210 | |
211 | - $event_args = new WordPoints_Hook_Event_Args( array() ); |
|
212 | - $event_args->add_entity( $entity ); |
|
211 | + $event_args = new WordPoints_Hook_Event_Args(array()); |
|
212 | + $event_args->add_entity($entity); |
|
213 | 213 | |
214 | 214 | $matches = $this->conditions_extension->conditions_are_met( |
215 | 215 | $this->settings['conditions'] |
216 | 216 | , $event_args |
217 | 217 | ); |
218 | 218 | |
219 | - if ( ! $matches ) { |
|
220 | - unset( $entities[ $index ] ); |
|
219 | + if ( ! $matches) { |
|
220 | + unset($entities[$index]); |
|
221 | 221 | } |
222 | 222 | } |
223 | 223 | |
@@ -233,13 +233,13 @@ discard block |
||
233 | 233 | * |
234 | 234 | * @return bool Whether the count met the requirements. |
235 | 235 | */ |
236 | - protected function check_count( $count ) { |
|
236 | + protected function check_count($count) { |
|
237 | 237 | |
238 | - if ( isset( $this->settings['max'] ) && $count > $this->settings['max'] ) { |
|
238 | + if (isset($this->settings['max']) && $count > $this->settings['max']) { |
|
239 | 239 | return false; |
240 | 240 | } |
241 | 241 | |
242 | - if ( isset( $this->settings['min'] ) && $count < $this->settings['min'] ) { |
|
242 | + if (isset($this->settings['min']) && $count < $this->settings['min']) { |
|
243 | 243 | return false; |
244 | 244 | } |
245 | 245 |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @since 2.1.0 |
19 | 19 | */ |
20 | 20 | public function get_title() { |
21 | - return __( 'Equals', 'wordpoints' ); |
|
21 | + return __('Equals', 'wordpoints'); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | /** |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | return array( |
30 | 30 | 'value' => array( |
31 | 31 | 'type' => 'text', |
32 | - 'label' => _x( 'Value', 'equals hook condition label', 'wordpoints' ), |
|
32 | + 'label' => _x('Value', 'equals hook condition label', 'wordpoints'), |
|
33 | 33 | ), |
34 | 34 | ); |
35 | 35 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | /** |
38 | 38 | * @since 2.1.0 |
39 | 39 | */ |
40 | - public function is_met( array $settings, WordPoints_Hook_Event_Args $args ) { |
|
40 | + public function is_met(array $settings, WordPoints_Hook_Event_Args $args) { |
|
41 | 41 | |
42 | 42 | return $settings['value'] === $args->get_current()->get_the_value(); |
43 | 43 | } |