]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/bookmark.php
WordPress 4.6.3-scripts
[autoinstalls/wordpress.git] / wp-includes / bookmark.php
index 140f5fdc48bb66aa0131a56f183c91fdc06cc500..fc719d5898594c414569a0b37f8d8cf61e1fa922 100644 (file)
@@ -128,11 +128,12 @@ function get_bookmarks( $args = '' ) {
        $r = wp_parse_args( $args, $defaults );
 
        $key = md5( serialize( $r ) );
-       if ( $cache = wp_cache_get( 'get_bookmarks', 'bookmark' ) ) {
+       $cache = false;
+       if ( 'rand' !== $r['orderby'] && $cache = wp_cache_get( 'get_bookmarks', 'bookmark' ) ) {
                if ( is_array( $cache ) && isset( $cache[ $key ] ) ) {
                        $bookmarks = $cache[ $key ];
                        /**
-                        * Filter the returned list of bookmarks.
+                        * Filters the returned list of bookmarks.
                         *
                         * The first time the hook is evaluated in this file, it returns the cached
                         * bookmarks list. The second evaluation returns a cached bookmarks list if the
@@ -285,8 +286,10 @@ function get_bookmarks( $args = '' ) {
 
        $results = $wpdb->get_results( $query );
 
-       $cache[ $key ] = $results;
-       wp_cache_set( 'get_bookmarks', $cache, 'bookmark' );
+       if ( 'rand()' !== $orderby ) {
+               $cache[ $key ] = $results;
+               wp_cache_set( 'get_bookmarks', $cache, 'bookmark' );
+       }
 
        /** This filter is documented in wp-includes/bookmark.php */
        return apply_filters( 'get_bookmarks', $results, $r );
@@ -329,30 +332,30 @@ function sanitize_bookmark($bookmark, $context = 'display') {
 }
 
 /**
- * Sanitizes a bookmark field
+ * Sanitizes a bookmark field.
  *
  * Sanitizes the bookmark fields based on what the field name is. If the field
  * has a strict value set, then it will be tested for that, else a more generic
- * filtering is applied. After the more strict filter is applied, if the
- * $context is 'raw' then the value is immediately return.
+ * filtering is applied. After the more strict filter is applied, if the `$context`
+ * is 'raw' then the value is immediately return.
+ *
+ * Hooks exist for the more generic cases. With the 'edit' context, the {@see 'edit_$field'}
+ * filter will be called and passed the `$value` and `$bookmark_id` respectively.
  *
- * Hooks exist for the more generic cases. With the 'edit' context, the
- * 'edit_$field' filter will be called and passed the $value and $bookmark_id
- * respectively. With the 'db' context, the 'pre_$field' filter is called and
- * passed the value. The 'display' context is the final context and has the
- * $field has the filter name and is passed the $value, $bookmark_id, and
- * $context respectively.
+ * With the 'db' context, the {@see 'pre_$field'} filter is called and passed the value.
+ * The 'display' context is the final context and has the `$field` has the filter name
+ * and is passed the `$value`, `$bookmark_id`, and `$context`, respectively.
  *
  * @since 2.3.0
  *
- * @param string $field The bookmark field
- * @param mixed $value The bookmark field value
- * @param int $bookmark_id Bookmark ID
- * @param string $context How to filter the field value. Either 'raw', 'edit',
- *             'attribute', 'js', 'db', or 'display'
- * @return mixed The filtered value
+ * @param string $field       The bookmark field.
+ * @param mixed  $value       The bookmark field value.
+ * @param int    $bookmark_id Bookmark ID.
+ * @param string $context     How to filter the field value. Accepts 'raw', 'edit', 'attribute',
+ *                            'js', 'db', or 'display'
+ * @return mixed The filtered value.
  */
-function sanitize_bookmark_field($field, $value, $bookmark_id, $context) {
+function sanitize_bookmark_field( $field, $value, $bookmark_id, $context ) {
        switch ( $field ) {
        case 'link_id' : // ints
        case 'link_rating' :