mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Sanitize order and orderby in get_bookmarks()
git-svn-id: http://svn.automattic.com/wordpress/trunk@18345 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
581402ae2f
commit
2010842d10
@ -213,22 +213,32 @@ function get_bookmarks($args = '') {
|
||||
|
||||
$orderby = strtolower($orderby);
|
||||
$length = '';
|
||||
switch ($orderby) {
|
||||
switch ( $orderby ) {
|
||||
case 'length':
|
||||
$length = ", CHAR_LENGTH(link_name) AS length";
|
||||
break;
|
||||
case 'rand':
|
||||
$orderby = 'rand()';
|
||||
break;
|
||||
case 'link_id':
|
||||
$orderby = "$wpdb->links.link_id";
|
||||
break;
|
||||
default:
|
||||
$orderparams = array();
|
||||
foreach ( explode(',', $orderby) as $ordparam )
|
||||
$orderparams[] = 'link_' . trim($ordparam);
|
||||
foreach ( explode(',', $orderby) as $ordparam ) {
|
||||
$ordparam = trim($ordparam);
|
||||
if ( in_array( $ordparam, array( 'name', 'url', 'visible', 'rating', 'owner', 'updated' ) ) )
|
||||
$orderparams[] = 'link_' . $ordparam;
|
||||
}
|
||||
$orderby = implode(',', $orderparams);
|
||||
}
|
||||
|
||||
if ( 'link_id' == $orderby )
|
||||
$orderby = "$wpdb->links.link_id";
|
||||
if ( empty( $orderby ) )
|
||||
$orderby = 'link_name';
|
||||
|
||||
$order = strtoupper( $order );
|
||||
if ( '' !== $order && !in_array( $order, array( 'ASC', 'DESC' ) ) )
|
||||
$order = 'ASC';
|
||||
|
||||
$visible = '';
|
||||
if ( $hide_invisible )
|
||||
|
Loading…
Reference in New Issue
Block a user