@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @since 2.1.0 |
| 35 | 35 | */ |
| 36 | 36 | public function __construct() { |
| 37 | - $this->conditions = wordpoints_hooks()->get_sub_app( 'conditions' ); |
|
| 37 | + $this->conditions = wordpoints_hooks()->get_sub_app('conditions'); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
@@ -44,14 +44,14 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | $conditions_data = array(); |
| 46 | 46 | |
| 47 | - foreach ( $this->conditions->get_all() as $data_type => $conditions ) { |
|
| 48 | - foreach ( $conditions as $slug => $condition ) { |
|
| 47 | + foreach ($this->conditions->get_all() as $data_type => $conditions) { |
|
| 48 | + foreach ($conditions as $slug => $condition) { |
|
| 49 | 49 | |
| 50 | - if ( ! ( $condition instanceof WordPoints_Hook_ConditionI ) ) { |
|
| 50 | + if ( ! ($condition instanceof WordPoints_Hook_ConditionI)) { |
|
| 51 | 51 | continue; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - $conditions_data[ $data_type ][ $slug ] = array( |
|
| 54 | + $conditions_data[$data_type][$slug] = array( |
|
| 55 | 55 | 'slug' => $slug, |
| 56 | 56 | 'data_type' => $data_type, |
| 57 | 57 | 'title' => $condition->get_title(), |
@@ -60,14 +60,14 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - return array( 'conditions' => $conditions_data ); |
|
| 63 | + return array('conditions' => $conditions_data); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
| 67 | 67 | * @since 2.1.0 |
| 68 | 68 | */ |
| 69 | - protected function validate_action_type_settings( $settings ) { |
|
| 70 | - return $this->validate_conditions( $settings ); |
|
| 69 | + protected function validate_action_type_settings($settings) { |
|
| 70 | + return $this->validate_conditions($settings); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -80,36 +80,36 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | * @return array The validated settings. |
| 82 | 82 | */ |
| 83 | - public function validate_conditions( $conditions, WordPoints_Hook_Event_Args $event_args = null ) { |
|
| 83 | + public function validate_conditions($conditions, WordPoints_Hook_Event_Args $event_args = null) { |
|
| 84 | 84 | |
| 85 | - if ( $event_args ) { |
|
| 85 | + if ($event_args) { |
|
| 86 | 86 | $this->event_args = $event_args; |
| 87 | 87 | $this->validator = $event_args->get_validator(); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - if ( ! is_array( $conditions ) ) { |
|
| 90 | + if ( ! is_array($conditions)) { |
|
| 91 | 91 | |
| 92 | 92 | $this->validator->add_error( |
| 93 | - __( 'Conditions do not match expected format.', 'wordpoints' ) |
|
| 93 | + __('Conditions do not match expected format.', 'wordpoints') |
|
| 94 | 94 | ); |
| 95 | 95 | |
| 96 | 96 | return array(); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - foreach ( $conditions as $arg_slug => $sub_args ) { |
|
| 99 | + foreach ($conditions as $arg_slug => $sub_args) { |
|
| 100 | 100 | |
| 101 | - if ( '_conditions' === $arg_slug ) { |
|
| 101 | + if ('_conditions' === $arg_slug) { |
|
| 102 | 102 | |
| 103 | - $this->validator->push_field( $arg_slug ); |
|
| 103 | + $this->validator->push_field($arg_slug); |
|
| 104 | 104 | |
| 105 | - foreach ( $sub_args as $index => $settings ) { |
|
| 105 | + foreach ($sub_args as $index => $settings) { |
|
| 106 | 106 | |
| 107 | - $this->validator->push_field( $index ); |
|
| 107 | + $this->validator->push_field($index); |
|
| 108 | 108 | |
| 109 | - $condition = $this->validate_condition( $settings ); |
|
| 109 | + $condition = $this->validate_condition($settings); |
|
| 110 | 110 | |
| 111 | - if ( $condition ) { |
|
| 112 | - $sub_args[ $index ] = $condition; |
|
| 111 | + if ($condition) { |
|
| 112 | + $sub_args[$index] = $condition; |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | $this->validator->pop_field(); |
@@ -119,18 +119,18 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | } else { |
| 121 | 121 | |
| 122 | - if ( ! $this->event_args->descend( $arg_slug ) ) { |
|
| 122 | + if ( ! $this->event_args->descend($arg_slug)) { |
|
| 123 | 123 | continue; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - $sub_args = $this->validate_action_type_settings( $sub_args ); |
|
| 126 | + $sub_args = $this->validate_action_type_settings($sub_args); |
|
| 127 | 127 | |
| 128 | - $conditions[ $arg_slug ] = $sub_args; |
|
| 128 | + $conditions[$arg_slug] = $sub_args; |
|
| 129 | 129 | |
| 130 | 130 | $this->event_args->ascend(); |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - $conditions[ $arg_slug ] = $sub_args; |
|
| 133 | + $conditions[$arg_slug] = $sub_args; |
|
| 134 | 134 | |
| 135 | 135 | } // End foreach ( $conditions ). |
| 136 | 136 | |
@@ -147,32 +147,32 @@ discard block |
||
| 147 | 147 | * @return array|false The validated conditions settings, or false if unable to |
| 148 | 148 | * validate. |
| 149 | 149 | */ |
| 150 | - protected function validate_condition( $settings ) { |
|
| 150 | + protected function validate_condition($settings) { |
|
| 151 | 151 | |
| 152 | - if ( ! isset( $settings['type'] ) ) { |
|
| 153 | - $this->validator->add_error( __( 'Condition type is missing.', 'wordpoints' ) ); |
|
| 152 | + if ( ! isset($settings['type'])) { |
|
| 153 | + $this->validator->add_error(__('Condition type is missing.', 'wordpoints')); |
|
| 154 | 154 | return false; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | $arg = $this->event_args->get_current(); |
| 158 | 158 | |
| 159 | - $data_type = $this->get_data_type( $arg ); |
|
| 159 | + $data_type = $this->get_data_type($arg); |
|
| 160 | 160 | |
| 161 | - if ( ! $data_type ) { |
|
| 161 | + if ( ! $data_type) { |
|
| 162 | 162 | $this->validator->add_error( |
| 163 | - __( 'This type of condition does not work for the selected attribute.', 'wordpoints' ) |
|
| 163 | + __('This type of condition does not work for the selected attribute.', 'wordpoints') |
|
| 164 | 164 | ); |
| 165 | 165 | |
| 166 | 166 | return false; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - $condition = $this->conditions->get( $data_type, $settings['type'] ); |
|
| 169 | + $condition = $this->conditions->get($data_type, $settings['type']); |
|
| 170 | 170 | |
| 171 | - if ( ! $condition ) { |
|
| 171 | + if ( ! $condition) { |
|
| 172 | 172 | |
| 173 | 173 | $this->validator->add_error( |
| 174 | 174 | sprintf( |
| 175 | - __( 'Unknown condition type “%s”.', 'wordpoints' ) |
|
| 175 | + __('Unknown condition type “%s”.', 'wordpoints') |
|
| 176 | 176 | , $settings['type'] |
| 177 | 177 | ) |
| 178 | 178 | , 'type' |
@@ -181,17 +181,17 @@ discard block |
||
| 181 | 181 | return false; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - if ( ! isset( $settings['settings'] ) ) { |
|
| 185 | - $this->validator->add_error( __( 'Condition settings are missing.', 'wordpoints' ) ); |
|
| 184 | + if ( ! isset($settings['settings'])) { |
|
| 185 | + $this->validator->add_error(__('Condition settings are missing.', 'wordpoints')); |
|
| 186 | 186 | return false; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - $this->validator->push_field( 'settings' ); |
|
| 189 | + $this->validator->push_field('settings'); |
|
| 190 | 190 | |
| 191 | 191 | // The condition may call this object's validate_settings() method to |
| 192 | 192 | // validate some sub-conditions. When that happens, these properties will be |
| 193 | 193 | // reset, so we need to back up their values and then restore them below. |
| 194 | - $backup = array( $this->validator, $this->event_args ); |
|
| 194 | + $backup = array($this->validator, $this->event_args); |
|
| 195 | 195 | |
| 196 | 196 | $settings['settings'] = $condition->validate_settings( |
| 197 | 197 | $arg |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | , $this->validator |
| 200 | 200 | ); |
| 201 | 201 | |
| 202 | - list( $this->validator, $this->event_args ) = $backup; |
|
| 202 | + list($this->validator, $this->event_args) = $backup; |
|
| 203 | 203 | |
| 204 | 204 | $this->validator->pop_field(); |
| 205 | 205 | |
@@ -209,11 +209,11 @@ discard block |
||
| 209 | 209 | /** |
| 210 | 210 | * @since 2.1.0 |
| 211 | 211 | */ |
| 212 | - public function should_hit( WordPoints_Hook_Fire $fire ) { |
|
| 212 | + public function should_hit(WordPoints_Hook_Fire $fire) { |
|
| 213 | 213 | |
| 214 | - $conditions = $this->get_settings_from_fire( $fire ); |
|
| 214 | + $conditions = $this->get_settings_from_fire($fire); |
|
| 215 | 215 | |
| 216 | - if ( $conditions && ! $this->conditions_are_met( $conditions, $fire->event_args ) ) { |
|
| 216 | + if ($conditions && ! $this->conditions_are_met($conditions, $fire->event_args)) { |
|
| 217 | 217 | return false; |
| 218 | 218 | } |
| 219 | 219 | |
@@ -235,35 +235,35 @@ discard block |
||
| 235 | 235 | WordPoints_Hook_Event_Args $event_args |
| 236 | 236 | ) { |
| 237 | 237 | |
| 238 | - foreach ( $conditions as $arg_slug => $sub_args ) { |
|
| 238 | + foreach ($conditions as $arg_slug => $sub_args) { |
|
| 239 | 239 | |
| 240 | - $event_args->descend( $arg_slug ); |
|
| 240 | + $event_args->descend($arg_slug); |
|
| 241 | 241 | |
| 242 | - if ( isset( $sub_args['_conditions'] ) ) { |
|
| 242 | + if (isset($sub_args['_conditions'])) { |
|
| 243 | 243 | |
| 244 | - foreach ( $sub_args['_conditions'] as $settings ) { |
|
| 244 | + foreach ($sub_args['_conditions'] as $settings) { |
|
| 245 | 245 | |
| 246 | 246 | $condition = $this->conditions->get( |
| 247 | - $this->get_data_type( $event_args->get_current() ) |
|
| 247 | + $this->get_data_type($event_args->get_current()) |
|
| 248 | 248 | , $settings['type'] |
| 249 | 249 | ); |
| 250 | 250 | |
| 251 | - $is_met = $condition->is_met( $settings['settings'], $event_args ); |
|
| 251 | + $is_met = $condition->is_met($settings['settings'], $event_args); |
|
| 252 | 252 | |
| 253 | - if ( ! $is_met ) { |
|
| 253 | + if ( ! $is_met) { |
|
| 254 | 254 | $event_args->ascend(); |
| 255 | 255 | return false; |
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - unset( $sub_args['_conditions'] ); |
|
| 259 | + unset($sub_args['_conditions']); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - $are_met = $this->conditions_are_met( $sub_args, $event_args ); |
|
| 262 | + $are_met = $this->conditions_are_met($sub_args, $event_args); |
|
| 263 | 263 | |
| 264 | 264 | $event_args->ascend(); |
| 265 | 265 | |
| 266 | - if ( ! $are_met ) { |
|
| 266 | + if ( ! $are_met) { |
|
| 267 | 267 | return false; |
| 268 | 268 | } |
| 269 | 269 | } |
@@ -280,13 +280,13 @@ discard block |
||
| 280 | 280 | * |
| 281 | 281 | * @return string|false The data type, or false. |
| 282 | 282 | */ |
| 283 | - protected function get_data_type( $arg ) { |
|
| 283 | + protected function get_data_type($arg) { |
|
| 284 | 284 | |
| 285 | - if ( $arg instanceof WordPoints_Entity_Attr ) { |
|
| 285 | + if ($arg instanceof WordPoints_Entity_Attr) { |
|
| 286 | 286 | $data_type = $arg->get_data_type(); |
| 287 | - } elseif ( $arg instanceof WordPoints_Entity_Array ) { |
|
| 287 | + } elseif ($arg instanceof WordPoints_Entity_Array) { |
|
| 288 | 288 | $data_type = 'entity_array'; |
| 289 | - } elseif ( $arg instanceof WordPoints_Entity ) { |
|
| 289 | + } elseif ($arg instanceof WordPoints_Entity) { |
|
| 290 | 290 | $data_type = 'entity'; |
| 291 | 291 | } else { |
| 292 | 292 | $data_type = false; |
@@ -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 | } |
@@ -111,21 +111,21 @@ discard block |
||
| 111 | 111 | ) { |
| 112 | 112 | |
| 113 | 113 | if ( |
| 114 | - empty( $settings['target'] ) |
|
| 115 | - || ! is_array( $settings['target'] ) |
|
| 114 | + empty($settings['target']) |
|
| 115 | + || ! is_array($settings['target']) |
|
| 116 | 116 | ) { |
| 117 | 117 | |
| 118 | - $validator->add_error( __( 'Invalid target.', 'wordpoints' ), 'target' ); |
|
| 118 | + $validator->add_error(__('Invalid target.', 'wordpoints'), 'target'); |
|
| 119 | 119 | |
| 120 | 120 | } else { |
| 121 | 121 | |
| 122 | - $target = $event_args->get_from_hierarchy( $settings['target'] ); |
|
| 122 | + $target = $event_args->get_from_hierarchy($settings['target']); |
|
| 123 | 123 | |
| 124 | 124 | if ( |
| 125 | 125 | ! $target instanceof WordPoints_Entity |
| 126 | - || ! in_array( $target->get_slug(), (array) $this->arg_types ) |
|
| 126 | + || ! in_array($target->get_slug(), (array) $this->arg_types) |
|
| 127 | 127 | ) { |
| 128 | - $validator->add_error( __( 'Invalid target.', 'wordpoints' ), 'target' ); |
|
| 128 | + $validator->add_error(__('Invalid target.', 'wordpoints'), 'target'); |
|
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | |
@@ -135,8 +135,8 @@ discard block |
||
| 135 | 135 | /** |
| 136 | 136 | * @since 2.1.0 |
| 137 | 137 | */ |
| 138 | - public function update_settings( WordPoints_Hook_ReactionI $reaction, array $settings ) { |
|
| 139 | - $reaction->update_meta( 'target', $settings['target'] ); |
|
| 138 | + public function update_settings(WordPoints_Hook_ReactionI $reaction, array $settings) { |
|
| 139 | + $reaction->update_meta('target', $settings['target']); |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
@@ -88,11 +88,11 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function hit() { |
| 90 | 90 | |
| 91 | - if ( ! $this->hit_id ) { |
|
| 91 | + if ( ! $this->hit_id) { |
|
| 92 | 92 | |
| 93 | 93 | $this->hit_id = $this->log_hit(); |
| 94 | 94 | |
| 95 | - if ( ! $this->hit_id ) { |
|
| 95 | + if ( ! $this->hit_id) { |
|
| 96 | 96 | return false; |
| 97 | 97 | } |
| 98 | 98 | } |
@@ -128,11 +128,11 @@ discard block |
||
| 128 | 128 | $this->reaction->get_context_id() |
| 129 | 129 | ), |
| 130 | 130 | 'reaction_id' => $this->reaction->get_id(), |
| 131 | - 'date' => current_time( 'mysql', true ), |
|
| 131 | + 'date' => current_time('mysql', true), |
|
| 132 | 132 | ) |
| 133 | 133 | ); |
| 134 | 134 | |
| 135 | - if ( ! $inserted ) { |
|
| 135 | + if ( ! $inserted) { |
|
| 136 | 136 | return false; |
| 137 | 137 | } |
| 138 | 138 | |