Ticket #9296: 9296.4.diff
File 9296.4.diff, 8.5 KB (added by , 12 years ago) |
---|
-
wp-admin/options-permalink.php
82 82 if ( is_multisite() && !is_subdomain_install() && is_main_site() ) 83 83 $blog_prefix = '/blog'; 84 84 85 if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) { 86 check_admin_referer('update-permalink'); 87 88 if ( isset( $_POST['permalink_structure'] ) ) { 89 if ( isset( $_POST['selection'] ) && 'custom' != $_POST['selection'] ) 90 $permalink_structure = $_POST['selection']; 91 else 92 $permalink_structure = $_POST['permalink_structure']; 93 94 if ( ! empty( $permalink_structure ) ) { 95 $permalink_structure = preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $permalink_structure ) ); 96 if ( $prefix && $blog_prefix ) 97 $permalink_structure = $prefix . preg_replace( '#^/?index\.php#', '', $permalink_structure ); 98 else 99 $permalink_structure = $blog_prefix . $permalink_structure; 100 } 101 $wp_rewrite->set_permalink_structure( $permalink_structure ); 102 } 103 104 if ( isset( $_POST['category_base'] ) ) { 105 $category_base = $_POST['category_base']; 106 if ( ! empty( $category_base ) ) 107 $category_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace( '#', '', $category_base ) ); 108 $wp_rewrite->set_category_base( $category_base ); 109 } 110 111 if ( isset( $_POST['tag_base'] ) ) { 112 $tag_base = $_POST['tag_base']; 113 if ( ! empty( $tag_base ) ) 114 $tag_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace( '#', '', $tag_base ) ); 115 $wp_rewrite->set_tag_base( $tag_base ); 116 } 117 118 create_initial_taxonomies(); 119 } 120 121 $permalink_structure = get_option('permalink_structure'); 122 $category_base = get_option('category_base'); 85 $permalink_structure = get_option( 'permalink_structure' ); 86 $category_base = get_option( 'category_base' ); 123 87 $tag_base = get_option( 'tag_base' ); 124 88 125 89 if ( $iis7_permalinks ) { … … 140 104 $usingpi = false; 141 105 142 106 flush_rewrite_rules(); 143 144 if (isset($_POST['submit'])) : ?>145 <div id="message" class="updated"><p><?php146 if ( ! is_multisite() ) {147 if ( $iis7_permalinks ) {148 if ( $permalink_structure && ! $usingpi && ! $writable )149 _e('You should update your web.config now.');150 else if ( $permalink_structure && ! $usingpi && $writable )151 _e('Permalink structure updated. Remove write access on web.config file now!');152 else153 _e('Permalink structure updated.');154 } else {155 if ( $permalink_structure && ! $usingpi && ! $writable )156 _e('You should update your .htaccess now.');157 else158 _e('Permalink structure updated.');159 }160 } else {161 _e('Permalink structure updated.');162 }163 107 ?> 164 </p></div>165 <?php endif; ?>166 108 167 109 <div class="wrap"> 168 110 <?php screen_icon(); ?> 169 111 <h2><?php echo esc_html( $title ); ?></h2> 170 112 171 <form name="form" action="options -permalink.php" method="post">172 <?php wp_nonce_field('update-permalink')?>113 <form name="form" action="options.php" method="post"> 114 <?php settings_fields( 'permalink' ); ?> 173 115 174 116 <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> 175 117 -
wp-admin/options.php
63 63 'discussion' => array( 'default_pingback_flag', 'default_ping_status', 'default_comment_status', 'comments_notify', 'moderation_notify', 'comment_moderation', 'require_name_email', 'comment_whitelist', 'comment_max_links', 'moderation_keys', 'blacklist_keys', 'show_avatars', 'avatar_rating', 'avatar_default', 'close_comments_for_old_posts', 'close_comments_days_old', 'thread_comments', 'thread_comments_depth', 'page_comments', 'comments_per_page', 'default_comments_page', 'comment_order', 'comment_registration' ), 64 64 'media' => array( 'thumbnail_size_w', 'thumbnail_size_h', 'thumbnail_crop', 'medium_size_w', 'medium_size_h', 'large_size_w', 'large_size_h', 'image_default_size', 'image_default_align', 'image_default_link_type' ), 65 65 'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'show_on_front', 'blog_public' ), 66 'writing' => array( 'use_smilies', 'default_category', 'default_email_category', 'use_balanceTags', 'default_link_category', 'default_post_format' ) 66 'writing' => array( 'use_smilies', 'default_category', 'default_email_category', 'use_balanceTags', 'default_link_category', 'default_post_format' ), 67 'permalink' => array( 'permalink_structure', 'category_base', 'tag_base' ), 67 68 ); 68 69 $whitelist_options['misc'] = $whitelist_options['options'] = $whitelist_options['privacy'] = array(); 69 70 … … 139 140 } 140 141 } 141 142 143 // Handle permalinks page. 144 if ( 'permalink' == $option_page ) { 145 146 $prefix = $blog_prefix = ''; 147 if ( ! got_mod_rewrite() && ! iis7_supports_permalinks() ) 148 $prefix = '/index.php'; 149 if ( is_multisite() && ! is_subdomain_install() && is_main_site() ) 150 $blog_prefix = '/blog'; 151 152 if ( isset( $_POST['permalink_structure'] ) || isset( $_POST['category_base'] ) || isset( $_POST['tag_base'] ) ) { 153 154 if ( isset( $_POST['permalink_structure'] ) ) { 155 $permalink_structure = $_POST['permalink_structure']; 156 157 if ( isset( $_POST['selection'] ) && 'custom' != $_POST['selection'] ) { 158 $permalink_structure = $_POST['selection']; 159 } 160 161 if ( ! empty( $permalink_structure ) ) { 162 $permalink_structure = preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $permalink_structure ) ); 163 if ( $prefix && $blog_prefix ) 164 $permalink_structure = $prefix . preg_replace( '#^/?index\.php#', '', $permalink_structure ); 165 else 166 $permalink_structure = $blog_prefix . $permalink_structure; 167 } 168 169 $wp_rewrite->set_permalink_structure( $permalink_structure ); 170 171 // Make sure the actual option is updated too. 172 $_POST['permalink_structure'] = $permalink_structure; 173 } 174 175 if ( isset( $_POST['category_base'] ) ) { 176 $category_base = $_POST['category_base']; 177 if ( ! empty( $category_base ) ) 178 $category_base = $blog_prefix . preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $category_base ) ); 179 $wp_rewrite->set_category_base( $category_base ); 180 } 181 182 if ( isset( $_POST['tag_base'] ) ) { 183 $tag_base = $_POST['tag_base']; 184 if ( ! empty( $tag_base ) ) 185 $tag_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace( '#', '', $tag_base ) ); 186 $wp_rewrite->set_tag_base( $tag_base ); 187 } 188 189 // Used for a proper update message. 190 if ( iis7_supports_permalinks() ) { 191 if ( ( ! file_exists($home_path . 'web.config') && win_is_writable($home_path) ) || win_is_writable($home_path . 'web.config') ) 192 $writable = true; 193 else 194 $writable = false; 195 } else { 196 if ( ( ! file_exists($home_path . '.htaccess') && is_writable($home_path) ) || is_writable($home_path . '.htaccess') ) 197 $writable = true; 198 else 199 $writable = false; 200 } 201 202 if ( ! is_multisite() ) { 203 if ( iis7_supports_permalinks() ) { 204 if ( $permalink_structure && ! $wp_rewrite->using_index_permalinks() && ! $writable ) 205 add_settings_error( 'permalink', 'settings_updated', __( 'You should update your web.config now.' ), 'updated' ); 206 else if ( $permalink_structure && ! $wp_rewrite->using_index_permalinks() && $writable ) 207 add_settings_error( 'permalink', 'settings_updated', __( 'Permalink structure updated. Remove write access on web.config file now!' ), 'updated' ); 208 else 209 add_settings_error( 'permalink', 'settings_updated', __( 'Permalink structure updated.' ), 'updated' ); 210 } else { 211 if ( $permalink_structure && ! $wp_rewrite->using_index_permalinks() && ! $writable ) 212 add_settings_error( 'permalink', 'settings_updated', __( 'You should update your .htaccess now.' ), 'updated' ); 213 else 214 add_settings_error( 'permalink', 'settings_updated', __( 'Permalink structure updated.' ), 'updated' ); 215 } 216 } else { 217 add_settings_error( 'permalink', 'settings_updated', __( 'Permalink structure updated.' ), 'updated' ); 218 } 219 220 create_initial_taxonomies(); 221 } 222 } 223 142 224 if ( $options ) { 143 225 foreach ( $options as $option ) { 144 226 if ( $unregistered )