Make WordPress Core

Ticket #10970: 10970-readonly.diff

File 10970-readonly.diff, 3.9 KB (added by sabernhardt, 20 months ago)

use readonly for fields; add constant to override

  • src/wp-admin/options-general.php

     
    2828        '<p>' . __( 'Most themes display the site title at the top of every page, in the title bar of the browser, and as the identifying name for syndicated feeds. The tagline is also displayed by many themes.' ) . '</p>';
    2929
    3030if ( ! is_multisite() ) {
    31         $options_help .= '<p>' . __( 'The WordPress URL and the site URL can be the same (example.com) or different; for example, having the WordPress core files (example.com/wordpress) in a subdirectory instead of the root directory.' ) . '</p>' .
    32                 '<p>' . __( 'If you want site visitors to be able to register themselves, as opposed to by the site administrator, check the membership box. A default user role can be set for all new users, whether self-registered or registered by the site admin.' ) . '</p>';
     31        if ( ! ( defined( 'WP_DISABLE_URL_CHANGES' ) && WP_DISABLE_URL_CHANGES ) ) {
     32                $options_help .= '<p>' . __( 'The WordPress URL and the site URL can be the same (example.com) or different; for example, having the WordPress core files (example.com/wordpress) in a subdirectory instead of the root directory.' ) . '</p>';
     33        }
     34        $options_help .= '<p>' . __( 'If you want site visitors to be able to register themselves, as opposed to by the site administrator, check the membership box. A default user role can be set for all new users, whether self-registered or registered by the site admin.' ) . '</p>';
    3335}
    3436
    3537$options_help .= '<p>' . __( 'You can set the language, and the translation files will be automatically downloaded and installed (available if your filesystem is writable).' ) . '</p>' .
     
    8183</tr>
    8284
    8385<?php
    84 if ( ! is_multisite() ) {
     86if ( ! is_multisite() && ! ( defined( 'WP_DISABLE_URL_CHANGES' ) && WP_DISABLE_URL_CHANGES ) ) {
    8587        $wp_site_url_class = '';
    8688        $wp_home_class     = '';
     89        $url_edit_button   = '';
     90        // Check wp-config.php for URL settings.
    8791        if ( defined( 'WP_SITEURL' ) ) {
    88                 $wp_site_url_class = ' disabled';
     92                $wp_site_url_class = ' readonly';
    8993        }
    9094        if ( defined( 'WP_HOME' ) ) {
    91                 $wp_home_class = ' disabled';
     95                $wp_home_class = ' readonly';
    9296        }
     97        // Enable fields on page load when Change button is clicked or if the constant is set to `false`.
     98        if ( empty( $_REQUEST['change_urls'] ) && ! ( defined( 'WP_DISABLE_URL_CHANGES' ) && ! WP_DISABLE_URL_CHANGES ) ) {
     99                $wp_site_url_class = ' readonly';
     100                $wp_home_class     = ' readonly';
     101                $url_edit_button   = ' <a class="button button-secondary aria-button-if-js change-urls" href="options-general.php?change_urls=1">' . __( 'Change site addresses' ) . '</a>';
     102        }
    93103        ?>
    94104
    95105<tr>
    96106<th scope="row"><label for="siteurl"><?php _e( 'WordPress Address (URL)' ); ?></label></th>
    97 <td><input name="siteurl" type="url" id="siteurl" value="<?php form_option( 'siteurl' ); ?>"<?php disabled( defined( 'WP_SITEURL' ) ); ?> class="regular-text code<?php echo $wp_site_url_class; ?>" /></td>
     107<td><input name="siteurl" type="url" id="siteurl" value="<?php form_option( 'siteurl' ); ?>"<?php wp_readonly( ! empty( $wp_site_url_class ) ); ?> class="regular-text code<?php echo $wp_site_url_class; ?>" /><?php echo $url_edit_button; ?></td>
    98108</tr>
    99109
    100110<tr>
    101111<th scope="row"><label for="home"><?php _e( 'Site Address (URL)' ); ?></label></th>
    102 <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 echo $wp_home_class; ?>" />
     112<td><input name="home" type="url" id="home" aria-describedby="home-description" value="<?php form_option( 'home' ); ?>"<?php wp_readonly( ! empty( $wp_home_class ) ); ?> class="regular-text code<?php echo $wp_home_class; ?>" /><?php echo $url_edit_button; ?>
    103113        <?php if ( ! defined( 'WP_HOME' ) ) : ?>
    104114<p class="description" id="home-description">
    105115                <?php