WordPress.org

Make WordPress Core

Ticket #32396: 32396.patch

File 32396.patch, 21.4 KB (added by chriscct7, 6 years ago)

Round 1 at this

  • src/wp-admin/includes/schema.php

     
    393393        'comments_notify' => 1,
    394394        'posts_per_rss' => 10,
    395395        'rss_use_excerpt' => 0,
    396         'mailserver_url' => 'mail.example.com',
    397         'mailserver_login' => 'login@example.com',
    398         'mailserver_pass' => 'password',
    399         'mailserver_port' => 110,
    400396        'default_category' => 1,
    401397        'default_comment_status' => 'open',
    402398        'default_ping_status' => 'open',
     
    423419        'gmt_offset' => $gmt_offset,
    424420
    425421        // 1.5
    426         'default_email_category' => 1,
    427422        'recently_edited' => '',
    428423        'template' => $template,
    429424        'stylesheet' => WP_DEFAULT_THEME,
  • src/wp-admin/includes/template.php

     
    12421242 * @param string $id       Slug-name to identify the section. Used in the 'id' attribute of tags.
    12431243 * @param string $title    Formatted title of the section. Shown as the heading for the section.
    12441244 * @param string $callback Function that echos out any content at the top of the section (between heading and fields).
    1245  * @param string $page     The slug-name of the settings page on which to show the section. Built-in pages include 'general', 'reading', 'writing', 'discussion', 'media', etc. Create your own using add_options_page();
     1245 * @param string $page     The slug-name of the settings page on which to show the section. Built-in pages include 'general', 'discussion', 'media', etc. Create your own using add_options_page();
    12461246 */
    12471247function add_settings_section($id, $title, $callback, $page) {
    12481248        global $wp_settings_sections;
     
    12541254
    12551255        if ( 'privacy' == $page ) {
    12561256                _deprecated_argument( __FUNCTION__, '3.5', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'privacy' ) );
    1257                 $page = 'reading';
     1257                $page = 'general';
    12581258        }
    12591259
     1260        if ( 'writing' == $page ) {
     1261                _deprecated_argument( __FUNCTION__, '4.4', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'writing' ) );
     1262                $page = 'general';
     1263        }
     1264       
     1265        if ( 'reading' == $page ) {
     1266                _deprecated_argument( __FUNCTION__, '4.4', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'reading' ) );
     1267                $page = 'general';
     1268        }       
     1269
    12601270        $wp_settings_sections[$page][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback);
    12611271}
    12621272
     
    13051315
    13061316        if ( 'privacy' == $page ) {
    13071317                _deprecated_argument( __FUNCTION__, '3.5', __( 'The privacy options group has been removed. Use another settings group.' ) );
    1308                 $page = 'reading';
     1318                $page = 'general';
    13091319        }
    13101320
     1321        if ( 'writing' == $page ) {
     1322                _deprecated_argument( __FUNCTION__, '4.4', __( 'The writing options group has been removed. Use another settings group.' ) );
     1323                $page = 'general';
     1324        }
     1325       
     1326        if ( 'reading' == $page ) {
     1327                _deprecated_argument( __FUNCTION__, '4.4', __( 'The reading options group has been removed. Use another settings group.' ) );
     1328                $page = 'general';
     1329        }
     1330
    13111331        $wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args);
    13121332}
    13131333
  • src/wp-admin/menu.php

     
    232232
    233233$menu[80] = array( __('Settings'), 'manage_options', 'options-general.php', '', 'menu-top menu-icon-settings', 'menu-settings', 'dashicons-admin-settings' );
    234234        $submenu['options-general.php'][10] = array(_x('General', 'settings screen'), 'manage_options', 'options-general.php');
    235         $submenu['options-general.php'][15] = array(__('Writing'), 'manage_options', 'options-writing.php');
    236         $submenu['options-general.php'][20] = array(__('Reading'), 'manage_options', 'options-reading.php');
    237235        $submenu['options-general.php'][25] = array(__('Discussion'), 'manage_options', 'options-discussion.php');
    238236        $submenu['options-general.php'][30] = array(__('Media'), 'manage_options', 'options-media.php');
    239237        $submenu['options-general.php'][40] = array(__('Permalinks'), 'manage_options', 'options-permalink.php');
  • src/wp-admin/options-discussion.php

     
    1414$title = __('Discussion Settings');
    1515$parent_file = 'options-general.php';
    1616
    17 add_action( 'admin_print_footer_scripts', 'options_discussion_add_js' );
     17if ( get_site_option( 'initial_db_version' ) < 32453 ) {
     18        add_action( 'admin_print_footer_scripts', 'options_discussion_add_js' );
     19}
    1820
    1921get_current_screen()->add_help_tab( array(
    2022        'id'      => 'overview',
     
    169171</tr>
    170172<?php do_settings_fields('discussion', 'default'); ?>
    171173</table>
    172 
     174<?php if ( get_site_option( 'initial_db_version' ) < 32453 ) : ?>
    173175<h2 class="title"><?php _e('Avatars'); ?></h2>
    174176
    175177<p><?php _e('An avatar is an image that follows you from weblog to weblog appearing beside your name when you comment on avatar enabled sites. Here you can enable the display of avatars for people who comment on your site.'); ?></p>
     
    276278</tr>
    277279<?php do_settings_fields('discussion', 'avatars'); ?>
    278280</table>
    279 
     281+<?php endif; ?>
    280282<?php do_settings_sections('discussion'); ?>
    281283
    282284<?php submit_button(); ?>
  • src/wp-admin/options-general.php

     
    2020/* translators: date and time format for exact current time, mainly about timezones, see http://php.net/date */
    2121$timezone_format = _x('Y-m-d H:i:s', 'timezone date format');
    2222
     23if ( get_site_option( 'initial_db_version' ) >= 32453  ) { ?>
     24<script type="text/javascript">
     25        jQuery(document).ready(function($){
     26                var section = $('#front-static-pages'),
     27                        staticPage = section.find('input:radio[value="page"]'),
     28                        selects = section.find('select'),
     29                        check_disabled = function(){
     30                                selects.prop( 'disabled', ! staticPage.prop('checked') );
     31                        };
     32                check_disabled();
     33                section.find('input:radio').change(check_disabled);
     34        });
     35</script>
     36<?php }
     37
    2338add_action('admin_head', 'options_general_add_js');
    2439
    2540$options_help = '<p>' . __('The fields on this screen determine some of the basics of your site setup.') . '</p>' .
     
    4055        'content' => $options_help,
    4156) );
    4257
     58if ( get_site_option( 'initial_db_version' ) >= 32453  ) {
     59get_current_screen()->add_help_tab( array(
     60        'id'      => 'site-visibility',
     61        'title'   => has_action( 'blog_privacy_selector' ) ? __( 'Site Visibility' ) : __( 'Search Engine Visibility' ),
     62        'content' => '<p>' . __( 'You can choose whether or not your site will be crawled by robots, ping services, and spiders. If you want those services to ignore your site, click the checkbox next to &#8220;Discourage search engines from indexing this site&#8221; and click the Save Changes button at the bottom of the screen. Note that your privacy is not complete; your site is still visible on the web.' ) . '</p>' .
     63                '<p>' . __( 'When this setting is in effect, a reminder is shown in the At a Glance box of the Dashboard that says, &#8220;Search Engines Discouraged,&#8221; to remind you that your site is not being crawled.' ) . '</p>',
     64) );
     65/** This filter is documented in wp-admin/options-general.php */
     66if ( apply_filters( 'enable_update_services_configuration', true ) ) {
     67        get_current_screen()->add_help_tab( array(
     68                'id'      => 'options-services',
     69                'title'   => __( 'Update Services' ),
     70                'content' => '<p>' . __( 'If desired, WordPress will automatically alert various services of your new posts.' ) . '</p>',
     71        ) );
     72}
     73}
     74
    4375get_current_screen()->set_help_sidebar(
    4476        '<p><strong>' . __('For more information:') . '</strong></p>' .
    4577        '<p>' . __('<a href="https://codex.wordpress.org/Settings_General_Screen" target="_blank">Documentation on General Settings</a>') . '</p>' .
     
    75107<td><input name="home" type="url" id="home" aria-describedby="home-description" value="<?php form_option( 'home' ); ?>"<?php disabled( defined( 'WP_HOME' ) ); ?> class="regular-text code<?php if ( defined( 'WP_HOME' ) ) echo ' disabled' ?>" />
    76108<p class="description" id="home-description"><?php _e( 'Enter the address here if you <a href="https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory">want your site home page to be different from your WordPress installation directory.</a>' ); ?></p></td>
    77109</tr>
     110<?php }
     111if ( get_site_option( 'initial_db_version' ) >= 32453 ) : ?>
     112        <?php if ( ! get_pages() ) : ?>
     113                        <input name="show_on_front" type="hidden" value="posts" />
     114                        <?php
     115                                if ( 'posts' != get_option( 'show_on_front' ) ) :
     116                                        update_option( 'show_on_front', 'posts' );
     117                                endif;
     118
     119                        else :
     120                                if ( 'page' == get_option( 'show_on_front' ) && ! get_option( 'page_on_front' ) && ! get_option( 'page_for_posts' ) ) {
     121                                        update_option( 'show_on_front', 'posts' );
     122                                }
     123
     124                        ?>
     125                        <tr>
     126                        <th scope="row"><?php _e( 'Front page displays' ); ?></th>
     127                        <td id="front-static-pages"><fieldset><legend class="screen-reader-text"><span><?php _e( 'Front page displays' ); ?></span></legend>
     128                                <p><label>
     129                                        <input name="show_on_front" type="radio" value="posts" class="tog" <?php checked( 'posts', get_option( 'show_on_front' ) ); ?> />
     130                                        <?php _e( 'Your latest posts' ); ?>
     131                                </label>
     132                                </p>
     133                                <p><label>
     134                                        <input name="show_on_front" type="radio" value="page" class="tog" <?php checked( 'page', get_option( 'show_on_front' ) ); ?> />
     135                                        <?php printf( __( 'A <a href="%s">static page</a> (select below)' ), 'edit.php?post_type=page' ); ?>
     136                                </label>
     137                                </p>
     138                        <ul>
     139                                <li><label for="page_on_front"><?php printf( __( 'Front page: %s' ), wp_dropdown_pages( array( 'name' => 'page_on_front', 'echo' => 0, 'show_option_none' => __( '&mdash; Select &mdash;' ), 'option_none_value' => '0', 'selected' => get_option( 'page_on_front' ) ) ) ); ?></label></li>
     140                                <li><label for="page_for_posts"><?php printf( __( 'Posts page: %s' ), wp_dropdown_pages( array( 'name' => 'page_for_posts', 'echo' => 0, 'show_option_none' => __( '&mdash; Select &mdash;' ), 'option_none_value' => '0', 'selected' => get_option( 'page_for_posts' ) ) ) ); ?></label></li>
     141                        </ul>
     142                        <?php if ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_for_posts' ) == get_option( 'page_on_front' ) ) : ?>
     143                        <div id="front-page-warning" class="error inline"><p><?php _e( '<strong>Warning:</strong> these pages should not be the same!' ); ?></p></div>
     144                        <?php endif; ?>
     145                        </fieldset></td>
     146                <?php endif; ?>
     147                        </tr>
     148<?php endif; ?>
     149<?php if ( !is_multisite() ) { ?>
    78150<tr>
    79151<th scope="row"><label for="admin_email"><?php _e('Email Address') ?> </label></th>
    80152<td><input name="admin_email" type="email" id="admin_email" aria-describedby="admin-email-description" value="<?php form_option( 'admin_email' ); ?>" class="regular-text ltr" />
     
    108180</td>
    109181</tr>
    110182<?php } ?>
     183
    111184<tr>
    112185<?php
    113186$current_offset = get_option('gmt_offset');
     
    318391        </tr>
    319392        <?php
    320393}
     394
     395if ( get_site_option( 'initial_db_version' ) >= 32453 ) : ?>
     396<tr class="option-site-visibility">
     397<th scope="row"><?php has_action( 'blog_privacy_selector' ) ? _e( 'Site Visibility' ) : _e( 'Search Engine Visibility' ); ?> </th>
     398<td><fieldset><legend class="screen-reader-text"><span><?php has_action( 'blog_privacy_selector' ) ? _e( 'Site Visibility' ) : _e( 'Search Engine Visibility' ); ?> </span></legend>
     399<?php if ( has_action( 'blog_privacy_selector' ) ) : ?>
     400        <input id="blog-public" type="radio" name="blog_public" value="1" <?php checked('1', get_option('blog_public')); ?> />
     401        <label for="blog-public"><?php _e( 'Allow search engines to index this site' );?></label><br/>
     402        <input id="blog-norobots" type="radio" name="blog_public" value="0" <?php checked('0', get_option('blog_public')); ?> />
     403        <label for="blog-norobots"><?php _e( 'Discourage search engines from indexing this site' ); ?></label>
     404        <p class="description"><?php _e( 'Note: Neither of these options blocks access to your site &mdash; it is up to search engines to honor your request.' ); ?></p>
     405        <?php
     406        /**
     407         * Enable the legacy 'Site Visibility' privacy options.
     408         *
     409         * By default the privacy options form displays a single checkbox to 'discourage' search
     410         * engines from indexing the site. Hooking to this action serves a dual purpose:
     411         * 1. Disable the single checkbox in favor of a multiple-choice list of radio buttons.
     412         * 2. Open the door to adding additional radio button choices to the list.
     413         *
     414         * Hooking to this action also converts the 'Search Engine Visibility' heading to the more
     415         * open-ended 'Site Visibility' heading.
     416         *
     417         * @since 2.1.0
     418         */
     419        do_action( 'blog_privacy_selector' );
     420        ?>
     421<?php else : ?>
     422        <label for="blog_public"><input name="blog_public" type="checkbox" id="blog_public" value="0" <?php checked( '0', get_option( 'blog_public' ) ); ?> />
     423        <?php _e( 'Discourage search engines from indexing this site' ); ?></label>
     424        <p class="description"><?php _e( 'It is up to search engines to honor this request.' ); ?></p>
     425<?php endif; ?>
     426</fieldset></td>
     427</tr>
     428<tr>
     429<th scope="row"><label for="default_category"><?php _e('Default Post Category') ?></label></th>
     430<td>
     431<?php
     432wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'default_category', 'orderby' => 'name', 'selected' => get_option('default_category'), 'hierarchical' => true));
    321433?>
     434</td>
     435</tr>
     436<tr>
     437<th scope="row"><label for="posts_per_page"><?php _e( 'Blog pages show at most' ); ?></label></th>
     438<td>
     439<input name="posts_per_page" type="number" step="1" min="1" id="posts_per_page" value="<?php form_option( 'posts_per_page' ); ?>" class="small-text" /> <?php _e( 'posts' ); ?>
     440</td>
     441</tr>
     442<?php if ( get_option( 'link_manager_enabled' ) ) :
     443?>
     444<tr>
     445<th scope="row"><label for="default_link_category"><?php _e('Default Link Category') ?></label></th>
     446<td>
     447<?php
     448wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'default_link_category', 'orderby' => 'name', 'selected' => get_option('default_link_category'), 'hierarchical' => true, 'taxonomy' => 'link_category'));
     449?>
     450</td>
     451</tr>
     452<?php endif; ?>
     453<?php
     454$post_formats = get_post_format_strings();
     455unset( $post_formats['standard'] );
     456?>
     457<tr>
     458<th scope="row"><label for="default_post_format"><?php _e('Default Post Format') ?></label></th>
     459<td>
     460        <select name="default_post_format" id="default_post_format">
     461                <option value="0"><?php echo get_post_format_string( 'standard' ); ?></option>
     462<?php foreach ( $post_formats as $format_slug => $format_name ): ?>
     463                <option<?php selected( get_option( 'default_post_format' ), $format_slug ); ?> value="<?php echo esc_attr( $format_slug ); ?>"><?php echo esc_html( $format_name ); ?></option>
     464<?php endforeach; ?>
     465        </select>
     466</td>
     467</tr>
     468
     469<?php
     470do_settings_fields('writing', 'default');
     471do_settings_fields('writing', 'remote_publishing'); // A deprecated section.
     472endif; ?>
    322473</table>
     474<?php if ( apply_filters( 'enable_update_services_configuration', false ) ) { ?>
     475        <?php if ( 1 == get_option('blog_public')  ) : ?>
    323476
     477        <p><label for="ping_sites"><?php _e('When you publish a new post, WordPress automatically notifies the following site update services. For more about this, see <a href="https://codex.wordpress.org/Update_Services">Update Services</a> on the Codex. Separate multiple service <abbr title="Universal Resource Locator">URL</abbr>s with line breaks.') ?></label></p>
     478
     479        <textarea name="ping_sites" id="ping_sites" class="large-text code" rows="3"><?php echo esc_textarea( get_option('ping_sites') ); ?></textarea>
     480
     481        <?php else : ?>
     482
     483                <p><?php printf(__('WordPress is not notifying any <a href="https://codex.wordpress.org/Update_Services">Update Services</a> because of your site&#8217;s <a href="%s">visibility settings</a>.'), 'options-reading.php'); ?></p>
     484
     485        <?php endif; ?>
     486<?php } ?>
     487<?php do_settings_sections('writing'); ?>
    324488<?php do_settings_sections('general'); ?>
    325489
    326490<?php submit_button(); ?>
  • src/wp-admin/options.php

     
    8383
    8484$whitelist_options = array(
    8585        'general' => array( 'blogname', 'blogdescription', 'gmt_offset', 'date_format', 'time_format', 'start_of_week', 'timezone_string', 'WPLANG' ),
    86         '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' ),
    87         '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' ),
    88         'reading' => array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'show_on_front', 'page_on_front', 'page_for_posts', 'blog_public' ),
    89         'writing' => array( 'default_category', 'default_email_category', 'default_link_category', 'default_post_format' )
     86        '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', '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' ),
     87        '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' )
    9088);
     89
     90if ( get_site_option( 'initial_db_version' ) < 32453 ) {
     91        $whitelist_options['writing'] = array();
     92        $whitelist_options['reading'] = array( 'posts_per_page', 'posts_per_rss', 'rss_use_excerpt', 'show_on_front', 'page_on_front', 'page_for_posts', 'blog_public' );
     93        $whitelist_options['writing'] = array();
     94        $whitelist_options['discussion'][] = 'avatar_default';
     95        $whitelist_options['discussion'][] = 'show_avatars';
     96        $whitelist_options['discussion'][] = 'avatar_rating';
     97        if ( show_writing_setting_page() ) {
     98                $whitelist_options['discussion'][] = 'default_category';
     99        } else {
     100                $whitelist_options['general'][] = 'default_category';
     101        }
     102        $whitelist_options['discussion'][] = 'default_link_category';
     103        $whitelist_options['discussion'][] = 'default_post_format';
     104} else {
     105        $whitelist_options['general'][] = 'posts_per_page';
     106        $whitelist_options['general'][] = 'page_on_front';
     107        $whitelist_options['general'][] = 'page_for_posts';
     108        $whitelist_options['general'][] = 'blog_public';
     109}
     110
    91111$whitelist_options['misc'] = $whitelist_options['options'] = $whitelist_options['privacy'] = array();
    92112
    93 $mail_options = array('mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass');
    94 
    95 if ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) )
     113if ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) ){
    96114        $whitelist_options['reading'][] = 'blog_charset';
    97 
    98 if ( get_site_option( 'initial_db_version' ) < 32453 ) {
    99         $whitelist_options['writing'][] = 'use_smilies';
    100         $whitelist_options['writing'][] = 'use_balanceTags';
    101115}
    102116
     117
    103118if ( !is_multisite() ) {
    104119        if ( !defined( 'WP_SITEURL' ) )
    105120                $whitelist_options['general'][] = 'siteurl';
     
    110125        $whitelist_options['general'][] = 'users_can_register';
    111126        $whitelist_options['general'][] = 'default_role';
    112127
    113         $whitelist_options['writing'] = array_merge($whitelist_options['writing'], $mail_options);
    114         $whitelist_options['writing'][] = 'ping_sites';
     128        if ( get_site_option( 'initial_db_version' ) < 32453 ) {
     129                $whitelist_options['writing'][] = 'ping_sites';
     130        }
    115131
    116132        $whitelist_options['media'][] = 'uploads_use_yearmonth_folders';
    117133
     
    122138        }
    123139} else {
    124140        $whitelist_options['general'][] = 'new_admin_email';
    125 
    126         /**
    127          * Filter whether the post-by-email functionality is enabled.
    128          *
    129          * @since 3.0.0
    130          *
    131          * @param bool $enabled Whether post-by-email configuration is enabled. Default true.
    132          */
    133         if ( apply_filters( 'enable_post_by_email_configuration', true ) )
    134                 $whitelist_options['writing'] = array_merge($whitelist_options['writing'], $mail_options);
    135141}
    136142
    137143/**
  • src/wp-includes/formatting.php

     
    35423542                case 'page_for_posts':
    35433543                case 'rss_excerpt_length':
    35443544                case 'default_category':
    3545                 case 'default_email_category':
    35463545                case 'default_link_category':
    35473546                case 'close_comments_days_old':
    35483547                case 'comments_per_page':
     
    35943593
    35953594                case 'date_format':
    35963595                case 'time_format':
    3597                 case 'mailserver_url':
    3598                 case 'mailserver_login':
    3599                 case 'mailserver_pass':
    36003596                case 'upload_path':
    36013597                        $value = $wpdb->strip_invalid_text_for_column( $wpdb->options, 'option_value', $value );
    36023598                        if ( is_wp_error( $value ) ) {