From 8d232849e3080f59a1f58cd0d55394b482ce6225 Mon Sep 17 00:00:00 2001 From: saxmatt Date: Thu, 25 Dec 2003 00:01:31 +0000 Subject: [PATCH] New title code. git-svn-id: http://svn.automattic.com/wordpress/trunk@652 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- index.php | 2 +- wp-includes/functions.php | 1 - wp-includes/template-functions.php | 59 ++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index 9e705a9cb6..fba96f3b17 100644 --- a/index.php +++ b/index.php @@ -7,7 +7,7 @@ require_once('wp-blog-header.php'); - <?php bloginfo('name') ?><?php single_post_title(' » ') ?><?php single_cat_title(' » ') ?><?php single_month_title(' » ') ?> + <?php bloginfo('name'); ?><?php wp_title(); ?> diff --git a/wp-includes/functions.php b/wp-includes/functions.php index adf65fe966..f45d37042b 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1308,7 +1308,6 @@ function balanceTags($text, $is_comment = 0) { // $attributes = $regex[2]; $attributes = $regex[2]; if($attributes) { - $attributes = ' '.$attributes; } diff --git a/wp-includes/template-functions.php b/wp-includes/template-functions.php index 2971a6accc..63d7049233 100644 --- a/wp-includes/template-functions.php +++ b/wp-includes/template-functions.php @@ -72,6 +72,65 @@ function get_bloginfo($show='') { return $output; } +function wp_title($sep = '»', $display = true) { + global $wpdb, $tableposts, $tablecategories; + global $year, $monthnum, $day, $cat, $p, $name; + + // If there's a category + if(!empty($cat) || !empty($category_name)) { + $title = stripslashes(get_the_category_by_ID($cat)); + $title = stripslashes($wpdb->get_var("SELECT cat_name FROM $tablecategories WHERE category_nicename = '$category_name'")); + } + + // If there's a month + if(!empty($m)) { + $my_year = substr($m, 0, 4); + $my_month = $month[substr($m, 4, 2)]; + $title = "$my_year $sep $my_month"; + + } + if (!empty($year)) { + $title = $year; + if (!empty($monthnum)) { + $title .= "$sep $monthnum"; + } + if (!empty($day)) { + $title .= " $sep $day"; + } + } + + // If there's a post + if (intval($p) || '' != $name) { + if (!$p) { + if ($year != '') { + $year = '' . intval($year); + $where .= ' AND YEAR(post_date)=' . $year; + } + + if ($monthnum != '') { + $monthnum = '' . intval($monthnum); + $where .= ' AND MONTH(post_date)=' . $monthnum; + } + + if ($day != '') { + $hay = '' . intval($day); + $where .= ' AND DAYOFMONTH(post_date)=' . $day; + } + $p = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_name = '$name' $where"); + } + $post_data = get_postdata($p); + $title = strip_tags(stripslashes($post_data['Title'])); + $title = apply_filters('single_post_title', $title); + } + + // Send it out + if ($display) { + echo " $sep $title"; + } else { + return " $sep $title"; + } +} + function single_post_title($prefix = '', $display = true) { global $p, $name, $wpdb, $tableposts; if (intval($p) || '' != $name) {