New title code.
git-svn-id: http://svn.automattic.com/wordpress/trunk@652 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
223d1b272b
commit
8d232849e3
|
@ -7,7 +7,7 @@ require_once('wp-blog-header.php');
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
||||
<head>
|
||||
<title><?php bloginfo('name') ?><?php single_post_title(' » ') ?><?php single_cat_title(' » ') ?><?php single_month_title(' » ') ?></title>
|
||||
<title><?php bloginfo('name'); ?><?php wp_title(); ?></title>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
||||
<meta name="generator" content="WordPress <?php echo $wp_version; ?>" /> <!-- leave this for stats -->
|
||||
|
|
|
@ -1308,7 +1308,6 @@ function balanceTags($text, $is_comment = 0) {
|
|||
// $attributes = $regex[2];
|
||||
$attributes = $regex[2];
|
||||
if($attributes) {
|
||||
|
||||
$attributes = ' '.$attributes;
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue