Make WordPress Core

Changeset 2146


Ignore:
Timestamp:
01/25/2005 12:23:57 AM (20 years ago)
Author:
rboren
Message:

Generate feed and trackback rules for pages. Bug 742.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/classes.php

    r2115 r2146  
    283283            $where .= " AND post_name = '" . $q['name'] . "'";
    284284        } else if ('' != $q['pagename']) {
    285             $q['pagename'] = sanitize_title($q['pagename']);
     285            $q['pagename'] = sanitize_title(basename($q['pagename']));
    286286            $q['name'] = $q['pagename'];
    287287            $where .= " AND post_name = '" . $q['pagename'] . "'";
     
    822822
    823823        $rewrite_rules = array();
     824        $page_structure = '/%pagename%';
    824825        if( is_array( $uris ) )
    825826            {
    826827                foreach ($uris as $uri => $pagename) {
    827                     $rewrite_rules += array($uri . '/?$' => "index.php?pagename=" . urldecode($pagename));
     828                    $this->add_rewrite_tag('%pagename%', "($uri)", 'pagename=');
     829                    $rewrite_rules += $this->generate_rewrite_rules($page_structure);
    828830                }
    829831            }
     
    930932
    931933    function add_rewrite_tag($tag, $pattern, $query) {
    932         $this->rewritecode[] = $tag;
    933         $this->rewritereplace[] = $pattern;
    934         $this->queryreplace[] = $query;
     934        // If the tag already exists, replace the existing pattern and query for
     935        // that tag, otherwise add the new tag, pattern, and query to the end of
     936        // the arrays.
     937        $position = array_search($tag, $this->rewritecode);     
     938        if (FALSE !== $position && NULL !== $position) {
     939            $this->rewritereplace[$position] = $pattern;
     940            $this->queryreplace[$position] = $query;           
     941        } else {
     942            $this->rewritecode[] = $tag;
     943            $this->rewritereplace[] = $pattern;
     944            $this->queryreplace[] = $query;
     945        }
    935946    }
    936947
     
    10051016                $post = 0;
    10061017                if (strstr($struct, '%postname%') || strstr($struct, '%post_id%')
     1018                        || strstr($struct, '%pagename%')
    10071019                        || (strstr($struct, '%year%') &&  strstr($struct, '%monthnum%') && strstr($struct, '%day%') && strstr($struct, '%hour%') && strstr($struct, '%minute') && strstr($struct, '%second%'))) {
    10081020                    $post = 1;
  • trunk/wp-trackback.php

    r2080 r2146  
    4949}
    5050
    51 if ( is_single() )
     51if ( is_single() || is_page() )
    5252    $tb_id = $posts[0]->ID;
    5353
Note: See TracChangeset for help on using the changeset viewer.