Changeset 36632 for trunk/src/wp-includes/query.php
- Timestamp:
- 02/23/2016 04:39:50 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/query.php
r36625 r36632 1468 1468 * @since 4.5.0 Removed the `$comments_popup` parameter. 1469 1469 * Introduced the `$comment_status` and `$ping_status` parameters. 1470 * Introduced `RAND(x)` syntax for `$orderby`, which allows an integer seed value to random sorts. 1470 1471 * @access public 1471 1472 * … … 1521 1522 * Default 'date'. Accepts 'none', 'name', 'author', 'date', 1522 1523 * 'title', 'modified', 'menu_order', 'parent', 'ID', 'rand', 1524 * 'RAND(x)' (where 'x' is an integer seed value), 1523 1525 * 'comment_count', 'meta_value', 'meta_value_num', 'post__in', 1524 1526 * and the array keys of `$meta_query`. … … 2333 2335 } 2334 2336 2337 // If RAND() contains a seed value, sanitize and add to allowed keys. 2338 $rand_with_seed = false; 2339 if ( preg_match( '/RAND\(([0-9]+)\)/i', $orderby, $matches ) ) { 2340 $orderby = sprintf( 'RAND(%s)', intval( $matches[1] ) ); 2341 $allowed_keys[] = $orderby; 2342 $rand_with_seed = true; 2343 } 2344 2335 2345 if ( ! in_array( $orderby, $allowed_keys, true ) ) { 2336 2346 return false; … … 2369 2379 $meta_clause = $meta_clauses[ $orderby ]; 2370 2380 $orderby_clause = "CAST({$meta_clause['alias']}.meta_value AS {$meta_clause['cast']})"; 2381 } elseif ( $rand_with_seed ) { 2382 $orderby_clause = $orderby; 2371 2383 } else { 2372 2384 // Default: order by post field.
Note: See TracChangeset
for help on using the changeset viewer.