Make WordPress Core

Ticket #9296: 9296.diff

File 9296.diff, 5.9 KB (added by andrewryno, 13 years ago)
  • wp-admin/options.php

     
    6161        'privacy' => array( 'blog_public' ),
    6262        'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'blog_charset', 'show_on_front', 'page_on_front', 'page_for_posts' ),
    6363        'writing' => array( 'default_post_edit_rows', 'use_smilies', 'default_category', 'default_email_category', 'use_balanceTags', 'default_link_category', 'default_post_format', 'enable_app', 'enable_xmlrpc' ),
    64         'options' => array( '' ) );
     64        'options' => array( '' ),
     65        'permalink' => array( 'permalink_structure', 'category_base', 'tag_base' ) );
    6566
    6667$mail_options = array('mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass');
    6768$uploads_options = array('uploads_use_yearmonth_folders', 'upload_path', 'upload_url_path');
     
    105106                check_admin_referer( $option_page . '-options' );
    106107        }
    107108
    108         if ( !isset( $whitelist_options[ $option_page ] ) )
     109        if ( ! isset( $whitelist_options[ $option_page ] ) )
    109110                wp_die( __( 'Error: options page not found.' ) );
    110111
    111112        if ( 'options' == $option_page ) {
     
    129130                        $_POST['timezone_string'] = '';
    130131                }
    131132        }
     133       
     134        if ( 'permalink' == $option_page ) {
     135                if ( isset( $permalink_structure ) || isset( $category_base ) ) {
    132136
     137                        if ( isset( $permalink_structure ) ) {
     138                                if ( isset( $selection ) && 'custom' != $selection )
     139                                        $permalink_structure = $selection;
     140                               
     141                                if ( ! empty( $permalink_structure ) ) {
     142                                        $permalink_structure = preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $permalink_structure ) );
     143                                        if ( $prefix && $blog_prefix )
     144                                                $permalink_structure = $prefix . preg_replace( '#^/?index\.php#', '', $permalink_structure );
     145                                        else
     146                                                $permalink_structure = $blog_prefix . $permalink_structure;
     147                                }
     148                                $wp_rewrite->set_permalink_structure( $permalink_structure );
     149                        }
     150
     151                        if ( isset( $category_base ) ) {
     152                                if ( ! empty( $category_base ) )
     153                                        $category_base = $blog_prefix . preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $category_base ) );
     154                                $wp_rewrite->set_category_base( $category_base );
     155                        }
     156
     157                        if ( isset( $tag_base ) ) {
     158                                if ( ! empty( $tag_base ) )
     159                                        $tag_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace( '#', '', $tag_base ) );
     160                                $wp_rewrite->set_tag_base( $tag_base );
     161                        }
     162
     163                        create_initial_taxonomies();
     164                }
     165        }
     166
    133167        if ( $options ) {
    134168                foreach ( $options as $option ) {
    135169                        if ( $unregistered )
     
    150184         *  Handle settings errors and return to options page
    151185         */
    152186        // If no settings errors were registered add a general 'updated' message.
    153         if ( !count( get_settings_errors() ) )
     187        if ( !count( get_settings_errors() ) && 'permalink' != $option_page )
    154188                add_settings_error('general', 'settings_updated', __('Settings saved.'), 'updated');
    155189        set_transient('settings_errors', get_settings_errors(), 30);
    156190
  • wp-admin/options-permalink.php

     
    6565if ( is_multisite() && !is_subdomain_install() && is_main_site() )
    6666        $blog_prefix = '/blog';
    6767
    68 if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) {
    69         check_admin_referer('update-permalink');
    70 
    71         if ( isset( $_POST['permalink_structure'] ) ) {
    72                 if ( isset( $_POST['selection'] ) && 'custom' != $_POST['selection'] )
    73                         $permalink_structure = $_POST['selection'];
    74                 else
    75                         $permalink_structure = $_POST['permalink_structure'];
    76 
    77                 if ( ! empty( $permalink_structure ) ) {
    78                         $permalink_structure = preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $permalink_structure ) );
    79                         if ( $prefix && $blog_prefix )
    80                                 $permalink_structure = $prefix . preg_replace( '#^/?index\.php#', '', $permalink_structure );
    81                         else
    82                                 $permalink_structure = $blog_prefix . $permalink_structure;
    83                 }
    84                 $wp_rewrite->set_permalink_structure( $permalink_structure );
    85         }
    86 
    87         if ( isset( $_POST['category_base'] ) ) {
    88                 $category_base = $_POST['category_base'];
    89                 if ( ! empty( $category_base ) )
    90                         $category_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace( '#', '', $category_base ) );
    91                 $wp_rewrite->set_category_base( $category_base );
    92         }
    93 
    94         if ( isset( $_POST['tag_base'] ) ) {
    95                 $tag_base = $_POST['tag_base'];
    96                 if ( ! empty( $tag_base ) )
    97                         $tag_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace( '#', '', $tag_base ) );
    98                 $wp_rewrite->set_tag_base( $tag_base );
    99         }
    100 
    101         create_initial_taxonomies();
    102 }
    103 
    104 $permalink_structure = get_option('permalink_structure');
    105 $category_base = get_option('category_base');
     68$permalink_structure = get_option( 'permalink_structure' );
     69$category_base = get_option( 'category_base' );
    10670$tag_base = get_option( 'tag_base' );
    10771
    10872if ( $iis7_permalinks ) {
     
    12589$wp_rewrite->flush_rules();
    12690
    12791
    128 if (isset($_POST['submit'])) : ?>
     92if (isset($_GET['settings-updated'])) : ?>
    12993<div id="message" class="updated"><p><?php
    13094if ( ! is_multisite() ) {
    13195        if ( $iis7_permalinks ) {
     
    152116<?php screen_icon(); ?>
    153117<h2><?php echo esc_html( $title ); ?></h2>
    154118
    155 <form name="form" action="options-permalink.php" method="post">
    156 <?php wp_nonce_field('update-permalink') ?>
     119<form name="form" action="options.php" method="post">
     120<?php settings_fields( 'permalink' ); ?>
    157121
    158122  <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>
    159123