@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | public function __construct( array $args ) { |
| 79 | 79 | |
| 80 | - $this->slug = $args['slug']; |
|
| 80 | + $this->slug = $args[ 'slug' ]; |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | // |
@@ -193,10 +193,10 @@ discard block |
||
| 193 | 193 | |
| 194 | 194 | // If we aren't using placeholders, calculate the value. Hidden fields |
| 195 | 195 | // never use placeholders. |
| 196 | - if ( ! $args['placeholders'] || 'hidden' === $field['type'] ) { |
|
| 196 | + if ( ! $args[ 'placeholders' ] || 'hidden' === $field[ 'type' ] ) { |
|
| 197 | 197 | |
| 198 | 198 | // Default to the default value. |
| 199 | - $value = $field['default']; |
|
| 199 | + $value = $field[ 'default' ]; |
|
| 200 | 200 | |
| 201 | 201 | // If the value is set use that instead. |
| 202 | 202 | if ( isset( $meta[ $name ] ) ) { |
@@ -204,21 +204,21 @@ discard block |
||
| 204 | 204 | } |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - switch ( $field['type'] ) { |
|
| 207 | + switch ( $field[ 'type' ] ) { |
|
| 208 | 208 | |
| 209 | 209 | case 'hidden': |
| 210 | 210 | case 'number': |
| 211 | 211 | case 'text': |
| 212 | - if ( isset( $field['label'] ) ) { |
|
| 212 | + if ( isset( $field[ 'label' ] ) ) { |
|
| 213 | 213 | ?><p class="description description-thin"><label><?php |
| 214 | - echo esc_html( $field['label'] ); |
|
| 214 | + echo esc_html( $field[ 'label' ] ); |
|
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | ?> |
| 218 | 218 | <input |
| 219 | - type="<?php echo esc_attr( $field['type'] ); ?>" |
|
| 219 | + type="<?php echo esc_attr( $field[ 'type' ] ); ?>" |
|
| 220 | 220 | name="<?php echo esc_attr( $name ); ?>" |
| 221 | - <?php if ( $args['placeholders'] && 'hidden' !== $field['type'] ) : ?> |
|
| 221 | + <?php if ( $args[ 'placeholders' ] && 'hidden' !== $field[ 'type' ] ) : ?> |
|
| 222 | 222 | value="<% if ( typeof <?php echo preg_replace( '/[^a-z0-9_]/i', '', $name ); // WPCS: XSS OK ?> !== "undefined" ) { print( <?php echo preg_replace( '/[^a-z0-9_]/i', '', $name ); // WPCS: XSS OK ?> ); } %>" |
| 223 | 223 | <?php else : ?> |
| 224 | 224 | value="<?php echo esc_attr( $value ); ?>" |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | /> |
| 228 | 228 | <?php |
| 229 | 229 | |
| 230 | - if ( isset( $field['label'] ) ) { |
|
| 230 | + if ( isset( $field[ 'label' ] ) ) { |
|
| 231 | 231 | ?></label></p><?php |
| 232 | 232 | } |
| 233 | 233 | break; |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | __METHOD__ |
| 238 | 238 | , sprintf( |
| 239 | 239 | 'WordPoints Error: Unknown field type "%s".' |
| 240 | - , esc_html( $field['type'] ) |
|
| 240 | + , esc_html( $field[ 'type' ] ) |
|
| 241 | 241 | ) |
| 242 | 242 | , '1.7.0' |
| 243 | 243 | ); |
@@ -237,12 +237,12 @@ discard block |
||
| 237 | 237 | if ( isset( $args[ $arg ] ) ) { |
| 238 | 238 | |
| 239 | 239 | _deprecated_argument( |
| 240 | - esc_html( "{$data['class']}::__construct" ) |
|
| 241 | - , esc_html( $data['version'] ) |
|
| 242 | - , esc_html( "{$arg} is deprecated, use {$data['replacement']} instead" ) |
|
| 240 | + esc_html( "{$data[ 'class' ]}::__construct" ) |
|
| 241 | + , esc_html( $data[ 'version' ] ) |
|
| 242 | + , esc_html( "{$arg} is deprecated, use {$data[ 'replacement' ]} instead" ) |
|
| 243 | 243 | ); |
| 244 | 244 | |
| 245 | - $args[ $data['replacement'] ] = $args[ $arg ]; |
|
| 245 | + $args[ $data[ 'replacement' ] ] = $args[ $arg ]; |
|
| 246 | 246 | |
| 247 | 247 | unset( $args[ $arg ] ); |
| 248 | 248 | } |
@@ -265,12 +265,12 @@ discard block |
||
| 265 | 265 | if ( isset( $this->deprecated_args[ $arg ] ) ) { |
| 266 | 266 | |
| 267 | 267 | _deprecated_argument( |
| 268 | - esc_html( "{$this->deprecated_args[ $arg ]['class']}::get_arg" ) |
|
| 269 | - , esc_html( $this->deprecated_args[ $arg ]['version'] ) |
|
| 270 | - , esc_html( "{$arg} is deprecated, use {$this->deprecated_args[ $arg ]['replacement']} instead" ) |
|
| 268 | + esc_html( "{$this->deprecated_args[ $arg ][ 'class' ]}::get_arg" ) |
|
| 269 | + , esc_html( $this->deprecated_args[ $arg ][ 'version' ] ) |
|
| 270 | + , esc_html( "{$arg} is deprecated, use {$this->deprecated_args[ $arg ][ 'replacement' ]} instead" ) |
|
| 271 | 271 | ); |
| 272 | 272 | |
| 273 | - $arg = $this->deprecated_args[ $arg ]['replacement']; |
|
| 273 | + $arg = $this->deprecated_args[ $arg ][ 'replacement' ]; |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | if ( isset( $this->args[ $arg ] ) ) { |
@@ -298,12 +298,12 @@ discard block |
||
| 298 | 298 | if ( isset( $args[ $arg ] ) ) { |
| 299 | 299 | |
| 300 | 300 | _deprecated_argument( |
| 301 | - esc_html( "{$data['class']}::set_args" ) |
|
| 302 | - , esc_html( $data['version'] ) |
|
| 303 | - , esc_html( "{$arg} is deprecated, use {$data['replacement']} instead" ) |
|
| 301 | + esc_html( "{$data[ 'class' ]}::set_args" ) |
|
| 302 | + , esc_html( $data[ 'version' ] ) |
|
| 303 | + , esc_html( "{$arg} is deprecated, use {$data[ 'replacement' ]} instead" ) |
|
| 304 | 304 | ); |
| 305 | 305 | |
| 306 | - $args[ $data['replacement'] ] = $args[ $arg ]; |
|
| 306 | + $args[ $data[ 'replacement' ] ] = $args[ $arg ]; |
|
| 307 | 307 | |
| 308 | 308 | unset( $args[ $arg ] ); |
| 309 | 309 | } |
@@ -456,9 +456,9 @@ discard block |
||
| 456 | 456 | $all_fields = array_keys( $this->columns ); |
| 457 | 457 | $fields = array(); |
| 458 | 458 | |
| 459 | - if ( ! empty( $this->args['fields'] ) ) { |
|
| 459 | + if ( ! empty( $this->args[ 'fields' ] ) ) { |
|
| 460 | 460 | |
| 461 | - $fields = (array) $this->args['fields']; |
|
| 461 | + $fields = (array) $this->args[ 'fields' ]; |
|
| 462 | 462 | $diff = array_diff( $fields, $all_fields ); |
| 463 | 463 | $fields = array_intersect( $all_fields, $fields ); |
| 464 | 464 | |
@@ -560,11 +560,11 @@ discard block |
||
| 560 | 560 | $validators = array(); |
| 561 | 561 | |
| 562 | 562 | // Default validators for integer columns. |
| 563 | - if ( '%d' === $data['format'] ) { |
|
| 564 | - if ( ! empty( $data['unsigned'] ) ) { |
|
| 565 | - $validators[] = array( $this, 'validate_unsigned_column' ); |
|
| 563 | + if ( '%d' === $data[ 'format' ] ) { |
|
| 564 | + if ( ! empty( $data[ 'unsigned' ] ) ) { |
|
| 565 | + $validators[ ] = array( $this, 'validate_unsigned_column' ); |
|
| 566 | 566 | } else { |
| 567 | - $validators[] = 'wordpoints_int'; |
|
| 567 | + $validators[ ] = 'wordpoints_int'; |
|
| 568 | 568 | } |
| 569 | 569 | } |
| 570 | 570 | |
@@ -604,8 +604,8 @@ discard block |
||
| 604 | 604 | global $wpdb; |
| 605 | 605 | |
| 606 | 606 | if ( |
| 607 | - isset( $data['values'] ) |
|
| 608 | - && ! in_array( $this->args[ $column ], $data['values'], true ) |
|
| 607 | + isset( $data[ 'values' ] ) |
|
| 608 | + && ! in_array( $this->args[ $column ], $data[ 'values' ], true ) |
|
| 609 | 609 | ) { |
| 610 | 610 | return; |
| 611 | 611 | } |
@@ -623,8 +623,8 @@ discard block |
||
| 623 | 623 | |
| 624 | 624 | $column = wordpoints_escape_mysql_identifier( $column ); |
| 625 | 625 | |
| 626 | - $this->wheres[] = $wpdb->prepare( // WPCS: unprepared SQL OK. |
|
| 627 | - "{$column} {$compare} {$data['format']}" |
|
| 626 | + $this->wheres[ ] = $wpdb->prepare( // WPCS: unprepared SQL OK. |
|
| 627 | + "{$column} {$compare} {$data[ 'format' ]}" |
|
| 628 | 628 | , $value |
| 629 | 629 | ); |
| 630 | 630 | } |
@@ -645,7 +645,7 @@ discard block |
||
| 645 | 645 | |
| 646 | 646 | // MySQL doesn't support LIKE and NOT LIKE for int columns. |
| 647 | 647 | // See https://stackoverflow.com/q/8422455/1924128 |
| 648 | - if ( '%s' === $data['format'] ) { |
|
| 648 | + if ( '%s' === $data[ 'format' ] ) { |
|
| 649 | 649 | $comparisons = array_merge( $comparisons, array( 'LIKE', 'NOT LIKE' ) ); |
| 650 | 650 | } |
| 651 | 651 | |
@@ -680,8 +680,8 @@ discard block |
||
| 680 | 680 | |
| 681 | 681 | $values = $this->args[ $key ]; |
| 682 | 682 | |
| 683 | - if ( isset( $data['values'] ) ) { |
|
| 684 | - $values = array_intersect( $values, $data['values'] ); |
|
| 683 | + if ( isset( $data[ 'values' ] ) ) { |
|
| 684 | + $values = array_intersect( $values, $data[ 'values' ] ); |
|
| 685 | 685 | } else { |
| 686 | 686 | $values = $this->validate_values( |
| 687 | 687 | $values |
@@ -693,7 +693,7 @@ discard block |
||
| 693 | 693 | return; |
| 694 | 694 | } |
| 695 | 695 | |
| 696 | - $in = wordpoints_prepare__in( $values, $data['format'] ); |
|
| 696 | + $in = wordpoints_prepare__in( $values, $data[ 'format' ] ); |
|
| 697 | 697 | |
| 698 | 698 | if ( false === $in ) { |
| 699 | 699 | return; |
@@ -701,7 +701,7 @@ discard block |
||
| 701 | 701 | |
| 702 | 702 | $column = wordpoints_escape_mysql_identifier( $column ); |
| 703 | 703 | |
| 704 | - $this->wheres[] = "{$column} {$type} ({$in})"; |
|
| 704 | + $this->wheres[ ] = "{$column} {$type} ({$in})"; |
|
| 705 | 705 | } |
| 706 | 706 | |
| 707 | 707 | /** |
@@ -715,7 +715,7 @@ discard block |
||
| 715 | 715 | |
| 716 | 716 | foreach ( $this->columns as $column => $data ) { |
| 717 | 717 | |
| 718 | - if ( ! empty( $data['is_date'] ) ) { |
|
| 718 | + if ( ! empty( $data[ 'is_date' ] ) ) { |
|
| 719 | 719 | $this->prepare_date_where( $column ); |
| 720 | 720 | } else { |
| 721 | 721 | $this->prepare_column_where( $column, $data ); |
@@ -738,7 +738,7 @@ discard block |
||
| 738 | 738 | |
| 739 | 739 | // MySQL doesn't allow for the offset without a limit, so if no limit is set |
| 740 | 740 | // we can ignore the start arg. See https://stackoverflow.com/a/271650/1924128 |
| 741 | - if ( ! isset( $this->args['limit'] ) ) { |
|
| 741 | + if ( ! isset( $this->args[ 'limit' ] ) ) { |
|
| 742 | 742 | return; |
| 743 | 743 | } |
| 744 | 744 | |
@@ -763,8 +763,8 @@ discard block |
||
| 763 | 763 | } |
| 764 | 764 | } |
| 765 | 765 | |
| 766 | - if ( $this->args['limit'] > 0 && $this->args['start'] >= 0 ) { |
|
| 767 | - $this->limit = "LIMIT {$this->args['start']}, {$this->args['limit']}"; |
|
| 766 | + if ( $this->args[ 'limit' ] > 0 && $this->args[ 'start' ] >= 0 ) { |
|
| 767 | + $this->limit = "LIMIT {$this->args[ 'start' ]}, {$this->args[ 'limit' ]}"; |
|
| 768 | 768 | } |
| 769 | 769 | } |
| 770 | 770 | |
@@ -775,12 +775,12 @@ discard block |
||
| 775 | 775 | */ |
| 776 | 776 | protected function prepare_order_by() { |
| 777 | 777 | |
| 778 | - if ( empty( $this->args['order_by'] ) ) { |
|
| 778 | + if ( empty( $this->args[ 'order_by' ] ) ) { |
|
| 779 | 779 | return; |
| 780 | 780 | } |
| 781 | 781 | |
| 782 | - $order = $this->args['order']; |
|
| 783 | - $order_by = $this->args['order_by']; |
|
| 782 | + $order = $this->args[ 'order' ]; |
|
| 783 | + $order_by = $this->args[ 'order_by' ]; |
|
| 784 | 784 | |
| 785 | 785 | if ( ! in_array( $order, array( 'DESC', 'ASC' ), true ) ) { |
| 786 | 786 | |
@@ -796,9 +796,9 @@ discard block |
||
| 796 | 796 | $wpdb->{"{$this->meta_type}meta"} |
| 797 | 797 | ); |
| 798 | 798 | |
| 799 | - if ( isset( $this->args['meta_type'] ) ) { |
|
| 799 | + if ( isset( $this->args[ 'meta_type' ] ) ) { |
|
| 800 | 800 | |
| 801 | - $meta_type = $this->meta_query->get_cast_for_type( $this->args['meta_type'] ); |
|
| 801 | + $meta_type = $this->meta_query->get_cast_for_type( $this->args[ 'meta_type' ] ); |
|
| 802 | 802 | $order_by = "CAST({$meta_table_name}.meta_value AS {$meta_type})"; |
| 803 | 803 | |
| 804 | 804 | } else { |
@@ -841,7 +841,7 @@ discard block |
||
| 841 | 841 | $date_query = $date_query->get_sql(); |
| 842 | 842 | |
| 843 | 843 | if ( ! empty( $date_query ) ) { |
| 844 | - $this->wheres[] = ltrim( $date_query, ' AND' ); |
|
| 844 | + $this->wheres[ ] = ltrim( $date_query, ' AND' ); |
|
| 845 | 845 | } |
| 846 | 846 | |
| 847 | 847 | remove_filter( 'date_query_valid_columns', array( $this, 'date_query_valid_columns_filter' ) ); |
@@ -883,11 +883,11 @@ discard block |
||
| 883 | 883 | , $this |
| 884 | 884 | ); |
| 885 | 885 | |
| 886 | - if ( ! empty( $meta_query['where'] ) ) { |
|
| 887 | - $this->wheres[] = ltrim( $meta_query['where'], ' AND' ); |
|
| 886 | + if ( ! empty( $meta_query[ 'where' ] ) ) { |
|
| 887 | + $this->wheres[ ] = ltrim( $meta_query[ 'where' ], ' AND' ); |
|
| 888 | 888 | } |
| 889 | 889 | |
| 890 | - $this->meta_join = $meta_query['join'] . "\n"; |
|
| 890 | + $this->meta_join = $meta_query[ 'join' ] . "\n"; |
|
| 891 | 891 | } |
| 892 | 892 | } |
| 893 | 893 | |
@@ -474,7 +474,7 @@ discard block |
||
| 474 | 474 | |
| 475 | 475 | $fields = implode( ', ', array_map( 'wordpoints_escape_mysql_identifier', $fields ) ); |
| 476 | 476 | |
| 477 | - $this->select = "SELECT {$fields}"; |
|
| 477 | + $this->select = "select {$fields}"; |
|
| 478 | 478 | } |
| 479 | 479 | |
| 480 | 480 | /** |
@@ -764,7 +764,7 @@ discard block |
||
| 764 | 764 | } |
| 765 | 765 | |
| 766 | 766 | if ( $this->args['limit'] > 0 && $this->args['start'] >= 0 ) { |
| 767 | - $this->limit = "LIMIT {$this->args['start']}, {$this->args['limit']}"; |
|
| 767 | + $this->limit = "limit {$this->args['start']}, {$this->args['limit']}"; |
|
| 768 | 768 | } |
| 769 | 769 | } |
| 770 | 770 | |
@@ -385,10 +385,10 @@ |
||
| 385 | 385 | } elseif ( $this->is_guid( $value ) ) { |
| 386 | 386 | |
| 387 | 387 | $guid = $this->split_guid( $value ); |
| 388 | - $context = $guid['context']; |
|
| 389 | - $value = $guid['id']; |
|
| 388 | + $context = $guid[ 'context' ]; |
|
| 389 | + $value = $guid[ 'id' ]; |
|
| 390 | 390 | |
| 391 | - $entity = $this->get_entity_from_context( $guid['id'], $context ); |
|
| 391 | + $entity = $this->get_entity_from_context( $guid[ 'id' ], $context ); |
|
| 392 | 392 | |
| 393 | 393 | } else { |
| 394 | 394 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | */ |
| 156 | 156 | protected function validate_condition( $settings ) { |
| 157 | 157 | |
| 158 | - if ( ! isset( $settings['type'] ) ) { |
|
| 158 | + if ( ! isset( $settings[ 'type' ] ) ) { |
|
| 159 | 159 | $this->validator->add_error( __( 'Condition type is missing.', 'wordpoints' ) ); |
| 160 | 160 | return false; |
| 161 | 161 | } |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | return false; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - $condition = $this->conditions->get( $data_type, $settings['type'] ); |
|
| 175 | + $condition = $this->conditions->get( $data_type, $settings[ 'type' ] ); |
|
| 176 | 176 | |
| 177 | 177 | if ( ! $condition ) { |
| 178 | 178 | |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | sprintf( |
| 181 | 181 | // translators: Condition type slug. |
| 182 | 182 | __( 'Unknown condition type “%s”.', 'wordpoints' ) |
| 183 | - , $settings['type'] |
|
| 183 | + , $settings[ 'type' ] |
|
| 184 | 184 | ) |
| 185 | 185 | , 'type' |
| 186 | 186 | ); |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | return false; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - if ( ! isset( $settings['settings'] ) ) { |
|
| 191 | + if ( ! isset( $settings[ 'settings' ] ) ) { |
|
| 192 | 192 | $this->validator->add_error( __( 'Condition settings are missing.', 'wordpoints' ) ); |
| 193 | 193 | return false; |
| 194 | 194 | } |
@@ -200,9 +200,9 @@ discard block |
||
| 200 | 200 | // reset, so we need to back up their values and then restore them below. |
| 201 | 201 | $backup = array( $this->validator, $this->event_args ); |
| 202 | 202 | |
| 203 | - $settings['settings'] = $condition->validate_settings( |
|
| 203 | + $settings[ 'settings' ] = $condition->validate_settings( |
|
| 204 | 204 | $arg |
| 205 | - , $settings['settings'] |
|
| 205 | + , $settings[ 'settings' ] |
|
| 206 | 206 | , $this->validator |
| 207 | 207 | ); |
| 208 | 208 | |
@@ -246,16 +246,16 @@ discard block |
||
| 246 | 246 | |
| 247 | 247 | $event_args->descend( $arg_slug ); |
| 248 | 248 | |
| 249 | - if ( isset( $sub_args['_conditions'] ) ) { |
|
| 249 | + if ( isset( $sub_args[ '_conditions' ] ) ) { |
|
| 250 | 250 | |
| 251 | - foreach ( $sub_args['_conditions'] as $settings ) { |
|
| 251 | + foreach ( $sub_args[ '_conditions' ] as $settings ) { |
|
| 252 | 252 | |
| 253 | 253 | $condition = $this->conditions->get( |
| 254 | 254 | $this->get_data_type( $event_args->get_current() ) |
| 255 | - , $settings['type'] |
|
| 255 | + , $settings[ 'type' ] |
|
| 256 | 256 | ); |
| 257 | 257 | |
| 258 | - $is_met = $condition->is_met( $settings['settings'], $event_args ); |
|
| 258 | + $is_met = $condition->is_met( $settings[ 'settings' ], $event_args ); |
|
| 259 | 259 | |
| 260 | 260 | if ( ! $is_met ) { |
| 261 | 261 | $event_args->ascend(); |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - unset( $sub_args['_conditions'] ); |
|
| 266 | + unset( $sub_args[ '_conditions' ] ); |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | $are_met = $this->conditions_are_met( $sub_args, $event_args ); |
@@ -111,15 +111,15 @@ 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 | 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 |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | * @since 2.1.0 |
| 137 | 137 | */ |
| 138 | 138 | public function update_settings( WordPoints_Hook_ReactionI $reaction, array $settings ) { |
| 139 | - $reaction->update_meta( 'target', $settings['target'] ); |
|
| 139 | + $reaction->update_meta( 'target', $settings[ 'target' ] ); |
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |