Make WordPress Core

Changeset 3845


Ignore:
Timestamp:
06/05/2006 02:12:59 AM (18 years ago)
Author:
ryan
Message:

Reorg bookmark functions. #2525

Location:
trunk
Files:
1 added
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-db.php

    r3800 r3845  
    285285}
    286286
    287 function get_link($link_id, $output = OBJECT) {
    288     global $wpdb;
    289 
    290     $link = $wpdb->get_row("SELECT * FROM $wpdb->links WHERE link_id = '$link_id'");
    291     $link->link_category = wp_get_link_cats($link_id);
    292 
    293     if ( $output == OBJECT ) {
    294         return $link;
    295     } elseif ( $output == ARRAY_A ) {
    296         return get_object_vars($link);
    297     } elseif ( $output == ARRAY_N ) {
    298         return array_values(get_object_vars($link));
    299     } else {
    300         return $link;
    301     }
    302 }
    303 
    304287function wp_insert_link($linkdata) {
    305288    global $wpdb, $current_user;
  • trunk/wp-includes/bookmark-template.php

    r3809 r3845  
    281281}
    282282
    283 function get_bookmarks($args = '') {
    284     global $wpdb;
    285 
    286     if ( is_array($args) )
    287         $r = &$args;
    288     else
    289         parse_str($args, $r);
    290 
    291     $defaults = array('orderby' => 'name', 'order' => 'ASC', 'limit' => -1, 'category' => '',
    292         'category_name' => '', 'hide_invisible' => 1, 'show_updated' => 0, 'include' => '', 'exclude' => '');
    293     $r = array_merge($defaults, $r);
    294     extract($r);
    295 
    296     $inclusions = '';
    297     if ( !empty($include) ) {
    298     $exclude = '';  //ignore exclude, category, and category_name params if using include
    299     $category = '';
    300     $category_name = '';
    301         $inclinks = preg_split('/[\s,]+/',$include);
    302         if ( count($inclinks) ) {
    303             foreach ( $inclinks as $inclink ) {
    304                 if (empty($inclusions))
    305                     $inclusions = ' AND ( link_id = ' . intval($inclink) . ' ';
    306                 else
    307                     $inclusions .= ' OR link_id = ' . intval($inclink) . ' ';
    308             }
    309         }
    310     }
    311     if (!empty($inclusions))
    312         $inclusions .= ')';
    313 
    314     $exclusions = '';
    315     if ( !empty($exclude) ) {
    316         $exlinks = preg_split('/[\s,]+/',$exclude);
    317         if ( count($exlinks) ) {
    318             foreach ( $exlinks as $exlink ) {
    319                 if (empty($exclusions))
    320                     $exclusions = ' AND ( link_id <> ' . intval($exlink) . ' ';
    321                 else
    322                     $exclusions .= ' AND link_id <> ' . intval($exlink) . ' ';
    323             }
    324         }
    325     }
    326     if (!empty($exclusions))
    327         $exclusions .= ')';
    328        
    329     if ( ! empty($category_name) ) {
    330         if ( $cat_id = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$category_name' LIMIT 1") )
    331             $category = $cat_id;
    332     }
    333 
    334     $category_query = '';
    335     $join = '';
    336     if ( !empty($category) ) {
    337         $incategories = preg_split('/[\s,]+/',$category);
    338         if ( count($incategories) ) {
    339             foreach ( $incategories as $incat ) {
    340                 if (empty($category_query))
    341                     $category_query = ' AND ( category_id = ' . intval($incat) . ' ';
    342                 else
    343                     $category_query .= ' OR category_id = ' . intval($incat) . ' ';
    344             }
    345         }
    346     }
    347     if (!empty($category_query)) {
    348         $category_query .= ')';
    349         $join = " LEFT JOIN $wpdb->link2cat ON ($wpdb->links.link_id = $wpdb->link2cat.link_id) ";
    350     }
    351 
    352     if (get_settings('links_recently_updated_time')) {
    353         $recently_updated_test = ", IF (DATE_ADD(link_updated, INTERVAL " . get_settings('links_recently_updated_time') . " MINUTE) >= NOW(), 1,0) as recently_updated ";
    354     } else {
    355         $recently_updated_test = '';
    356     }
    357 
    358     if ($show_updated) {
    359         $get_updated = ", UNIX_TIMESTAMP(link_updated) AS link_updated_f ";
    360     }
    361 
    362     $orderby = strtolower($orderby);
    363     $length = '';
    364     switch ($orderby) {
    365         case 'length':
    366             $length = ", CHAR_LENGTH(link_name) AS length";
    367             break;
    368         case 'rand':
    369             $orderby = 'rand()';
    370             break;
    371         default:
    372             $orderby = "link_" . $orderby;
    373     }
    374 
    375     if ( 'link_id' == $orderby )
    376         $orderby = "$wpdb->links.link_id";
    377 
    378     $visible = '';
    379     if ( $hide_invisible )
    380         $visible = "AND link_visible = 'Y'";
    381 
    382     $query = "SELECT * $length $recently_updated_test $get_updated FROM $wpdb->links $join WHERE 1=1 $visible $category_query";
    383     $query .= " $exclusions $inclusions";
    384     $query .= " ORDER BY $orderby $order";
    385     if ($limit != -1)
    386         $query .= " LIMIT $limit";
    387 
    388     $results = $wpdb->get_results($query);
    389     return apply_filters('get_bookmarks', $results, $r);
    390 }
    391283?>
  • trunk/wp-settings.php

    r3844 r3845  
    140140require (ABSPATH . WPINC . '/rewrite.php');
    141141require (ABSPATH . WPINC . '/feed-functions.php');
    142 require (ABSPATH . WPINC . '/template-functions-bookmarks.php');
     142require (ABSPATH . WPINC . '/bookmark.php');
     143require (ABSPATH . WPINC . '/bookmark-template.php');
    143144require (ABSPATH . WPINC . '/kses.php');
    144145require (ABSPATH . WPINC . '/cron.php');
Note: See TracChangeset for help on using the changeset viewer.