Make WordPress Core

Changeset 652


Ignore:
Timestamp:
12/25/2003 12:01:31 AM (21 years ago)
Author:
saxmatt
Message:

New title code.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/index.php

    r629 r652  
    88
    99<head>
    10     <title><?php bloginfo('name') ?><?php single_post_title(' &raquo; ') ?><?php single_cat_title(' &raquo; ') ?><?php single_month_title(' &raquo; ') ?></title>
     10    <title><?php bloginfo('name'); ?><?php wp_title(); ?></title>
    1111   
    1212    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  • trunk/wp-includes/functions.php

    r650 r652  
    13091309            $attributes = $regex[2];
    13101310            if($attributes) {
    1311 
    13121311                $attributes = ' '.$attributes;
    13131312            }
  • trunk/wp-includes/template-functions.php

    r650 r652  
    7171    }
    7272    return $output;
     73}
     74
     75function wp_title($sep = '&raquo;', $display = true) {
     76    global $wpdb, $tableposts, $tablecategories;
     77    global $year, $monthnum, $day, $cat, $p, $name;
     78
     79    // If there's a category
     80    if(!empty($cat) || !empty($category_name)) {
     81        $title = stripslashes(get_the_category_by_ID($cat));
     82        $title = stripslashes($wpdb->get_var("SELECT cat_name FROM $tablecategories WHERE category_nicename = '$category_name'"));
     83    }
     84
     85    // If there's a month
     86    if(!empty($m)) {
     87        $my_year = substr($m, 0, 4);
     88        $my_month = $month[substr($m, 4, 2)];
     89        $title = "$my_year $sep $my_month";
     90
     91    }
     92    if (!empty($year)) {
     93        $title = $year;
     94        if (!empty($monthnum)) {
     95            $title .= "$sep $monthnum";
     96        }
     97        if (!empty($day)) {
     98            $title .= " $sep $day";
     99        }
     100    }
     101
     102    // If there's a post
     103    if (intval($p) || '' != $name) {
     104        if (!$p) {
     105        if ($year != '') {
     106            $year = '' . intval($year);
     107            $where .= ' AND YEAR(post_date)=' . $year;
     108        }
     109       
     110        if ($monthnum != '') {
     111            $monthnum = '' . intval($monthnum);
     112            $where .= ' AND MONTH(post_date)=' . $monthnum;
     113        }
     114       
     115        if ($day != '') {
     116            $hay = '' . intval($day);
     117            $where .= ' AND DAYOFMONTH(post_date)=' . $day;
     118        }
     119            $p = $wpdb->get_var("SELECT ID FROM $tableposts WHERE post_name = '$name' $where");
     120        }
     121        $post_data = get_postdata($p);
     122        $title = strip_tags(stripslashes($post_data['Title']));
     123        $title = apply_filters('single_post_title', $title);
     124    }
     125
     126    // Send it out
     127    if ($display) {
     128        echo " $sep $title";
     129    } else {
     130        return " $sep $title";
     131    }
    73132}
    74133
Note: See TracChangeset for help on using the changeset viewer.