Ticket #1762: 1762.redo.diff
File 1762.redo.diff, 16.6 KB (added by , 18 years ago) |
---|
-
wp-includes/rewrite.php
150 150 *******************************************************************************/ 151 151 152 152 class WP_Rewrite { 153 var $permalink_structure;154 153 var $use_trailing_slashes; 154 155 var $author_base; 155 156 var $category_base; 157 var $comments_base; 158 var $feed_base; 159 var $search_base; 156 160 var $tag_base; 161 162 var $author_structure; 157 163 var $category_structure; 158 var $tag_structure; 159 var $author_base = 'author'; 160 var $author_structure; 164 var $comments_feed_structure; 161 165 var $date_structure; 166 var $feed_structure; 162 167 var $page_structure; 163 var $ search_base = 'search';168 var $permalink_structure; 164 169 var $search_structure; 165 var $comments_base = 'comments'; 166 var $feed_base = 'feed'; 167 var $comments_feed_structure; 168 var $feed_structure; 170 var $tag_structure; 171 169 172 var $front; 170 173 var $root = ''; 171 174 var $index = 'index.php'; 172 175 var $matches = ''; 176 173 177 var $rules; 174 178 var $extra_rules; //those not generated by the class, see add_rewrite_rule() 175 179 var $non_wp_rules; //rules that don't redirect to WP's index.php 180 176 181 var $endpoints; 177 182 var $use_verbose_rules = false; 178 var $rewritecode = 179 array( 180 '%year%', 181 '%monthnum%', 182 '%day%', 183 '%hour%', 184 '%minute%', 185 '%second%', 186 '%postname%', 187 '%post_id%', 188 '%category%', 189 '%tag%', 190 '%author%', 191 '%pagename%', 192 '%search%' 193 ); 183 184 var $rewritecode = array( 185 '%year%', '%monthnum%', '%day%', 186 '%hour%', '%minute%', '%second%', 187 '%postname%', '%post_id%', '%category%', 188 '%tag%', '%author%', '%pagename%', 189 '%search%' 190 ); 191 192 var $rewritereplace = array( 193 '([0-9]{4})', '([0-9]{1,2})', '([0-9]{1,2})', 194 '([0-9]{1,2})', '([0-9]{1,2})', '([0-9]{1,2})', 195 '([^/]+)', '([0-9]+)', '(.+?)', 196 '(.+?)', '([^/]+)', '([^/]+)', 197 '(.+)' 198 ); 199 200 var $queryreplace = array( 201 'year=', 'monthnum=', 'day=', 202 'hour=', 'minute=', 'second=', 203 'name=', 'p=', 'category_name=', 204 'tag=', 'author_name=', 'pagename=', 205 's=' 206 ); 194 207 195 var $rewritereplace = 196 array( 197 '([0-9]{4})', 198 '([0-9]{1,2})', 199 '([0-9]{1,2})', 200 '([0-9]{1,2})', 201 '([0-9]{1,2})', 202 '([0-9]{1,2})', 203 '([^/]+)', 204 '([0-9]+)', 205 '(.+?)', 206 '(.+?)', 207 '([^/]+)', 208 '([^/]+)', 209 '(.+)' 210 ); 208 var $feeds = array( 209 'feed', 'rdf', 'rss', 210 'rss2', 'atom' 211 ); 211 212 212 var $queryreplace =213 array (214 'year=',215 'monthnum=',216 'day=',217 'hour=',218 'minute=',219 'second=',220 'name=',221 'p=',222 'category_name=',223 'tag=',224 'author_name=',225 'pagename=',226 's='227 );228 229 var $feeds = array ( 'feed', 'rdf', 'rss', 'rss2', 'atom' );230 231 213 function using_permalinks() { 232 214 if (empty($this->permalink_structure)) 233 215 return false; … … 415 397 $this->author_structure = ''; 416 398 return false; 417 399 } 400 401 if ( empty( $this->author_base ) ) { 402 $this->author_structure = $this->front . 'author/'; 403 } else { 404 $this->author_structure = $this->author_base . '/'; 405 } 406 407 $this->author_structure .= '%author%'; 418 408 419 $this->author_structure = $this->front . $this->author_base . '/%author%';420 421 409 return $this->author_structure; 422 410 } 423 411 … … 430 418 $this->search_structure = ''; 431 419 return false; 432 420 } 421 422 if ( empty( $this->search_base ) ) { 423 $this->search_structure = $this->root . 'search/'; 424 } else { 425 $this->search_structure = $this->search_base . '/'; 426 } 427 428 $this->search_structure .= '%search%'; 433 429 434 $this->search_structure = $this->root . $this->search_base . '/%search%';435 436 430 return $this->search_structure; 437 431 } 438 432 … … 460 454 $this->feed_structure = ''; 461 455 return false; 462 456 } 457 458 if ( empty( $this->feed_base ) ) { 459 $this->feed_structure = $this->root . 'feed/'; 460 } else { 461 $this->feed_structure = $this->feed_base . '/'; 462 } 463 463 464 $this->feed_structure = $this->root . $this->feed_base . '/%feed%';464 $this->feed_structure .= '%feed%'; 465 465 466 466 return $this->feed_structure; 467 467 } … … 475 475 $this->comment_feed_structure = ''; 476 476 return false; 477 477 } 478 479 if ( empty( $this->comments_base ) ) { 480 $this->comment_feed_structure = $this->root . 'comments' . ( !empty( $this->feed_base ) ? $this->feed_base : '/feed' ) . '/'; 481 } else { 482 $this->comment_feed_structure = $this->comments_base . ( !empty( $this->feed_base ) ? $this->feed_base : '/feed' ) . '/'; 483 } 484 485 $this->comment_feed_structure .= '%feed%'; 478 486 479 $this->comment_feed_structure = $this->root . $this->comments_base . '/' . $this->feed_base . '/%feed%';480 481 487 return $this->comment_feed_structure; 482 488 } 483 489 … … 750 756 $root_rewrite = apply_filters('root_rewrite_rules', $root_rewrite); 751 757 752 758 // Comments 753 $comments_rewrite = $this->generate_rewrite_rules($this-> root . $this->comments_base, EP_COMMENTS, true, true, true, false);759 $comments_rewrite = $this->generate_rewrite_rules($this->get_comment_feed_permastruct(), EP_COMMENTS, true, true, true, false); 754 760 $comments_rewrite = apply_filters('comments_rewrite_rules', $comments_rewrite); 755 761 756 762 // Search 757 $search_structure = $this->get_search_permastruct(); 758 $search_rewrite = $this->generate_rewrite_rules($search_structure, EP_SEARCH); 763 $search_rewrite = $this->generate_rewrite_rules($this->get_search_permastruct(), EP_SEARCH); 759 764 $search_rewrite = apply_filters('search_rewrite_rules', $search_rewrite); 760 765 761 766 // Categories … … 898 903 $this->permalink_structure = get_option('permalink_structure'); 899 904 $this->front = substr($this->permalink_structure, 0, strpos($this->permalink_structure, '%')); 900 905 $this->root = ''; 906 901 907 if ($this->using_index_permalinks()) { 902 908 $this->root = $this->index . '/'; 903 909 } 910 911 $this->author_base = get_option( 'author_base' ); 904 912 $this->category_base = get_option( 'category_base' ); 913 $this->comments_base = get_option( 'comments_base' ); 914 $this->feed_base = get_option( 'feed_base' ); 915 $this->search_base = get_option( 'search_base' ); 905 916 $this->tag_base = get_option( 'tag_base' ); 917 906 918 unset($this->category_structure); 907 919 unset($this->author_structure); 908 920 unset($this->date_structure); … … 910 922 unset($this->search_structure); 911 923 unset($this->feed_structure); 912 924 unset($this->comment_feed_structure); 925 913 926 $this->use_trailing_slashes = ( substr($this->permalink_structure, -1, 1) == '/' ) ? true : false; 914 927 } 915 928 … … 933 946 $this->init(); 934 947 } 935 948 } 949 950 function set_author_base( $author_base ) { 951 if ( $this->tag_base != $author_base ) { 952 update_option( 'author_base', $author_base ); 953 $this->init(); 954 } 955 } 956 957 function set_comments_base( $comments_base ) { 958 if ( $this->comments_base != $comments_base ) { 959 update_option( 'comments_base', $comments_base ); 960 $this->init(); 961 } 962 } 963 964 function set_feed_base( $feed_base ) { 965 if ( $this->feed_base != $feed_base ) { 966 update_option( 'feed_base', $feed_base ); 967 $this->init(); 968 } 969 } 970 971 function set_search_base( $search_base ) { 972 if ( $this->search_base != $search_base ) { 973 update_option( 'search_base', $search_base ); 974 $this->init(); 975 } 976 } 936 977 937 978 function WP_Rewrite() { 938 979 $this->init(); -
wp-admin/wp-admin.css
1339 1339 margin-right: 220px; 1340 1340 text-decoration:underline; 1341 1341 } 1342 1343 p.permalink-common-option { 1344 width: 33%; 1345 float: left; 1346 } 1347 1348 p.permalink-custom { 1349 clear: both; 1350 } 1351 No newline at end of file -
wp-admin/options-permalink.php
57 57 58 58 $home_path = get_home_path(); 59 59 60 if ( isset( $_POST['permalink_structure']) || isset($_POST['category_base']) ) {60 if ( isset( $_POST['submit'] ) ) { 61 61 check_admin_referer('update-permalink'); 62 63 if ( isset($_POST['permalink_structure']) ) { 64 $permalink_structure = $_POST['permalink_structure']; 65 if (! empty($permalink_structure) ) 66 $permalink_structure = preg_replace('#/+#', '/', '/' . $_POST['permalink_structure']); 67 $wp_rewrite->set_permalink_structure($permalink_structure); 62 63 function _clean_base_up( $base ) { 64 return preg_replace( '#/+#', '/', '/' . $base ); 68 65 } 69 70 if ( isset($_POST['category_base']) ) { 71 $category_base = $_POST['category_base']; 72 if (! empty($category_base) ) 73 $category_base = preg_replace('#/+#', '/', '/' . $_POST['category_base']); 74 $wp_rewrite->set_category_base($category_base); 66 67 function _do_rewrite_rules_stuff( $rule_name ) { 68 global $wp_rewrite; 69 70 if ( isset( $_POST[$rule_name] ) ) { 71 $rule = $_POST[$rule_name]; 72 73 if ( !empty( $rule ) ) { 74 $rule = preg_replace( '#/+#', '/', '/' . $rule ); 75 } 76 77 if ( method_exists( $wp_rewrite, 'set_' . $rule_name ) ) { 78 call_user_func( array( &$wp_rewrite, 'set_' . $rule_name ), $rule ); 79 } 80 } 75 81 } 76 77 if ( isset($_POST['tag_base']) ) { 78 $tag_base = $_POST['tag_base']; 79 if (! empty($tag_base) ) 80 $tag_base = preg_replace('#/+#', '/', '/' . $_POST['tag_base']); 81 $wp_rewrite->set_tag_base($tag_base); 82 83 $possible_rules = array( 84 'permalink_structure', 'author_base', 'category_base', 85 'comments_base', 'feed_base', 'search_base', 'tag_base' 86 ); 87 88 foreach ( $possible_rules as $rule ) { 89 _do_rewrite_rules_stuff( $rule ); 82 90 } 83 91 } 84 92 85 $permalink_structure = get_option('permalink_structure'); 86 $category_base = get_option('category_base'); 93 $permalink_structure = get_option( 'permalink_structure' ); 94 95 $author_base = get_option( 'author_base' ); 96 $category_base = get_option( 'category_base' ); 97 $comments_base = get_option( 'comments_base' ); 98 $feed_base = get_option( 'feed_base' ); 99 $search_base = get_option( 'search_base' ); 87 100 $tag_base = get_option( 'tag_base' ); 88 101 89 102 if ( (!file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess') ) … … 112 125 <h2><?php _e('Customize Permalink Structure') ?></h2> 113 126 <form name="form" action="options-permalink.php" method="post"> 114 127 <?php wp_nonce_field('update-permalink') ?> 115 <p class="submit"><input type="submit" name="submit" value="<?php _e('Update Permalink Structure »') ?>" /></p>116 128 <p><?php _e('By default WordPress uses web <abbr title="Universal Resource Locator">URL</abbr>s which have question marks and lots of numbers in them, however WordPress offers you the ability to create a custom URL structure for your permalinks and archives. This can improve the aesthetics, usability, and forward-compatibility of your links. A <a href="http://codex.wordpress.org/Using_Permalinks">number of tags are available</a>, and here are some examples to get you started.'); ?></p> 117 129 118 130 <?php … … 153 165 checked="checked" 154 166 <?php } ?> 155 167 /> 156 <?php _e('Custom, specify below'); ?> 157 </label> 158 <br /> 168 <?php _e('Custom:'); ?></label> <input name="permalink_structure" id="permalink_structure" type="text" class="code" style="width: 60%;" value="<?php echo attribute_escape($permalink_structure); ?>" size="50" /> 159 169 </p> 160 <p id="customstructure"><?php _e('Custom structure'); ?>: <input name="permalink_structure" id="permalink_structure" type="text" class="code" style="width: 60%;" value="<?php echo attribute_escape($permalink_structure); ?>" size="50" /></p>161 170 171 <p class="submit"><input type="submit" name="submit" value="<?php _e('Update Permalink Structure »') ?>" /></p> 172 162 173 <h3><?php _e('Optional'); ?></h3> 163 <?php if ($is_apache) : ?> 164 <p><?php _e('If you like, you may enter a custom prefix for your category <abbr title="Universal Resource Locator">URL</abbr>s here. For example, <code>/taxonomy/tags</code> would make your category links like <code>http://example.org/taxonomy/tags/uncategorized/</code>. If you leave this blank the default will be used.') ?></p> 165 <?php else : ?> 166 <p><?php _e('If you like, you may enter a custom prefix for your category <abbr title="Universal Resource Locator">URL</abbr>s here. For example, <code>/index.php/taxonomy/tags</code> would make your category links like <code>http://example.org/index.php/taxonomy/tags/uncategorized/</code>. If you leave this blank the default will be used.') ?></p> 167 <?php endif; ?> 168 <p> 169 <?php _e('Category base'); ?>: <input name="category_base" id="category_base" type="text" class="code" value="<?php echo attribute_escape($category_base); ?>" size="30" /> 170 </p> 171 <p> 172 <?php _e('Tag base'); ?>: <input name="tag_base" id="tag_base" type="text" class="code" value="<?php echo attribute_escape($tag_base); ?>" size="30" /> 173 </p> 174 <p class="submit"> 175 <input type="submit" name="submit" value="<?php _e('Update Permalink Structure »') ?>" /> 176 </p> 177 </form> 174 175 <table class="permalink-bases" style="width: 99%"> 176 <tr> 177 <td style="width: 33%"> 178 <h4><?php _e( 'Category Base' ); ?></h4> 179 <p><input type="text" name="category_base" id="category_base" class="code" value="<?php echo attribute_escape( $category_base ); ?>" size="30" /></p> 180 <p><small><?php _e( 'Default:' ); ?> <code>/category</code></small></p> 181 </td> 182 <td style="width: 33%"> 183 <h4><?php _e( 'Tag Base' ); ?></h4> 184 <p><input type="text" name="tag_base" id="tag_base" class="code" value="<?php echo attribute_escape( $tag_base ); ?>" size="30" /></p> 185 <p><small><?php _e( 'Default:' ); ?> <code>/tag</code></small></p> 186 </td> 187 <td> 188 <h4><?php _e( 'Author Base' ); ?></h4> 189 <p><input type="text" name="author_base" id="author_base" class="code" value="<?php echo attribute_escape( $author_base ); ?>" size="30" /></p> 190 <p><small><?php _e( 'Default:' ); ?> <code>/author</code></small></p> 191 </td> 192 </tr> 193 <tr> 194 <td> 195 <h4><?php _e( 'Search Base' ); ?></h4> 196 <p><input type="text" name="search_base" id="search_base" class="code" value="<?php echo attribute_escape( $search_base ); ?>" size="30" /></p> 197 <p><small><?php _e( 'Default:' ); ?> <code>/search</code></small></p> 198 </td> 199 <td> 200 <h4><?php _e( 'Feed Base' ); ?></h4> 201 <p><input type="text" name="feed_base" id="feed_base" class="code" value="<?php echo attribute_escape( $feed_base ); ?>" size="30" /></p> 202 <p><small><?php _e( 'Default:' ); ?> <code>/feed</code></small></p> 203 </td> 204 <td> 205 <h4><?php _e( 'Comments Feed Base' ); ?></h4> 206 <p><input type="text" name="comments_base" id="comments_base" class="code" value="<?php echo attribute_escape( $comments_base ); ?>" size="30" /></p> 207 <p><small><?php _e( 'Default:' ); ?> <code>/comments</code></small></p> 208 </td> 209 </tr> 210 </table> 211 212 <p class="submit"><input type="submit" name="submit" value="<?php _e('Update Permalink Structure »') ?>" /></p> 213 214 </form> 215 178 216 <?php if ( $permalink_structure && !$usingpi && !$writable ) : ?> 179 217 <p><?php _e('If your <code>.htaccess</code> file were <a href="http://codex.wordpress.org/Make_a_Directory_Writable">writable</a>, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your <code>.htaccess</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all.') ?></p> 180 218 <form action="options-permalink.php" method="post"> -
wp-admin/upgrade-schema.php
243 243 add_option('default_link_category', 2); 244 244 add_option('show_on_front', 'posts'); 245 245 246 // 2. 2246 // 2.3 247 247 add_option('tag_base'); 248 add_option( 'author_base' ); 249 add_option( 'search_base' ); 250 add_option( 'comments_base' ); 251 add_option( 'feed_base' ); 248 252 249 253 // Delete unused options 250 254 $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing');