Ticket #2433: wp-rewrite-api.diff
File wp-rewrite-api.diff, 4.1 KB (added by , 19 years ago) |
---|
-
wp-includes/rewrite-functions.php
1 <?php 2 3 //Add a straight rewrite rule 4 function add_rewrite_rule($regex, $redirect) { 5 global $wp_rewrite; 6 $wp_rewrite->add_extra_rule($regex, $redirect); 7 } 8 9 //Add a new tag (like %postname%) 10 //warning: you must call this on init or earlier, otherwise the query var addition stuff won't work 11 function add_rewrite_tag($tagname, $regex) { 12 //validation 13 if ($tagname < 3 || $tagname{0} != '%' || $tagname{strlen($tagname)-1} != '%') { 14 return; 15 } 16 17 $qv = trim($tagname, '%'); 18 19 global $wp_rewrite, $wp; 20 $wp->add_extra_qv($qv); 21 $wp_rewrite->add_rewrite_tag($tagname, $regex, trim($tagname, '%') . '='); 22 } 23 24 //Add a new feed type like /atom1/ 25 function add_feed($feedname, $filename) { 26 global $wp_rewrite; 27 if (in_array($feedname, $wp_rewrite->feeds)) { //override 28 $wp_rewrite->feed_files[$filename] = $feedname; 29 //the feed name is already in $wp_rewrite->feeds 30 } else { //add it 31 $wp_rewrite->feeds[] = $feedname; 32 } 33 } 34 35 ?> 36 No newline at end of file -
wp-includes/classes.php
864 864 var $index = 'index.php'; 865 865 var $matches = ''; 866 866 var $rules; 867 var $extra_rules; //those not generated by the class, see add_rewrite_rule() 867 868 var $use_verbose_rules = false; 868 869 var $rewritecode = 869 870 array( … … 913 914 's=' 914 915 ); 915 916 916 var $feeds = array ('feed', 'rdf', 'rss', 'rss2', 'atom'); 917 917 var $feeds = array ( 'feed', 'rdf', 'rss', 'rss2', 'atom' ); 918 919 //the filenames aren't actually used in WP_Rewrite but seems a convenient place as any to store them 920 var $feed_files = array ( 921 'rdf' => 'wp-rdf.php' 922 'rss' => 'wp-rss.php' 923 'rss2' => 'wp-rss2.php' 924 'atom' =>'wp-atom.php' 925 ); 926 918 927 function using_permalinks() { 919 928 if (empty($this->permalink_structure)) 920 929 return false; … … 1400 1409 1401 1410 return $rules; 1402 1411 } 1412 1413 //Add a straight rewrite rule 1414 function add_extra_rule($regex, $redirect) { 1415 if (!is_array($this->extra_rules)) { 1416 $this->extra_rules = array (); 1417 } 1418 $this->extra_rules[$regex] = $redirect; 1419 } 1403 1420 1404 1421 function flush_rules() { 1405 1422 generate_page_uri_index(); … … 1456 1473 var $matched_rule; 1457 1474 var $matched_query; 1458 1475 var $did_permalink = false; 1476 1477 function add_extra_qv($qv) { 1478 $this->public_query_vars[] = $qv; 1479 } 1459 1480 1460 1481 function parse_request($extra_query_vars = '') { 1461 1482 global $wp_rewrite; -
wp-settings.php
138 138 require (ABSPATH . WPINC . '/template-functions-post.php'); 139 139 require (ABSPATH . WPINC . '/template-functions-category.php'); 140 140 require (ABSPATH . WPINC . '/comment-functions.php'); 141 require (ABSPATH . WPINC . '/rewrite-functions.php'); 141 142 require (ABSPATH . WPINC . '/feed-functions.php'); 142 143 require (ABSPATH . WPINC . '/links.php'); 143 144 require (ABSPATH . WPINC . '/kses.php'); -
wp-feed.php
12 12 $feed = 'rss2'; 13 13 } 14 14 15 $file = $wp_rewrite->feed_files[$feed]; 16 15 17 if ( is_single() || ($withcomments == 1) ) { 16 18 require(ABSPATH . 'wp-commentsrss2.php'); 17 19 } else { 18 switch ($feed) { 19 case 'atom': 20 require(ABSPATH . 'wp-atom.php'); 21 break; 22 case 'rdf': 23 require(ABSPATH . 'wp-rdf.php'); 24 break; 25 case 'rss': 26 require(ABSPATH . 'wp-rss.php'); 27 break; 28 case 'rss2': 29 require(ABSPATH . 'wp-rss2.php'); 30 break; 31 case 'comments-rss2': 32 require(ABSPATH . 'wp-commentsrss2.php'); 33 break; 34 } 20 if (in_array($feed, $wp_rewrite->feeds) && !empty($file) && file_exists(ABSPATH . $file)) { 21 require ABSPATH . $file; 22 } 35 23 } 36 24 37 25 ?>