Ticket #43977: 43977.2.diff
| File 43977.2.diff, 7.2 KB (added by , 8 years ago) |
|---|
-
src/wp-includes/bookmark.php
171 171 $r['exclude'] = ''; //ignore exclude, category, and category_name params if using include 172 172 $r['category'] = ''; 173 173 $r['category_name'] = ''; 174 $inclinks = preg_split( '/[\s,]+/',$r['include'] );174 $inclinks = wp_parse_id_list( $r['include'] ); 175 175 if ( count( $inclinks ) ) { 176 176 foreach ( $inclinks as $inclink ) { 177 177 if ( empty( $inclusions ) ) { 178 $inclusions = ' AND ( link_id = ' . intval( $inclink ). ' ';178 $inclusions = ' AND ( link_id = ' . $inclink . ' '; 179 179 } else { 180 $inclusions .= ' OR link_id = ' . intval( $inclink ). ' ';180 $inclusions .= ' OR link_id = ' . $inclink . ' '; 181 181 } 182 182 } 183 183 } … … 188 188 189 189 $exclusions = ''; 190 190 if ( ! empty( $r['exclude'] ) ) { 191 $exlinks = preg_split( '/[\s,]+/',$r['exclude'] );191 $exlinks = wp_parse_id_list( $r['exclude'] ); 192 192 if ( count( $exlinks ) ) { 193 193 foreach ( $exlinks as $exlink ) { 194 194 if ( empty( $exclusions ) ) { 195 $exclusions = ' AND ( link_id <> ' . intval( $exlink ). ' ';195 $exclusions = ' AND ( link_id <> ' . $exlink . ' '; 196 196 } else { 197 $exclusions .= ' AND link_id <> ' . intval( $exlink ). ' ';197 $exclusions .= ' AND link_id <> ' . $exlink . ' '; 198 198 } 199 199 } 200 200 } … … 223 223 $category_query = ''; 224 224 $join = ''; 225 225 if ( ! empty( $r['category'] ) ) { 226 $incategories = preg_split( '/[\s,]+/',$r['category'] );226 $incategories = wp_parse_id_list( $r['category'] ); 227 227 if ( count( $incategories ) ) { 228 228 foreach ( $incategories as $incat ) { 229 229 if ( empty( $category_query ) ) { 230 $category_query = ' AND ( tt.term_id = ' . intval( $incat ). ' ';230 $category_query = ' AND ( tt.term_id = ' . $incat . ' '; 231 231 } else { 232 $category_query .= ' OR tt.term_id = ' . intval( $incat ). ' ';232 $category_query .= ' OR tt.term_id = ' . $incat . ' '; 233 233 } 234 234 } 235 235 } -
src/wp-includes/class-wp-comment-query.php
482 482 483 483 // 'status' accepts an array or a comma-separated string. 484 484 $status_clauses = array(); 485 $statuses = $this->query_vars['status']; 486 if ( ! is_array( $statuses ) ) { 487 $statuses = preg_split( '/[\s,]+/', $statuses ); 488 } 485 $statuses = wp_parse_list( $this->query_vars['status'] ); 489 486 490 487 // 'any' overrides other statuses. 491 488 if ( ! in_array( 'any', $statuses ) ) { … … 517 514 518 515 // User IDs or emails whose unapproved comments are included, regardless of $status. 519 516 if ( ! empty( $this->query_vars['include_unapproved'] ) ) { 520 $include_unapproved = $this->query_vars['include_unapproved']; 521 522 // Accepts arrays or comma-separated strings. 523 if ( ! is_array( $include_unapproved ) ) { 524 $include_unapproved = preg_split( '/[\s,]+/', $include_unapproved ); 525 } 517 $include_unapproved = wp_parse_list( $this->query_vars['include_unapproved'] ); 526 518 527 $unapproved_ids = $unapproved_emails = array(); 519 $unapproved_ids = array(); 520 $unapproved_emails = array(); 528 521 foreach ( $include_unapproved as $unapproved_identifier ) { 529 522 // Numeric values are assumed to be user ids. 530 523 if ( is_numeric( $unapproved_identifier ) ) { -
src/wp-includes/functions.php
3692 3692 } 3693 3693 3694 3694 /** 3695 * Cleans up an array, comma- or space-separated list of scalar values. 3696 * 3697 * @since 5.0.0 3698 * 3699 * @param array|string $list List of values. 3700 * @return array Sanitized array of values. 3701 */ 3702 function wp_parse_list( $list ) { 3703 if ( ! is_array( $list ) ) { 3704 return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); 3705 } 3706 3707 return $list; 3708 } 3709 3710 /** 3695 3711 * Clean up an array, comma- or space-separated list of IDs. 3696 3712 * 3697 3713 * @since 3.0.0 … … 3700 3716 * @return array Sanitized array of IDs. 3701 3717 */ 3702 3718 function wp_parse_id_list( $list ) { 3703 if ( ! is_array( $list ) ) { 3704 $list = preg_split( '/[\s,]+/', $list ); 3705 } 3719 $list = wp_parse_list( $list ); 3706 3720 3707 3721 return array_unique( array_map( 'absint', $list ) ); 3708 3722 } … … 3716 3730 * @return array Sanitized array of slugs. 3717 3731 */ 3718 3732 function wp_parse_slug_list( $list ) { 3719 if ( ! is_array( $list ) ) { 3720 $list = preg_split( '/[\s,]+/', $list ); 3721 } 3722 3723 foreach ( $list as $key => $value ) { 3724 $list[ $key ] = sanitize_title( $value ); 3725 } 3733 $list = wp_parse_list( $list ); 3726 3734 3727 return array_unique( $list);3735 return array_unique( array_map( 'sanitize_title', $list ) ); 3728 3736 } 3729 3737 3730 3738 /** -
src/wp-includes/post.php
5004 5004 5005 5005 $author_query = ''; 5006 5006 if ( ! empty( $r['authors'] ) ) { 5007 $post_authors = preg_split( '/[\s,]+/',$r['authors'] );5007 $post_authors = wp_parse_list( $r['authors'] ); 5008 5008 5009 5009 if ( ! empty( $post_authors ) ) { 5010 5010 foreach ( $post_authors as $post_author ) { -
src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php
521 521 if ( ! isset( $request['_fields'] ) ) { 522 522 return $fields; 523 523 } 524 $requested_fields = is_array( $request['_fields'] ) ? $request['_fields'] : preg_split( '/[\s,]+/',$request['_fields'] );524 $requested_fields = wp_parse_list( $request['_fields'] ); 525 525 if ( 0 === count( $requested_fields ) ) { 526 526 return $fields; 527 527 } -
src/wp-includes/rest-api.php
651 651 652 652 $data = $response->get_data(); 653 653 654 $fields = is_array( $request['_fields'] ) ? $request['_fields'] : preg_split( '/[\s,]+/',$request['_fields'] );654 $fields = wp_parse_list( $request['_fields'] ); 655 655 656 656 if ( 0 === count( $fields ) ) { 657 657 return $response; … … 1081 1081 */ 1082 1082 function rest_validate_value_from_schema( $value, $args, $param = '' ) { 1083 1083 if ( 'array' === $args['type'] ) { 1084 if ( ! is_array( $value ) ) { 1085 $value = preg_split( '/[\s,]+/', $value ); 1086 } 1084 $value = wp_parse_list( $value ); 1087 1085 if ( ! wp_is_numeric_array( $value ) ) { 1088 1086 /* translators: 1: parameter, 2: type name */ 1089 1087 return new WP_Error( 'rest_invalid_param', sprintf( __( '%1$s is not of type %2$s.' ), $param, 'array' ) ); … … 1225 1223 if ( empty( $args['items'] ) ) { 1226 1224 return (array) $value; 1227 1225 } 1228 if ( ! is_array( $value ) ) { 1229 $value = preg_split( '/[\s,]+/', $value ); 1230 } 1226 $value = wp_parse_list( $value ); 1231 1227 foreach ( $value as $index => $v ) { 1232 1228 $value[ $index ] = rest_sanitize_value_from_schema( $v, $args['items'] ); 1233 1229 }