diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2007-10-12 16:21:15 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2007-10-12 16:21:15 +0000 |
commit | 3a4570b0fc8b3d6339bef71d17d7701554e0bbf7 (patch) | |
tree | 2a06e5261263c68d8afd95a6328879dc289cb909 /wp-includes/deprecated.php | |
parent | b83c34a7010faee0223f6037025c350da12e05e6 (diff) | |
download | wordpress-mu-3a4570b0fc8b3d6339bef71d17d7701554e0bbf7.tar.gz wordpress-mu-3a4570b0fc8b3d6339bef71d17d7701554e0bbf7.tar.xz wordpress-mu-3a4570b0fc8b3d6339bef71d17d7701554e0bbf7.zip |
Merge with WP 2.3 - testing use only!
Move pluggable functions out of wpmu-functions and into pluggable.php, fixes #439
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1069 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes/deprecated.php')
-rw-r--r-- | wp-includes/deprecated.php | 327 |
1 files changed, 272 insertions, 55 deletions
diff --git a/wp-includes/deprecated.php b/wp-includes/deprecated.php index c93abe3..67ef9f9 100644 --- a/wp-includes/deprecated.php +++ b/wp-includes/deprecated.php @@ -56,7 +56,7 @@ function start_wp() { function the_category_ID($echo = true) { // Grab the first cat in the list. $categories = get_the_category(); - $cat = $categories[0]->cat_ID; + $cat = $categories[0]->term_id; if ( $echo ) echo $cat; @@ -217,12 +217,10 @@ function get_linksbyname($cat_name = "noname", $before = '', $after = '<br />', $limit = -1, $show_updated = 0) { global $wpdb; $cat_id = -1; - $results = $wpdb->get_results("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$cat_name'"); - if ($results) { - foreach ($results as $result) { - $cat_id = $result->cat_ID; - } - } + $cat = get_term_by('name', $cat_name, 'link_category'); + if ( $cat ) + $cat_id = $cat->term_id; + get_links($cat_id, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated); } @@ -235,10 +233,10 @@ function get_linksbyname($cat_name = "noname", $before = '', $after = '<br />', function wp_get_linksbyname($category, $args = '') { global $wpdb; - $cat_id = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories WHERE cat_name='$category' LIMIT 1"); - - if (! $cat_id) - return; + $cat = get_term_by('name', $cat_name, 'link_category'); + if ( !$cat ) + return false; + $cat_id = $cat->term_id; $args = add_query_arg('category', $cat_id, $args); wp_get_links($args); @@ -263,17 +261,13 @@ function wp_get_linksbyname($category, $args = '') { ** echo '<li>'.$link->link_name.'</li>'; ** } **/ -// Deprecate in favor of get_linkz(). function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit = -1) { global $wpdb; $cat_id = -1; - //$results = $wpdb->get_results("SELECT cat_id FROM $wpdb->linkcategories WHERE cat_name='$cat_name'"); - // TODO: Fix me. - if ($results) { - foreach ($results as $result) { - $cat_id = $result->cat_id; - } - } + $cat = get_term_by('name', $cat_name, 'link_category'); + if ( $cat ) + $cat_id = $cat->term_id; + return get_linkobjects($cat_id, $orderby, $limit); } @@ -313,41 +307,17 @@ function get_linkobjectsbyname($cat_name = "noname" , $orderby = 'name', $limit ** link_notes **/ // Deprecate in favor of get_linkz(). -function get_linkobjects($category = -1, $orderby = 'name', $limit = -1) { +function get_linkobjects($category = 0, $orderby = 'name', $limit = 0) { global $wpdb; - $sql = "SELECT * FROM $wpdb->links WHERE link_visible = 'Y'"; - if ($category != -1) { - $sql .= " AND link_category = $category "; - } - if ($orderby == '') - $orderby = 'id'; - if (substr($orderby,0,1) == '_') { - $direction = ' DESC'; - $orderby = substr($orderby,1); - } - if (strcasecmp('rand',$orderby) == 0) { - $orderby = 'rand()'; - } else { - $orderby = " link_" . $orderby; - } - $sql .= ' ORDER BY ' . $orderby; - $sql .= $direction; - /* The next 2 lines implement LIMIT TO processing */ - if ($limit != -1) - $sql .= " LIMIT $limit"; - - $results = $wpdb->get_results($sql); - if ($results) { - foreach ($results as $result) { - $result->link_url = $result->link_url; - $result->link_name = $result->link_name; - $result->link_description = $result->link_description; - $result->link_notes = $result->link_notes; - $newresults[] = $result; - } + $links = get_bookmarks("category=$category&orderby=$orderby&limit=$limit"); + + $links_array = array(); + foreach ($links as $link) { + $links_array[] = $link; } - return $newresults; + + return $links_array; } /** function get_linksbyname_withrating() @@ -427,10 +397,7 @@ function list_cats($optionall = 1, $all = 'All', $sort_column = 'ID', $sort_orde } function wp_list_cats($args = '') { - if ( is_array($args) ) - $r = &$args; - else - parse_str($args, $r); + $r = wp_parse_args( $args ); // Map to new names. if ( isset($r['optionall']) && isset($r['all'])) @@ -512,4 +479,254 @@ function get_settings($option) { return get_option($option); } +// Use the_permalink(). +function permalink_link() { + the_permalink(); +} + +// Use the_permalink_rss() +function permalink_single_rss($file = '') { + the_permalink_rss(); +} + +/** function wp_get_links() + ** Gets the links associated with category n. + ** Parameters: + ** category (no default) - The category to use. + ** or: + ** a query string + **/ +function wp_get_links($args = '') { + global $wpdb; + + if ( strpos( $args, '=' ) === false ) { + $cat_id = $args; + $args = add_query_arg( 'category', $cat_id, $args ); + } + + $defaults = array( + 'category' => -1, 'before' => '', + 'after' => '<br />', 'between' => ' ', + 'show_images' => true, 'orderby' => 'name', + 'show_description' => true, 'show_rating' => false, + 'limit' => -1, 'show_updated' => true, + 'echo' => true + ); + + $r = wp_parse_args( $args, $defaults ); + extract( $r, EXTR_SKIP ); + + return get_links($category, $before, $after, $between, $show_images, $orderby, $show_description, $show_rating, $limit, $show_updated, $echo); +} // end wp_get_links + +/** function get_links() + ** Gets the links associated with category n. + ** Parameters: + ** category (default -1) - The category to use. If no category supplied + ** uses all + ** before (default '') - the html to output before the link + ** after (default '<br />') - the html to output after the link + ** between (default ' ') - the html to output between the link/image + ** and its description. Not used if no image or show_images == true + ** show_images (default true) - whether to show images (if defined). + ** orderby (default 'id') - the order to output the links. E.g. 'id', 'name', + ** 'url', 'description', or 'rating'. Or maybe owner. If you start the + ** name with an underscore the order will be reversed. + ** You can also specify 'rand' as the order which will return links in a + ** random order. + ** show_description (default true) - whether to show the description if + ** show_images=false/not defined . + ** show_rating (default false) - show rating stars/chars + ** limit (default -1) - Limit to X entries. If not specified, all entries + ** are shown. + ** show_updated (default 0) - whether to show last updated timestamp + ** echo (default true) - whether to echo the results, or return them instead + */ +function get_links($category = -1, + $before = '', + $after = '<br />', + $between = ' ', + $show_images = true, + $orderby = 'name', + $show_description = true, + $show_rating = false, + $limit = -1, + $show_updated = 1, + $echo = true) { + + global $wpdb; + + $order = 'ASC'; + if ( substr($orderby, 0, 1) == '_' ) { + $order = 'DESC'; + $orderby = substr($orderby, 1); + } + + if ( $category == -1 ) //get_bookmarks uses '' to signify all categories + $category = ''; + + $results = get_bookmarks("category=$category&orderby=$orderby&order=$order&show_updated=$show_updated&limit=$limit"); + + if ( !$results ) + return; + + $output = ''; + + foreach ( (array) $results as $row ) { + if ( !isset($row->recently_updated) ) + $row->recently_updated = false; + $output .= $before; + if ( $show_updated && $row->recently_updated ) + $output .= get_option('links_recently_updated_prepend'); + $the_link = '#'; + if ( !empty($row->link_url) ) + $the_link = clean_url($row->link_url); + $rel = $row->link_rel; + if ( '' != $rel ) + $rel = ' rel="' . $rel . '"'; + + $desc = attribute_escape(sanitize_bookmark_field('link_description', $row->link_description, $row->link_id, 'display')); + $name = attribute_escape(sanitize_bookmark_field('link_name', $row->link_name, $row->link_id, 'display')); + $title = $desc; + + if ( $show_updated ) + if (substr($row->link_updated_f, 0, 2) != '00') + $title .= ' ('.__('Last updated') . ' ' . date(get_option('links_updated_date_format'), $row->link_updated_f + (get_option('gmt_offset') * 3600)) . ')'; + + if ( '' != $title ) + $title = ' title="' . $title . '"'; + + $alt = ' alt="' . $name . '"'; + + $target = $row->link_target; + if ( '' != $target ) + $target = ' target="' . $target . '"'; + + $output .= '<a href="' . $the_link . '"' . $rel . $title . $target. '>'; + + if ( $row->link_image != null && $show_images ) { + if ( strpos($row->link_image, 'http') !== false ) + $output .= "<img src=\"$row->link_image\" $alt $title />"; + else // If it's a relative path + $output .= "<img src=\"" . get_option('siteurl') . "$row->link_image\" $alt $title />"; + } else { + $output .= $name; + } + + $output .= '</a>'; + + if ( $show_updated && $row->recently_updated ) + $output .= get_option('links_recently_updated_append'); + + if ( $show_description && '' != $desc ) + $output .= $between . $desc; + + if ($show_rating) { + $output .= $between . get_linkrating($row); + } + + $output .= "$after\n"; + } // end while + + if ( !$echo ) + return $output; + echo $output; +} + +/* + * function get_links_list() + * + * added by Dougal + * + * Output a list of all links, listed by category, using the + * settings in $wpdb->linkcategories and output it as a nested + * HTML unordered list. + * + * Parameters: + * order (default 'name') - Sort link categories by 'name' or 'id' + * hide_if_empty (default true) - Supress listing empty link categories + */ +function get_links_list($order = 'name', $hide_if_empty = 'obsolete') { + $order = strtolower($order); + + // Handle link category sorting + $direction = 'ASC'; + if ( '_' == substr($order,0,1) ) { + $direction = 'DESC'; + $order = substr($order,1); + } + + if ( !isset($direction) ) + $direction = ''; + + $cats = get_categories("type=link&orderby=$order&order=$direction&hierarchical=0"); + + // Display each category + if ( $cats ) { + foreach ( (array) $cats as $cat ) { + // Handle each category. + + // Display the category name + echo ' <li id="linkcat-' . $cat->term_id . '" class="linkcat"><h2>' . apply_filters('link_category', $cat->name ) . "</h2>\n\t<ul>\n"; + // Call get_links() with all the appropriate params + get_links($cat->term_id, '<li>', "</li>", "\n", true, 'name', false); + + // Close the last category + echo "\n\t</ul>\n</li>\n"; + } + } +} + + +/** function links_popup_script() + ** This function contributed by Fullo -- http://sprite.csr.unibo.it/fullo/ + ** Show the link to the links popup and the number of links + ** Parameters: + ** text (default Links) - the text of the link + ** width (default 400) - the width of the popup window + ** height (default 400) - the height of the popup window + ** file (default linkspopup.php) - the page to open in the popup window + ** count (default true) - the number of links in the db + */ +function links_popup_script($text = 'Links', $width=400, $height=400, $file='links.all.php', $count = true) { + if ( $count ) + $counts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->links"); + + $javascript = "<a href=\"#\" onclick=\"javascript:window.open('$file?popup=1', '_blank', 'width=$width,height=$height,scrollbars=yes,status=no'); return false\">"; + $javascript .= $text; + + if ( $count ) + $javascript .= " ($counts)"; + + $javascript .= "</a>\n\n"; + echo $javascript; +} + + +function get_linkrating($link) { + return sanitize_bookmark_field('link_rating', $link->link_rating, $link->link_id, 'display'); +} + +/** function get_linkcatname() + ** Gets the name of category n. + ** Parameters: id (default 0) - The category to get. If no category supplied + ** uses 0 + */ +function get_linkcatname($id = 0) { + $id = (int) $id; + + if ( empty($id) ) + return ''; + + $cats = wp_get_link_cats($id); + + if ( empty($cats) || ! is_array($cats) ) + return ''; + + $cat_id = (int) $cats[0]; // Take the first cat. + + $cat = get_category($cat_id); + return $cat->name; +} + ?> |