Changeset 45667 for trunk/src/wp-includes/bookmark.php
- Timestamp:
- 07/25/2019 12:47:53 AM (6 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/bookmark.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/bookmark.php
r45590 r45667 140 140 ); 141 141 142 $ r= wp_parse_args( $args, $defaults );143 144 $key = md5( serialize( $ r) );142 $parsed_args = wp_parse_args( $args, $defaults ); 143 144 $key = md5( serialize( $parsed_args ) ); 145 145 $cache = wp_cache_get( 'get_bookmarks', 'bookmark' ); 146 if ( 'rand' !== $r['orderby'] && $cache ) { 146 147 if ( 'rand' !== $parsed_args['orderby'] && $cache ) { 147 148 if ( is_array( $cache ) && isset( $cache[ $key ] ) ) { 148 149 $bookmarks = $cache[ $key ]; … … 160 161 * 161 162 * @param array $bookmarks List of the cached bookmarks. 162 * @param array $ rAn array of bookmark query arguments.163 * @param array $parsed_args An array of bookmark query arguments. 163 164 */ 164 return apply_filters( 'get_bookmarks', $bookmarks, $ r);165 return apply_filters( 'get_bookmarks', $bookmarks, $parsed_args ); 165 166 } 166 167 } … … 171 172 172 173 $inclusions = ''; 173 if ( ! empty( $r['include'] ) ) { 174 $r['exclude'] = ''; //ignore exclude, category, and category_name params if using include 175 $r['category'] = ''; 176 $r['category_name'] = ''; 177 $inclinks = wp_parse_id_list( $r['include'] ); 174 if ( ! empty( $parsed_args['include'] ) ) { 175 $parsed_args['exclude'] = ''; //ignore exclude, category, and category_name params if using include 176 $parsed_args['category'] = ''; 177 $parsed_args['category_name'] = ''; 178 179 $inclinks = wp_parse_id_list( $parsed_args['include'] ); 178 180 if ( count( $inclinks ) ) { 179 181 foreach ( $inclinks as $inclink ) { … … 191 193 192 194 $exclusions = ''; 193 if ( ! empty( $ r['exclude'] ) ) {194 $exlinks = wp_parse_id_list( $ r['exclude'] );195 if ( ! empty( $parsed_args['exclude'] ) ) { 196 $exlinks = wp_parse_id_list( $parsed_args['exclude'] ); 195 197 if ( count( $exlinks ) ) { 196 198 foreach ( $exlinks as $exlink ) { … … 207 209 } 208 210 209 if ( ! empty( $ r['category_name'] ) ) {210 $ r['category'] = get_term_by( 'name', $r['category_name'], 'link_category' );211 if ( $ r['category'] ) {212 $ r['category'] = $r['category']->term_id;211 if ( ! empty( $parsed_args['category_name'] ) ) { 212 $parsed_args['category'] = get_term_by( 'name', $parsed_args['category_name'], 'link_category' ); 213 if ( $parsed_args['category'] ) { 214 $parsed_args['category'] = $parsed_args['category']->term_id; 213 215 } else { 214 216 $cache[ $key ] = array(); 215 217 wp_cache_set( 'get_bookmarks', $cache, 'bookmark' ); 216 218 /** This filter is documented in wp-includes/bookmark.php */ 217 return apply_filters( 'get_bookmarks', array(), $ r);219 return apply_filters( 'get_bookmarks', array(), $parsed_args ); 218 220 } 219 221 } 220 222 221 223 $search = ''; 222 if ( ! empty( $ r['search'] ) ) {223 $like = '%' . $wpdb->esc_like( $ r['search'] ) . '%';224 if ( ! empty( $parsed_args['search'] ) ) { 225 $like = '%' . $wpdb->esc_like( $parsed_args['search'] ) . '%'; 224 226 $search = $wpdb->prepare( ' AND ( (link_url LIKE %s) OR (link_name LIKE %s) OR (link_description LIKE %s) ) ', $like, $like, $like ); 225 227 } … … 227 229 $category_query = ''; 228 230 $join = ''; 229 if ( ! empty( $ r['category'] ) ) {230 $incategories = wp_parse_id_list( $ r['category'] );231 if ( ! empty( $parsed_args['category'] ) ) { 232 $incategories = wp_parse_id_list( $parsed_args['category'] ); 231 233 if ( count( $incategories ) ) { 232 234 foreach ( $incategories as $incat ) { … … 244 246 } 245 247 246 if ( $ r['show_updated'] ) {248 if ( $parsed_args['show_updated'] ) { 247 249 $recently_updated_test = ', IF (DATE_ADD(link_updated, INTERVAL 120 MINUTE) >= NOW(), 1,0) as recently_updated '; 248 250 } else { … … 250 252 } 251 253 252 $get_updated = ( $ r['show_updated'] ) ? ', UNIX_TIMESTAMP(link_updated) AS link_updated_f ' : '';253 254 $orderby = strtolower( $ r['orderby'] );254 $get_updated = ( $parsed_args['show_updated'] ) ? ', UNIX_TIMESTAMP(link_updated) AS link_updated_f ' : ''; 255 256 $orderby = strtolower( $parsed_args['orderby'] ); 255 257 $length = ''; 256 258 switch ( $orderby ) { … … 283 285 } 284 286 285 $order = strtoupper( $ r['order'] );287 $order = strtoupper( $parsed_args['order'] ); 286 288 if ( '' !== $order && ! in_array( $order, array( 'ASC', 'DESC' ) ) ) { 287 289 $order = 'ASC'; … … 289 291 290 292 $visible = ''; 291 if ( $ r['hide_invisible'] ) {293 if ( $parsed_args['hide_invisible'] ) { 292 294 $visible = "AND link_visible = 'Y'"; 293 295 } … … 296 298 $query .= " $exclusions $inclusions $search"; 297 299 $query .= " ORDER BY $orderby $order"; 298 if ( $ r['limit'] != -1 ) {299 $query .= ' LIMIT ' . $ r['limit'];300 if ( $parsed_args['limit'] != -1 ) { 301 $query .= ' LIMIT ' . $parsed_args['limit']; 300 302 } 301 303 … … 308 310 309 311 /** This filter is documented in wp-includes/bookmark.php */ 310 return apply_filters( 'get_bookmarks', $results, $ r);312 return apply_filters( 'get_bookmarks', $results, $parsed_args ); 311 313 } 312 314
Note: See TracChangeset
for help on using the changeset viewer.