Ticket #15691: 15691.patch
| File 15691.patch, 7.7 KB (added by , 15 years ago) |
|---|
-
wp-admin/includes/misc.php
593 593 </fieldset> 594 594 <?php 595 595 } 596 597 /** 598 * Process settings submitted by the Settings API. 599 * 600 * @since 3.2.0 601 * 602 * @global array $whitelist_options A whitelist of permitted settings fields 603 * @param string $option_page The id of the panel that submitted the settings 604 */ 605 function process_settings( $option_page ) { 606 global $whitelist_options; 607 608 if ( 'options' == $option_page && !isset( $_POST['option_page'] ) ) { // This is for back compat and will eventually be removed. 609 $unregistered = true; 610 check_admin_referer( 'update-options' ); 611 } else { 612 $unregistered = false; 613 check_admin_referer( $option_page . '-options' ); 614 } 615 616 if ( !isset( $whitelist_options[ $option_page ] ) ) 617 wp_die( __( 'Error: options page not found.' ) ); 618 619 if ( 'options' == $option_page ) { 620 if ( is_multisite() && ! is_super_admin() ) 621 wp_die( __( 'You do not have sufficient permissions to modify unregistered settings for this site.' ) ); 622 $options = explode( ',', stripslashes( $_POST[ 'page_options' ] ) ); 623 } else { 624 $options = $whitelist_options[ $option_page ]; 625 } 626 627 // Handle custom date/time formats 628 if ( 'general' == $option_page ) { 629 if ( !empty($_POST['date_format']) && isset($_POST['date_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['date_format'] ) ) 630 $_POST['date_format'] = $_POST['date_format_custom']; 631 if ( !empty($_POST['time_format']) && isset($_POST['time_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['time_format'] ) ) 632 $_POST['time_format'] = $_POST['time_format_custom']; 633 // Map UTC+- timezones to gmt_offsets and set timezone_string to empty. 634 if ( !empty($_POST['timezone_string']) && preg_match('/^UTC[+-]/', $_POST['timezone_string']) ) { 635 $_POST['gmt_offset'] = $_POST['timezone_string']; 636 $_POST['gmt_offset'] = preg_replace('/UTC\+?/', '', $_POST['gmt_offset']); 637 $_POST['timezone_string'] = ''; 638 } 639 } 640 641 if ( $options ) { 642 foreach ( $options as $option ) { 643 if ( $unregistered ) 644 _deprecated_argument( 'options.php', '2.7', sprintf( __( 'The <code>%1$s</code> setting is unregistered. Unregistered settings are deprecated. See http://codex.wordpress.org/Settings_API' ), $option, $option_page ) ); 645 646 $option = trim($option); 647 $value = null; 648 if ( isset($_POST[$option]) ) 649 $value = $_POST[$option]; 650 if ( !is_array($value) ) 651 $value = trim($value); 652 $value = stripslashes_deep($value); 653 654 if ( is_network_admin() ) 655 update_site_option( $option, $value ); 656 else 657 update_option( $option, $value ); 658 } 659 } 660 661 /** 662 * Handle settings errors and return to the originating page 663 */ 664 // If no settings errors were registered add a general 'updated' message. 665 if ( !count( get_settings_errors() ) ) 666 add_settings_error('general', 'settings_updated', __('Settings saved.'), 'updated'); 667 set_transient('settings_errors', get_settings_errors(), 30); 668 669 /** 670 * Redirect back to the settings page that was submitted 671 */ 672 $goback = add_query_arg( 'settings-updated', 'true', wp_get_referer() ); 673 wp_redirect( $goback ); 674 exit; 675 } 596 676 ?> -
wp-admin/includes/template.php
1137 1137 } 1138 1138 1139 1139 /** 1140 * Echoes the output of get_settings_form_action() 1141 * 1142 * @since 3.2.0 1143 */ 1144 function settings_form_action() { 1145 echo get_settings_form_action(); 1146 } 1147 1148 /** 1149 * Gets the proper form action for a settings screen 1150 * 1151 * On a single Site Admin, settings should be saved to options.php. On the Network Admin, settings 1152 * are saved by edit.php?action=pluginoptions. 1153 * 1154 * @since 3.2.0 1155 * 1156 * @return string $action The form action 1157 */ 1158 function get_settings_form_action() { 1159 $action = is_network_admin() ? network_admin_url( 'edit.php?action=pluginoptions' ) : admin_url( 'options.php' ); 1160 return apply_filters( 'settings_form_action', $action ); 1161 } 1162 1163 /** 1140 1164 * Prints out all settings sections added to a particular settings page 1141 1165 * 1142 1166 * Part of the Settings API. Use this in a settings page callback function -
wp-admin/network/edit.php
165 165 exit(); 166 166 break; 167 167 168 case 'pluginoptions': 169 wp_reset_vars (array( 'option_page' ) ); 170 $whitelist_options = apply_filters( 'whitelist_options', array() ); 171 172 process_settings( $option_page ); 173 break; 174 168 175 case 'updateblog': 169 176 // No longer used. 170 177 break; -
wp-admin/options.php
97 97 * If $_GET['action'] == 'update' we are saving settings sent from a settings page 98 98 */ 99 99 if ( 'update' == $action ) { 100 if ( 'options' == $option_page && !isset( $_POST['option_page'] ) ) { // This is for back compat and will eventually be removed. 101 $unregistered = true; 102 check_admin_referer( 'update-options' ); 103 } else { 104 $unregistered = false; 105 check_admin_referer( $option_page . '-options' ); 106 } 107 108 if ( !isset( $whitelist_options[ $option_page ] ) ) 109 wp_die( __( 'Error: options page not found.' ) ); 110 111 if ( 'options' == $option_page ) { 112 if ( is_multisite() && ! is_super_admin() ) 113 wp_die( __( 'You do not have sufficient permissions to modify unregistered settings for this site.' ) ); 114 $options = explode( ',', stripslashes( $_POST[ 'page_options' ] ) ); 115 } else { 116 $options = $whitelist_options[ $option_page ]; 117 } 118 119 // Handle custom date/time formats 120 if ( 'general' == $option_page ) { 121 if ( !empty($_POST['date_format']) && isset($_POST['date_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['date_format'] ) ) 122 $_POST['date_format'] = $_POST['date_format_custom']; 123 if ( !empty($_POST['time_format']) && isset($_POST['time_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['time_format'] ) ) 124 $_POST['time_format'] = $_POST['time_format_custom']; 125 // Map UTC+- timezones to gmt_offsets and set timezone_string to empty. 126 if ( !empty($_POST['timezone_string']) && preg_match('/^UTC[+-]/', $_POST['timezone_string']) ) { 127 $_POST['gmt_offset'] = $_POST['timezone_string']; 128 $_POST['gmt_offset'] = preg_replace('/UTC\+?/', '', $_POST['gmt_offset']); 129 $_POST['timezone_string'] = ''; 130 } 131 } 132 133 if ( $options ) { 134 foreach ( $options as $option ) { 135 if ( $unregistered ) 136 _deprecated_argument( 'options.php', '2.7', sprintf( __( 'The <code>%1$s</code> setting is unregistered. Unregistered settings are deprecated. See http://codex.wordpress.org/Settings_API' ), $option, $option_page ) ); 137 138 $option = trim($option); 139 $value = null; 140 if ( isset($_POST[$option]) ) 141 $value = $_POST[$option]; 142 if ( !is_array($value) ) 143 $value = trim($value); 144 $value = stripslashes_deep($value); 145 update_option($option, $value); 146 } 147 } 148 149 /** 150 * Handle settings errors and return to options page 151 */ 152 // If no settings errors were registered add a general 'updated' message. 153 if ( !count( get_settings_errors() ) ) 154 add_settings_error('general', 'settings_updated', __('Settings saved.'), 'updated'); 155 set_transient('settings_errors', get_settings_errors(), 30); 156 157 /** 158 * Redirect back to the settings page that was submitted 159 */ 160 $goback = add_query_arg( 'settings-updated', 'true', wp_get_referer() ); 161 wp_redirect( $goback ); 162 exit; 100 process_settings( $option_page ); 163 101 } 164 102 165 103 include('./admin-header.php'); ?>