Changeset 9131
- Timestamp:
- 10/13/2008 06:32:16 PM (16 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/options-general.php
r9032 r9131 12 12 $title = __('General Settings'); 13 13 $parent_file = 'options-general.php'; 14 15 /** 16 * Display JavaScript on the page. 17 * 18 * @package WordPress 19 * @subpackage General_Settings_Panel 20 */ 21 function add_js() { 22 ?> 23 <script type="text/javascript"> 24 //<![CDATA[ 25 jQuery(document).ready(function($){ 26 $("input[name='date_format']").click(function(){ 27 if ( "date_format_custom_radio" != $(this).attr("id") ) 28 $("input[name='date_format_custom']").val( $(this).val() ); 29 }); 30 $("input[name='date_format_custom']").focus(function(){ 31 $("#date_format_custom_radio").attr("checked", "checked"); 32 }); 33 34 $("input[name='time_format']").click(function(){ 35 if ( "time_format_custom_radio" != $(this).attr("id") ) 36 $("input[name='time_format_custom']").val( $(this).val() ); 37 }); 38 $("input[name='time_format_custom']").focus(function(){ 39 $("#time_format_custom_radio").attr("checked", "checked"); 40 }); 41 }); 42 //]]> 43 </script> 44 <?php 45 } 46 add_filter('admin_head', 'add_js'); 14 47 15 48 include('./admin-header.php'); … … 97 130 <tr> 98 131 <th scope="row"><label for="date_format"><?php _e('Date Format') ?></label></th> 99 <td><input name="date_format" type="text" id="date_format" size="30" value="<?php form_option('date_format'); ?>" /><br /> 100 <?php _e('Output:') ?> <strong><?php echo mysql2date(get_option('date_format'), current_time('mysql')); ?></strong></td> 132 <td> 133 <fieldset><legend class="hidden"><?php _e('Date Format') ?></legend> 134 <?php 135 136 $date_formats = apply_filters( 'date_formats', array( 137 __('F j, Y'), 138 'Y/m/d', 139 'm/d/Y', 140 'd/m/Y', 141 ) ); 142 143 $custom = TRUE; 144 145 foreach ( $date_formats as $format ) { 146 echo "\t<label title='" . attribute_escape($format) . "'><input type='radio' name='date_format' value='" . attribute_escape($format) . "'"; 147 if ( get_option('date_format') === $format ) { // checked() uses "==" rather than "===" 148 echo " checked='checked'"; 149 $custom = FALSE; 150 } 151 echo ' /> ' . gmdate( $format, current_time('timestamp') ) . "</label><br />\n"; 152 } 153 154 echo ' <label><input type="radio" name="date_format" id="date_format_custom_radio" value="\c\u\s\t\o\m"'; 155 checked( $custom, TRUE ); 156 echo '/> ' . __('Custom') . ': </label><input type="text" name="date_format_custom" value="' . attribute_escape( get_option('date_format') ) . '" size="30" /> ' . gmdate( get_option('date_format'), current_time('timestamp') ) . "</label>\n"; 157 158 echo "\t<p>" . __('<a href="http://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date formatting</a>. Click "Save Changes" to update sample output.') . "</p>\n"; 159 ?> 160 </fieldset> 161 </td> 101 162 </tr> 102 163 <tr> 103 164 <th scope="row"><label for="time_format"><?php _e('Time Format') ?></label></th> 104 <td><input name="time_format" type="text" id="time_format" size="30" value="<?php form_option('time_format'); ?>" /><br /> 105 <?php _e('Output:') ?> <strong><?php echo gmdate(get_option('time_format'), current_time('timestamp')); ?></strong><br /> 106 <?php _e('<a href="http://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date formatting</a>. Click "Save Changes" to update sample output.') ?></td> 165 <td> 166 <fieldset><legend class="hidden"><?php _e('Time Format') ?></legend> 167 <?php 168 169 $time_formats = apply_filters( 'time_formats', array( 170 __('g:i a'), 171 'g:i A', 172 'H:i', 173 ) ); 174 175 $custom = TRUE; 176 177 foreach ( $time_formats as $format ) { 178 echo "\t<label title='" . attribute_escape($format) . "'><input type='radio' name='time_format' value='" . attribute_escape($format) . "'"; 179 if ( get_option('time_format') === $format ) { // checked() uses "==" rather than "===" 180 echo " checked='checked'"; 181 $custom = FALSE; 182 } 183 echo ' /> ' . gmdate( $format, current_time('timestamp') ) . "</label><br />\n"; 184 } 185 186 echo ' <label><input type="radio" name="time_format" id="time_format_custom_radio" value="\c\u\s\t\o\m"'; 187 checked( $custom, TRUE ); 188 echo '/> ' . __('Custom') . ': </label><input type="text" name="time_format_custom" value="' . attribute_escape( get_option('time_format') ) . '" size="30" /> ' . gmdate( get_option('time_format'), current_time('timestamp') ) . "</label>\n"; 189 ?> 190 </fieldset> 191 </td> 107 192 </tr> 108 193 <tr> -
trunk/wp-admin/options.php
r9066 r9131 42 42 43 43 case 'update': 44 $any_changed = 0;45 46 44 $option_page = $_POST[ 'option_page' ]; 47 45 check_admin_referer( $option_page . '-options' ); … … 50 48 wp_die( __( 'Error! Options page not found.' ) ); 51 49 52 if ( $option_page == 'options') {50 if ( 'options' == $option_page ) { 53 51 $options = explode(',', stripslashes( $_POST[ 'page_options' ] )); 54 52 } else { … … 56 54 } 57 55 58 if ($options) { 59 foreach ($options as $option) { 56 // Handle custom date/time formats 57 if ( 'general' == $option_page ) { 58 if ( !empty($_POST['date_format']) && !empty($_POST['date_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['date_format'] ) ) 59 $_POST['date_format'] = $_POST['date_format_custom']; 60 if ( !empty($_POST['time_format']) && !empty($_POST['time_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['time_format'] ) ) 61 $_POST['time_format'] = $_POST['time_format_custom']; 62 } 63 64 if ( $options ) { 65 foreach ( $options as $option ) { 60 66 $option = trim($option); 61 67 $value = $_POST[$option]; 62 if (!is_array($value))$value = trim($value);68 if ( !is_array($value) ) $value = trim($value); 63 69 $value = stripslashes_deep($value); 64 70 update_option($option, $value); … … 66 72 } 67 73 68 $goback = add_query_arg( 'updated', 'true', wp_get_referer());69 wp_redirect( $goback);70 74 $goback = add_query_arg( 'updated', 'true', wp_get_referer() ); 75 wp_redirect( $goback ); 76 break; 71 77 72 78 default:
Note: See TracChangeset
for help on using the changeset viewer.