Ticket #2562: template_functions_bookmark_incl_excl.diff
| File template_functions_bookmark_incl_excl.diff, 2.0 KB (added by , 20 years ago) |
|---|
-
wp-includes/template-functions-bookmarks.php
283 283 parse_str($args, $r); 284 284 285 285 $defaults = array('orderby' => 'name', 'order' => 'ASC', 'limit' => -1, 'category' => -1, 286 'category_name' => '', 'hide_invisible' => 1, 'show_updated' => 0 );286 'category_name' => '', 'hide_invisible' => 1, 'show_updated' => 0, 'include' => '', 'exclude' => ''); 287 287 $r = array_merge($defaults, $r); 288 288 extract($r); 289 289 290 if ( !empty($include) ) { 291 $exclude = ''; 292 $category = -1; 293 $category_name = ''; 294 } 295 290 296 $exclusions = ''; 291 297 if ( !empty($exclude) ) { 292 298 $exlinks = preg_split('/[\s,]+/',$r['exclude']); 293 299 if ( count($exlinks) ) { 294 300 foreach ( $exlinks as $exlink ) { 301 if (empty($exclusions)) 302 $exclusions = ' AND ( link_id <> ' . intval($exlink) . ' '; 303 else 295 304 $exclusions .= ' AND link_id <> ' . intval($exlink) . ' '; 296 305 } 297 306 } 298 307 } 308 if (!empty($exclusions)) 309 $exclusions .= ')'; 299 310 311 $inclusions = ''; 312 if ( !empty($include) ) { 313 $inclinks = preg_split('/[\s,]+/',$r['include']); 314 if ( count($inclinks) ) { 315 foreach ( $inclinks as $inclink ) { 316 if (empty($inclusions)) 317 $inclusions = ' AND ( link_id = ' . intval($inclink) . ' '; 318 else 319 $inclusions .= ' OR link_id = ' . intval($inclink) . ' '; 320 } 321 } 322 } 323 if (!empty($inclusions)) 324 $inclusions .= ')'; 325 300 326 if ( ! empty($category_name) ) { 301 327 if ( $cat_id = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$category_name' LIMIT 1") ) 302 328 $category = $cat_id; … … 341 367 $visible = "AND link_visible = 'Y'"; 342 368 343 369 $query = "SELECT * $length $recently_updated_test $get_updated FROM $wpdb->links $join WHERE 1=1 $visible $category_query"; 370 $query .= " $exclusions $inclusions"; 344 371 $query .= " ORDER BY $orderby $order"; 345 372 if ($limit != -1) 346 373 $query .= " LIMIT $limit";