X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/699231ae09f7057a4d0000cdf32e50a3df6a04ca..refs/tags/wordpress-3.4:/wp-includes/bookmark.php diff --git a/wp-includes/bookmark.php b/wp-includes/bookmark.php index 641ae3b4..8248e3a6 100644 --- a/wp-includes/bookmark.php +++ b/wp-includes/bookmark.php @@ -7,12 +7,12 @@ */ /** - * Retrieve Bookmark data based on ID + * Retrieve Bookmark data * * @since 2.1.0 * @uses $wpdb Database Object * - * @param int $bookmark_id + * @param mixed $bookmark * @param string $output Optional. Either OBJECT, ARRAY_N, or ARRAY_A constant * @param string $filter Optional, default is 'raw'. * @return array|object Type returned depends on $output value. @@ -101,9 +101,9 @@ function get_bookmark_field( $field, $bookmark, $context = 'display' ) { * links marked as 'invisible'. * 'show_updated' - Default is 0 (integer). Will show the time of when the * bookmark was last updated. - * 'include' - Default is empty string (string). Include other categories + * 'include' - Default is empty string (string). Include bookmark ID(s) * separated by commas. - * 'exclude' - Default is empty string (string). Exclude other categories + * 'exclude' - Default is empty string (string). Exclude bookmark ID(s) * separated by commas. * * @since 2.1.0 @@ -213,22 +213,35 @@ 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); + $keys = array( 'link_id', 'link_name', 'link_url', 'link_visible', 'link_rating', 'link_owner', 'link_updated', 'link_notes' ); + if ( in_array( 'link_' . $ordparam, $keys ) ) + $orderparams[] = 'link_' . $ordparam; + elseif ( in_array( $ordparam, $keys ) ) + $orderparams[] = $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 ) @@ -334,11 +347,10 @@ function sanitize_bookmark_field($field, $value, $bookmark_id, $context) { return $value; if ( 'edit' == $context ) { - $format_to_edit = array('link_notes'); $value = apply_filters("edit_$field", $value, $bookmark_id); - if ( in_array($field, $format_to_edit) ) { - $value = format_to_edit($value); + if ( 'link_notes' == $field ) { + $value = esc_html( $value ); // textarea_escaped } else { $value = esc_attr($value); } @@ -363,9 +375,8 @@ function sanitize_bookmark_field($field, $value, $bookmark_id, $context) { * @since 2.7.0 * @uses wp_cache_delete() Deletes the contents of 'get_bookmarks' */ -function clean_bookmark_cache($bookmark_id) { +function clean_bookmark_cache( $bookmark_id ) { wp_cache_delete( $bookmark_id, 'bookmark' ); wp_cache_delete( 'get_bookmarks', 'bookmark' ); + clean_object_term_cache( $bookmark_id, 'link'); } - -?>