Make WordPress Core

Changeset 836


Ignore:
Timestamp:
02/05/2004 08:55:50 PM (21 years ago)
Author:
rboren
Message:

Clean feed and trackback URLs.

Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/options-permalink.php

    r782 r836  
    130130$match = str_replace($rewritecode, $rewritereplace, $match);
    131131$match = preg_replace('|[?]|', '', $match, 1);
     132
     133$feedmatch = str_replace('?/?', '/', $match);
     134$trackbackmatch = $feedmatch;
     135
    132136preg_match_all('/%.+?%/', $permalink_structure, $tokens);
    133137
    134138$query = 'index.php?';
     139$feedquery = 'wp-feed.php?';
     140$trackbackquery = 'wp-trackback.php?';
    135141for ($i = 0; $i < count($tokens[0]); ++$i) {
    136     if (0 < $i) $query .= '&';
    137     $query .= str_replace($rewritecode, $queryreplace, $tokens[0][$i]) . '$'. ($i + 1);
     142    if (0 < $i) {
     143        $query .= '&';
     144        $feedquery .= '&';
     145        $trackbackquery .= '&';
     146    }
     147
     148    $query_token = str_replace($rewritecode, $queryreplace, $tokens[0][$i]) . '$'. ($i + 1);
     149    $query .= $query_token;
     150    $feedquery .= $query_token;
     151    $trackbackquery .= $query_token;
    138152}
    139153++$i;
     154
    140155// Add post paged stuff
    141156$match .= '([0-9]+)?/?';
    142157$query .= "&page=$$i";
     158
     159// Add post feed stuff
     160$feedregex = '(feed|rdf|rss|rss2|atom)/?';
     161$feedmatch .= $feedregex;
     162$feedquery .= "&feed=$$i";
     163
     164// Add post trackback stuff
     165$trackbackregex = 'trackback/?';
     166$trackbackmatch .= $trackbackregex;
     167
     168// Site feed
     169$sitefeedmatch = 'feed/?([0-9a-z-]+)?/?$';
     170$sitefeedquery = $site_root . 'wp-feed.php?feed=$1';
     171
     172// Site comment feed
     173$sitecommentfeedmatch = 'comments/feed/?([0-9a-z-]+)?/?$';
     174$sitecommentfeedquery = $site_root . 'wp-feed.php?feed=$1&withcomments=1';
    143175
    144176// Code for nice categories, currently not very flexible
     
    152184RewriteBase <?php echo $site_root; ?>
    153185RewriteRule ^<?php echo $match; echo '$ ' . $site_root . $query ?> [QSA]
    154 RewriteRule ^<?php echo $catmatch; ?>?(.*) <?php echo $site_root; ?>index.php?category_name=$1 [QSA]</textarea>
     186RewriteRule ^<?php echo $feedmatch; echo '$ ' . $site_root . $feedquery ?> [QSA]
     187RewriteRule ^<?php echo $trackbackmatch; echo '$ ' . $site_root . $trackbackquery ?> [QSA]
     188RewriteRule ^<?php echo $catmatch; ?>(.*)/<?php echo $feedregex ?>$ <?php echo $site_root; ?>wp-feed.php?category_name=$1&feed=$2 [QSA]
     189RewriteRule ^<?php echo $catmatch; ?>?(.*) <?php echo $site_root; ?>index.php?category_name=$1 [QSA]
     190RewriteRule ^<?php echo $sitefeedmatch; ?> <?php echo $sitefeedquery ?> [QSA]
     191RewriteRule ^<?php echo $sitecommentfeedmatch; ?> <?php echo $sitecommentfeedquery ?> [QSA]</textarea>
    155192    </form>
    156193</div>
  • trunk/wp-atom.php

    r785 r836  
    11<?php
    2 $blog = 1;
    3 $doing_rss = 1;
     2if (! $feed) {
     3    $blog = 1;
     4    $doing_rss = 1;
     5    require('wp-blog-header.php');
     6}
     7
    48header('Content-type: application/atom+xml', true);
    5 require('wp-blog-header.php');
     9
    610if (!isset($rss_language)) { $rss_language = 'en'; }
    711if (!isset($rss_encoded_html)) { $rss_encoded_html = 0; }
  • trunk/wp-blog-header.php

    r828 r836  
    1111require($curpath.'/wp-config.php');
    1212
    13 $wpvarstoreset = array('m','p','posts','w', 'cat','withcomments','s','search','exact', 'sentence','poststart','postend','preview','debug', 'calendar','page','paged','more','tb', 'pb','author','order','orderby', 'year', 'monthnum', 'day', 'name', 'category_name');
     13$wpvarstoreset = array('m','p','posts','w', 'cat','withcomments','s','search','exact', 'sentence','poststart','postend','preview','debug', 'calendar','page','paged','more','tb', 'pb','author','order','orderby', 'year', 'monthnum', 'day', 'name', 'category_name', 'feed');
    1414
    1515    for ($i=0; $i<count($wpvarstoreset); $i += 1) {
  • trunk/wp-commentsrss2.php

    r722 r836  
    66/* These first lines are the first part of a WordPress template.
    77           In every template you do, you got to copy them before the CafeLog 'loop' */
    8 $blog=1; // enter your blog's ID
     8if (! $feed) {
     9    $blog=1; // enter your blog's ID
     10    require('wp-blog-header.php');
     11}
     12
    913header('Content-type: text/xml');
    10 require('wp-blog-header.php');
    1114
    1215if (!isset($rss_language)) { $rss_language = 'en'; }
     
    2730        $i++;
    2831?>
    29     <title><?php if (isset($_REQUEST["p"])) { echo "Comments on: "; the_title_rss(); } else { bloginfo_rss("name"); echo " Comments"; } ?></title>
    30     <link><?php isset($_REQUEST["p"]) ? permalink_single_rss() : bloginfo_rss("url") ?></link>
     32    <title><?php if (isset($_REQUEST["p"]) || isset($_REQUEST["name"])) { echo "Comments on: "; the_title_rss(); } else { bloginfo_rss("name"); echo " Comments"; } ?></title>
     33    <link><?php (isset($_REQUEST["p"]) || isset($_REQUEST["name"])) ? permalink_single_rss() : bloginfo_rss("url") ?></link>
    3134    <description><?php bloginfo_rss("description") ?></description>
    3235    <dc:language><?php echo $rss_language ?></dc:language>
     
    4144
    4245<?php
    43         if (isset($_REQUEST["p"])) {
     46        if (isset($_REQUEST["p"]) || isset($_REQUEST["name"])) {
    4447            $comments = $wpdb->get_results("SELECT comment_ID,
    4548                                                   comment_author,
  • trunk/wp-includes/functions.php

    r810 r836  
    7474    $pee = preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "\t<p>$1</p>\n", $pee); // make paragraphs, including one at the end
    7575    $pee = preg_replace('|<p>\s*?</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace
     76    $pee = preg_replace('!<p>\s*(</?(?:table|tr|td|th|div|ul|ol|li|pre|select|form|blockquote|p|h[1-6])[^>]*>)\s*</p>!', "$1", $pee); // don't pee all over a tag
    7677    $pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists
    7778    $pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee);
     
    147148}
    148149
     150function trailingslashit($string) {
     151    if ( '/' != substr($string, -1)) {
     152        $string .= '/';
     153    }
     154    return $string;
     155}
    149156
    150157function mysql2date($dateformatstring, $mysqlstring, $use_b2configmonthsdays = 1) {
  • trunk/wp-includes/template-functions-category.php

    r801 r836  
    3535    if ($echo) echo $link;
    3636    return $link;
     37}
     38
     39function get_category_rss_link($echo = false, $category_id, $category_nicename) {
     40       global $querystring_start, $querystring_equal, $siteurl;
     41       $cat_ID = $category_id;
     42       $permalink_structure = get_settings('permalink_structure');
     43
     44       if ('' == $permalink_structure) {
     45               $file = "$siteurl/wp-rss2.php";
     46        $link = $file . $querystring_start . 'cat' . $querystring_equal . $category_id;
     47       } else {
     48        $link = get_category_link(0, $category_id, $category_nicename);
     49               $link = $link . "/feed/";
     50       }
     51
     52       if ($echo) echo $link;
     53       return $link;
    3754}
    3855
  • trunk/wp-includes/template-functions-comment.php

    r805 r836  
    210210    global $id;
    211211    global $querystring_start, $querystring_equal, $querystring_separator, $siteurl;
    212     $url = $siteurl.'/'.$commentsrssfilename.$querystring_start.'p'.$querystring_equal.$id;
     212
     213    if ('' != get_settings('permalink_structure')) {
     214        $url = trailingslashit(get_permalink()) . 'rss2/';
     215    } else {
     216        $url = $siteurl.'/'.$commentsrssfilename.$querystring_start.'p'.$querystring_equal.$id;
     217    }
     218
    213219    $url = '<a href="'.$url.'">'.$link_text.'</a>';
    214220    echo $url;
     
    253259    global $siteurl, $id;
    254260    $tb_url = $siteurl.'/wp-trackback.php/'.$id;
     261
     262    if ('' != get_settings('permalink_structure')) {
     263        $tb_url = get_permalink() . 'trackback/';
     264    }
     265
    255266    if ($display) {
    256267        echo $tb_url;
  • trunk/wp-includes/template-functions-general.php

    r814 r836  
    2424function get_bloginfo($show='') {
    2525    global $siteurl, $blogfilename, $blogname, $blogdescription, $siteurl, $admin_email;
     26
     27    $do_perma = 0;
     28    $feed_url = $siteurl;
     29    $comment_feed_url = $siteurl;
     30
     31    if ('' != get_settings('permalink_structure')) {
     32        $do_perma = 1;
     33        $feed_url = $siteurl . '/feed';
     34        $comment_feed_url = $siteurl . '/comments/feed';
     35    }
     36
    2637    switch($show) {
    2738        case "url":
     
    3344        case "rdf_url":
    3445            $output = $siteurl.'/wp-rdf.php';
     46            if ($do_perma) {
     47                $output = $feed_url . '/rdf/';
     48            }
    3549            break;
    3650        case "rss_url":
    3751            $output = $siteurl.'/wp-rss.php';
     52            if ($do_perma) {
     53                $output = $feed_url . '/rss/';
     54            }
    3855            break;
    3956        case "rss2_url":
    4057            $output = $siteurl.'/wp-rss2.php';
     58            if ($do_perma) {
     59                $output = $feed_url . '/rss2/';
     60            }
    4161            break;
    4262        case "atom_url":
    4363            $output = $siteurl.'/wp-atom.php';
     64            if ($do_perma) {
     65                $output = $feed_url . '/atom/';
     66            }
    4467            break;       
    4568        case "comments_rss2_url":
    4669            $output = $siteurl.'/wp-commentsrss2.php';
     70            if ($do_perma) {
     71                $output = $comment_feed_url . '/rss2/';
     72            }
    4773            break;
    4874        case "pingback_url":
  • trunk/wp-rdf.php

    r724 r836  
    11<?php /* RDF 1.0 generator, original version by garym@teledyn.com */
    2 $blog = 1; // enter your blog's ID
    3 $doing_rss = 1;
     2if (! $feed) {
     3    $blog = 1; // enter your blog's ID
     4    $doing_rss = 1;
     5    require('wp-blog-header.php');
     6}
     7
    48header('Content-type: text/xml', true);
    5 require('wp-blog-header.php');
    69
    710/* This doesn't take into account edits
  • trunk/wp-rss.php

    r724 r836  
    11<?php /* These first lines are the first part of a CafeLog template.
    22         In every template you do, you got to copy them before the CafeLog 'loop' */
    3 $blog = 1; // enter your blog's ID
    4 $doing_rss = 1;
     3if (! $feed) {
     4    $blog = 1; // enter your blog's ID
     5    $doing_rss = 1;
     6    require('wp-blog-header.php');
     7}
     8
    59header('Content-type: text/xml', true);
    6 require('wp-blog-header.php');
    710
    811/* This doesn't take into account edits
  • trunk/wp-rss2.php

    r742 r836  
    11<?php
    2 $blog = 1;
    3 $doing_rss = 1;
     2if (! $feed) {
     3    $blog = 1;
     4    $doing_rss = 1;
     5    require('wp-blog-header.php');
     6}
     7
    48header('Content-type: text/xml', true);
    5 require('wp-blog-header.php');
    69
    710/* This doesn't take into account edits
  • trunk/wp-trackback.php

    r637 r836  
    1111$blog_name = $HTTP_POST_VARS['blog_name'];
    1212
     13require('wp-blog-header.php');
     14
     15if ( (($p != '') && ($p != 'all')) || ($name != '') ) {
     16    $tb_id = $posts[0]->ID;
     17}
    1318
    1419if (empty($title) && empty($tb_url) && empty($blog_name)) {
Note: See TracChangeset for help on using the changeset viewer.