Ticket #7665: patch-jquery-date-and-time-picker2.diff
File patch-jquery-date-and-time-picker2.diff, 29.6 KB (added by , 13 years ago) |
---|
-
wp-includes/functions.php
142 142 } 143 143 144 144 /** 145 * Builds a regular expression allowing to match a date formatted according to the specified format 146 * 147 * @param string Format of the date 148 * @param string Regular expression delimiters 149 * @return bool|string a string representing the built regular expression, or false in case of an error or if no format element is used 150 */ 151 function build_date_parse_regexp_from_format( $format, $delimiter = '/' ) { 152 // Regular expressions used to parse the date 153 $replacements = array( 154 'd' => '([0-2][0-9]|3[0-1])', 155 'D' => '(Sun|Mon|Tue|Wed|Thu|Fri|Sat)', 156 'j' => '([1-9]|[1-2][0-9]|3[0-1])', 157 'l' => '(Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday)', 158 'S' => '(st|nd|rd|th)', 159 'z' => '(\d{1,3})', 160 'F' => '(January|February|March|April|May|June|July|August|September|October|November|December)', 161 'M' => '(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)', 162 'm' => '(0[1-9]|1[0-2])', 163 'n' => '([1-9]|1[0-2])', 164 'Y' => '(\d{4})', 165 'y' => '(\d{2})', 166 'a' => '(am|pm)', 167 'A' => '(AM|PM)', 168 'g' => '([0-9]|1[0-2])', 169 'h' => '(0[0-9]|1[0-2])', 170 'G' => '([0-9]|1[0-9]|2[0-3])', 171 'H' => '([0-1][0-9]|2[0-3])', 172 'i' => '([0-5][0-9])', 173 's' => '([0-5][0-9])', 174 'u' => '(\d{1,6})', 175 'U' => '(\d{1,10})', 176 'e' => '([a-zA-Z-\/]+(?:\+\d+)?)', 177 'O' => '((?:\+|-)\d{4})', 178 'P' => '((?:\+|-)\d{2}:\d{2})', 179 'T' => '([A-Z]+)', 180 ); 181 182 // Looking for used format elements 183 $parsed_format = $format; 184 $used_replacements = array(); 185 foreach ( $replacements as $k => $v ) { 186 if ( ( $p = strpos( $format, $k ) ) !== false ) { 187 $parsed_format = str_replace( $k, "%{$k}%", $parsed_format ); 188 $used_replacements[$k] = $v; 189 } 190 } 191 192 if ( !empty( $used_replacements ) ) { 193 // Computing sources elements to create the regular expression 194 $replacement_keys = array_map( create_function( '$a', 'return "%{$a}%";' ), array_keys( $used_replacements ) ); 195 196 // Building the regular expression 197 return $delimiter . '^' . str_replace( '/', '\/', str_replace( $replacement_keys, array_values( $used_replacements ), $parsed_format ) ) . '$' . $delimiter; 198 } 199 else 200 return false; 201 } 202 203 /** 204 * Get info about given date formatted according to the specified format 205 * 206 * This function is a placeholder for the PHP 5.3+ date_parse_from_format() function. 207 * Please visit the official function documentation for further information : 208 * http://fr.php.net/manual/fr/function.date-parse-from-format.php 209 * 210 * This function differs from its original version in its return values : 211 * it returns false in case of an error instead of including errors in the returned array 212 * and it does not support format modifiers such as '+' or '!' (yet) 213 * 214 * @param string Format of the date 215 * @param string Date to parse 216 * @return bool|array an array containing the date components, or false in case of an error 217 */ 218 if ( !function_exists( 'date_parse_from_format' ) ) 219 { 220 function date_parse_from_format( $format, $date ) { 221 // Regular expressions used to parse the date 222 $replacements = array( 223 'd' => '([0-2][0-9]|3[0-1])', 224 'D' => array( 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ), 225 'j' => '([1-9]|[1-2][0-9]|3[0-1])', 226 'l' => array( 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ), 227 'S' => array( 'st', 'nd', 'rd', 'th' ), 228 'z' => '(\d{1,3})', 229 'F' => array( 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ), 230 'M' => array( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ), 231 'm' => '(0[1-9]|1[0-2])', 232 'n' => '([1-9]|1[0-2])', 233 'Y' => '(\d{4})', 234 'y' => '(\d{2})', 235 'a' => '(am|pm)', 236 'A' => array( 'AM', 'PM' ), 237 'g' => '([0-9]|1[0-2])', 238 'h' => '(0[0-9]|1[0-2])', 239 'G' => '([0-9]|1[0-9]|2[0-3])', 240 'H' => '([0-1][0-9]|2[0-3])', 241 'i' => '([0-5][0-9])', 242 's' => '([0-5][0-9])', 243 'u' => '(\d{1,6})', 244 'U' => '(\d{1,10})', 245 'e' => '([a-zA-Z-\/]+(?:\+\d+)?)', 246 'O' => '((?:\+|-)\d{4})', 247 'P' => '((?:\+|-)\d{2}:\d{2})', 248 'T' => '([A-Z]+)', 249 ); 250 251 // Looking for used format elements 252 $parsed_format = $format; 253 $used_replacements = array(); 254 $used_replacements_indices = array(); 255 foreach ( $replacements as $k => $v ) { 256 if ( ( $p = strpos( $format, $k ) ) !== false ) { 257 $parsed_format = str_replace( $k, "%{$k}%", $parsed_format ); 258 $used_replacements[$k] = $v; 259 $used_replacements_indices[$p] = $k; 260 } 261 } 262 263 // If a format element has been found 264 if ( !empty( $used_replacements ) ) { 265 // Sort format elements to be in the same order as the results of the regular expression 266 ksort( $used_replacements_indices ); 267 268 // Computing sources and replacements elements to create the regular expression 269 $replacement_keys = array_map( create_function( '$a', 'return "%{$a}%";' ), array_keys( $used_replacements ) ); 270 $replacement_values = array_map( create_function( '$a', 'return is_array($a) ? ("(" . implode("|", $a) . ")") : $a;' ), array_values( $used_replacements ) ); 271 272 // Applying the regular expression 273 $regexp = '/^' . str_replace( '/', '\/', str_replace( $replacement_keys, $replacement_values, $parsed_format ) ) . '$/'; 274 if ( !preg_match( $regexp, $date, $regs ) ) 275 return false; 276 277 // Retrieving regular expression result for each format element 278 $members = array(); 279 $i = 1; 280 foreach ( $used_replacements_indices as $v ) { 281 $members[$v] = $regs[$i++]; 282 } 283 284 // Computing results 285 $result = array( 286 'day' => false, 287 'month' => false, 288 'year' => false, 289 'hour' => 0, 290 'minute' => 0, 291 'second' => 0, 292 'fraction' => false 293 ); 294 foreach ( $members as $k => $v ) { 295 switch ($k) 296 { 297 case 'd': 298 case 'j': 299 $result['day'] = intval( $v ); 300 break; 301 302 case 'M': 303 case 'F': 304 $result['month'] = array_search( $v, $replacements[$k] ) + 1; 305 break; 306 307 case 'm': 308 case 'n': 309 $result['month'] = intval( $v ); 310 break; 311 312 case 'Y': 313 $result['year'] = intval( $v ); 314 break; 315 316 case 'y': 317 $result['year'] = intval( $v ); 318 if ( $result['year'] < 70 ) 319 $result['year'] += 2000; 320 else 321 $result['year'] += 1900; 322 break; 323 324 case 'H': 325 case 'h': 326 $result['hour'] = intval( $v ); 327 if ( ( !empty( $members['a'] ) && $members['a'] == 'pm' ) || ( !empty( $members['A'] ) && $members['A'] == 'PM' ) ) 328 $result['hour'] += 12; 329 break; 330 331 case 'i': 332 $result['minute'] = intval( $v ); 333 break; 334 335 case 's': 336 $result['second'] = intval( $v ); 337 break; 338 339 case 'u': 340 $result['fraction'] = floatval( $v ); 341 break; 342 343 case 'U': 344 $ts = intval($v); 345 $result['day'] = date( 'j', $ts ); 346 $result['month'] = date( 'n', $ts ); 347 $result['year'] = date( 'Y', $ts ); 348 $result['hour'] = date( 'G', $ts ); 349 $result['minute'] = date( 'i', $ts ); 350 $result['second'] = date( 's', $ts ); 351 $result = array_map( 'intval', $result ); 352 break; 353 } 354 } 355 return $result; 356 } 357 else 358 return false; 359 } 360 } 361 362 /** 145 363 * Convert integer number to format based on the locale. 146 364 * 147 365 * @since 2.3.0 -
wp-includes/script-loader.php
68 68 $scripts->add_data( 'common', 'group', 1 ); 69 69 $scripts->localize( 'common', 'commonL10n', array( 70 70 'warnDelete' => __("You are about to permanently delete the selected items.\n 'Cancel' to stop, 'OK' to delete."), 71 'l10n_print_after' => 'try{convertEntities(commonL10n);}catch(e){};' 71 'l10n_print_after' => 'try{convertEntities(commonL10n);}catch(e){};', 72 73 'datePicker_dateFormat' => __('mm/dd/yy'), 74 'datePicker_firstDay' => get_option('start_of_week'), 75 76 'timePicker_hourText' => __('Hour'), 77 'timePicker_minuteText' => __('Minute'), 78 79 'date_regexp' => str_replace( '\\', '\\\\', build_date_parse_regexp_from_format( __('m/d/Y'), '' ) ), 80 'date_components_order' => __('month,day,year'), 81 'time_regexp' => str_replace( '\\', '\\\\', build_date_parse_regexp_from_format( __('H:i'), '' ) ) 72 82 ) ); 73 83 74 84 $scripts->add( 'sack', "/wp-includes/js/tw-sack$suffix.js", false, '1.6.1' ); … … 164 174 165 175 $scripts->add( 'jquery-ui-dialog', '/wp-includes/js/jquery/ui.dialog.js', array('jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-button', 'jquery-ui-position'), '1.8.12' ); 166 176 $scripts->add_data( 'jquery-ui-dialog', 'group', 1 ); 177 178 $scripts->add( 'jquery-ui-timepicker', '/wp-includes/js/jquery/ui.timepicker.js', array('jquery-ui-core'), '0.2.3' ); 179 $scripts->add_data( 'jquery-ui-timepicker', 'group', 1 ); 167 180 181 $scripts->add( 'jquery-ui-datepicker', '/wp-includes/js/jquery/ui.datepicker.js', array('jquery-ui-core'), '1.8.12' ); 182 $scripts->add_data( 'jquery-ui-datepicker', 'group', 1 ); 183 184 $locale_chunks = explode( '_', get_locale() ); 185 $jquery_datepicker_language_file = '/wp-includes/js/jquery/ui.datepicker.i18n/jquery.ui.datepicker-' . implode( '-', $locale_chunks ) . '.js'; 186 if ( !file_exists( ABSPATH . $jquery_datepicker_language_file ) ) { 187 $jquery_datepicker_language_file = '/wp-includes/js/jquery/ui.datepicker.i18n/jquery.ui.datepicker-' . $locale_chunks[0] . '.js'; 188 if ( !file_exists( ABSPATH . $jquery_datepicker_language_file ) ) 189 unset( $jquery_datepicker_language_file ); 190 } 191 if ( !empty( $jquery_datepicker_language_file ) ) { 192 $scripts->add( 'jquery-ui-datepicker-i18n', $jquery_datepicker_language_file, array('jquery-ui-core', 'jquery-ui-datepicker'), '1.8.12' ); 193 $scripts->add_data( 'jquery-ui-datepicker-i18n', 'group', 1 ); 194 } 195 168 196 // deprecated, not used in core, most functionality is included in jQuery 1.3 169 197 $scripts->add( 'jquery-form', "/wp-includes/js/jquery/jquery.form$suffix.js", array('jquery'), '2.73'); 170 198 $scripts->add_data( 'jquery-form', 'group', 1 ); … … 516 544 $styles->add( 'admin-bar', "/wp-includes/css/admin-bar$suffix.css", array(), '20110622' ); 517 545 $styles->add( 'wp-jquery-ui-dialog', "/wp-includes/css/jquery-ui-dialog$suffix.css", array(), '20101224' ); 518 546 $styles->add( 'wplink', "/wp-includes/js/tinymce/plugins/wplink/css/wplink$suffix.css", array(), '20101224' ); 547 $styles->add( 'jquery-ui-core', "/wp-includes/css/jquery-ui-core.css", array(), '20110717' ); 548 $styles->add( 'jquery-ui-theme', "/wp-includes/css/jquery-ui-theme.css", array(), '20110717' ); 549 $styles->add( 'jquery-ui-timepicker', "/wp-includes/css/jquery-ui-timepicker.css", array(), '20110622' ); 550 $styles->add( 'jquery-ui-datepicker', "/wp-includes/css/jquery-ui-datepicker.css", array(), '20110717' ); 519 551 520 552 foreach ( $rtl_styles as $rtl_style ) { 521 553 $styles->add_data( $rtl_style, 'rtl', true ); -
wp-admin/includes/post.php
101 101 if (!isset( $post_data['ping_status'] )) 102 102 $post_data['ping_status'] = 'closed'; 103 103 104 foreach ( array(' aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) {104 foreach ( array('dd', 'tt') as $timeunit ) { 105 105 if ( !empty( $post_data['hidden_' . $timeunit] ) && $post_data['hidden_' . $timeunit] != $post_data[$timeunit] ) { 106 106 $post_data['edit_date'] = '1'; 107 107 break; … … 109 109 } 110 110 111 111 if ( !empty( $post_data['edit_date'] ) ) { 112 $aa = $post_data['aa']; 113 $mm = $post_data['mm']; 114 $jj = $post_data['jj']; 115 $hh = $post_data['hh']; 116 $mn = $post_data['mn']; 117 $ss = $post_data['ss']; 118 $aa = ($aa <= 0 ) ? date('Y') : $aa; 119 $mm = ($mm <= 0 ) ? date('n') : $mm; 120 $jj = ($jj > 31 ) ? 31 : $jj; 121 $jj = ($jj <= 0 ) ? date('j') : $jj; 122 $hh = ($hh > 23 ) ? $hh -24 : $hh; 123 $mn = ($mn > 59 ) ? $mn -60 : $mn; 124 $ss = ($ss > 59 ) ? $ss -60 : $ss; 125 $post_data['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss ); 126 $post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_date'] ); 112 $date_str = sprintf( '%s %s', trim( $post_data['dd'] ), trim( $post_data['tt'] ) ); 113 $date_format_str = sprintf( '%s H:i', __( 'm/d/Y' ) ); 114 $result = date_parse_from_format( $date_format_str, $date_str ); 115 if ( !empty( $result ) && empty( $result['warning_count'] ) && empty( $result['error_count'] ) ) { 116 $aa = $result['year']; 117 $mm = $result['month']; 118 $jj = $result['day']; 119 $hh = $result['hour']; 120 $mn = $result['minute']; 121 $ss = $post_data['ss']; 122 $aa = ($aa <= 0 ) ? date('Y') : $aa; 123 $mm = ($mm <= 0 ) ? date('n') : $mm; 124 $jj = ($jj > 31 ) ? 31 : $jj; 125 $jj = ($jj <= 0 ) ? date('j') : $jj; 126 $hh = ($hh > 23 ) ? $hh -24 : $hh; 127 $mn = ($mn > 59 ) ? $mn -60 : $mn; 128 $ss = ($ss > 59 ) ? $ss -60 : $ss; 129 $post_data['post_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss ); 130 $post_data['post_date_gmt'] = get_gmt_from_date( $post_data['post_date'] ); 131 } 127 132 } 128 133 129 134 return $post_data; -
wp-admin/includes/comment.php
43 43 $_POST['comment_content'] = $_POST['content']; 44 44 $_POST['comment_ID'] = (int) $_POST['comment_ID']; 45 45 46 foreach ( array (' aa', 'mm', 'jj', 'hh', 'mn') as $timeunit ) {46 foreach ( array ('dd', 'tt') as $timeunit ) { 47 47 if ( !empty( $_POST['hidden_' . $timeunit] ) && $_POST['hidden_' . $timeunit] != $_POST[$timeunit] ) { 48 48 $_POST['edit_date'] = '1'; 49 49 break; … … 51 51 } 52 52 53 53 if ( !empty ( $_POST['edit_date'] ) ) { 54 $aa = $_POST['aa']; 55 $mm = $_POST['mm']; 56 $jj = $_POST['jj']; 57 $hh = $_POST['hh']; 58 $mn = $_POST['mn']; 59 $ss = $_POST['ss']; 60 $jj = ($jj > 31 ) ? 31 : $jj; 61 $hh = ($hh > 23 ) ? $hh -24 : $hh; 62 $mn = ($mn > 59 ) ? $mn -60 : $mn; 63 $ss = ($ss > 59 ) ? $ss -60 : $ss; 64 $_POST['comment_date'] = "$aa-$mm-$jj $hh:$mn:$ss"; 54 $date_str = sprintf( '%s %s', trim( $_POST['dd'] ), trim( $_POST['tt'] ) ); 55 $date_format_str = sprintf( '%s H:i', __( 'm/d/Y' ) ); 56 $result = date_parse_from_format( $date_format_str, $date_str ); 57 58 if ( !empty( $result ) && empty( $result['warning_count'] ) && empty( $result['error_count'] ) ) { 59 $aa = $result['year']; 60 $mm = $result['month']; 61 $jj = $result['day']; 62 $hh = $result['hour']; 63 $mn = $result['minute']; 64 $ss = $_POST['ss']; 65 $aa = ($aa <= 0 ) ? date('Y') : $aa; 66 $mm = ($mm <= 0 ) ? date('n') : $mm; 67 $jj = ($jj > 31 ) ? 31 : $jj; 68 $jj = ($jj <= 0 ) ? date('j') : $jj; 69 $hh = ($hh > 23 ) ? $hh -24 : $hh; 70 $mn = ($mn > 59 ) ? $mn -60 : $mn; 71 $ss = ($ss > 59 ) ? $ss -60 : $ss; 72 $_POST['comment_date'] = sprintf( "%04d-%02d-%02d %02d:%02d:%02d", $aa, $mm, $jj, $hh, $mn, $ss ); 73 } 65 74 } 66 75 67 76 wp_update_comment( $_POST ); -
wp-admin/includes/template.php
280 280 <div class="comment_status">' . esc_html( $post->comment_status ) . '</div> 281 281 <div class="ping_status">' . esc_html( $post->ping_status ) . '</div> 282 282 <div class="_status">' . esc_html( $post->post_status ) . '</div> 283 <div class="jj">' . mysql2date( 'd', $post->post_date, false ) . '</div> 284 <div class="mm">' . mysql2date( 'm', $post->post_date, false ) . '</div> 285 <div class="aa">' . mysql2date( 'Y', $post->post_date, false ) . '</div> 286 <div class="hh">' . mysql2date( 'H', $post->post_date, false ) . '</div> 287 <div class="mn">' . mysql2date( 'i', $post->post_date, false ) . '</div> 283 <div class="dd">' . mysql2date( __('m/d/Y'), $post->post_date, false ) . '</div> 284 <div class="tt">' . mysql2date( 'H:i', $post->post_date, false ) . '</div> 288 285 <div class="ss">' . mysql2date( 's', $post->post_date, false ) . '</div> 289 286 <div class="post_password">' . esc_html( $post->post_password ) . '</div>'; 290 287 … … 598 595 599 596 $time_adj = current_time('timestamp'); 600 597 $post_date = ($for_post) ? $post->post_date : $comment->comment_date; 601 $jj = ($edit) ? mysql2date( 'd', $post_date, false ) : gmdate( 'd', $time_adj ); 602 $mm = ($edit) ? mysql2date( 'm', $post_date, false ) : gmdate( 'm', $time_adj ); 603 $aa = ($edit) ? mysql2date( 'Y', $post_date, false ) : gmdate( 'Y', $time_adj ); 604 $hh = ($edit) ? mysql2date( 'H', $post_date, false ) : gmdate( 'H', $time_adj ); 605 $mn = ($edit) ? mysql2date( 'i', $post_date, false ) : gmdate( 'i', $time_adj ); 606 $ss = ($edit) ? mysql2date( 's', $post_date, false ) : gmdate( 's', $time_adj ); 598 599 $date_format = __('m/d/Y'); 600 $dd = ($edit) ? mysql2date($date_format, $post_date, false) : gmdate($date_format, $time_adj); 601 $tt = ($edit) ? mysql2date('H:i', $post_date, false) : gmdate('H:i', $time_adj); 602 $ss = ($edit) ? mysql2date('s', $post_date, false) : gmdate('s', $time_adj); 603 604 $cur_dd = gmdate($date_format, $time_adj); 605 $cur_tt = gmdate('H:i', $time_adj); 607 606 608 $cur_jj = gmdate( 'd', $time_adj ); 609 $cur_mm = gmdate( 'm', $time_adj ); 610 $cur_aa = gmdate( 'Y', $time_adj ); 611 $cur_hh = gmdate( 'H', $time_adj ); 612 $cur_mn = gmdate( 'i', $time_adj ); 607 $date = '<input type="text" ' . ($multi ? '' : 'id="dd"') . ' name="dd" value="' . $dd . '" size="10" maxlength="10"' . $tab_index_attribute . ' autocomplete="off" class="datepicker" />'; 608 $time = '<input type="text" ' . ($multi ? '' : 'id="tt"') . ' name="tt" value="' . $tt . '" size="10" maxlength="10"' . $tab_index_attribute . ' autocomplete="off" class="timepicker" />'; 613 609 614 $month = "<select " . ( $multi ? '' : 'id="mm" ' ) . "name=\"mm\"$tab_index_attribute>\n";615 for ( $i = 1; $i < 13; $i = $i +1 ) {616 $month .= "\t\t\t" . '<option value="' . zeroise($i, 2) . '"';617 if ( $i == $mm )618 $month .= ' selected="selected"';619 $month .= '>' . $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) . "</option>\n";620 }621 $month .= '</select>';622 623 $day = '<input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';624 $year = '<input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" />';625 $hour = '<input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';626 $minute = '<input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" />';627 628 610 echo '<div class="timestamp-wrap">'; 629 /* translators: 1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input */ 630 printf(__('%1$s%2$s, %3$s @ %4$s : %5$s'), $month, $day, $year, $hour, $minute); 611 printf(__('Date %s @ %s'), $date, $time); 631 612 632 613 echo '</div><input type="hidden" id="ss" name="ss" value="' . $ss . '" />'; 633 614 634 615 if ( $multi ) return; 635 616 636 617 echo "\n\n"; 637 foreach ( array(' mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) {618 foreach ( array('dd', 'tt') as $timeunit ) { 638 619 echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n"; 639 620 $cur_timeunit = 'cur_' . $timeunit; 640 621 echo '<input type="hidden" id="'. $cur_timeunit . '" name="'. $cur_timeunit . '" value="' . $$cur_timeunit . '" />' . "\n"; … … 645 626 <a href="#edit_timestamp" class="save-timestamp hide-if-no-js button"><?php _e('OK'); ?></a> 646 627 <a href="#edit_timestamp" class="cancel-timestamp hide-if-no-js"><?php _e('Cancel'); ?></a> 647 628 </p> 629 630 <script type="text/javascript"> 631 <!-- 632 jQuery(document).ready( function() { 633 setupDateAndTimePickers(false); 634 } ); 635 //--> 636 </script> 648 637 <?php 649 638 } 650 639 -
wp-admin/js/comment.dev.js
11 11 12 12 $('.cancel-timestamp').click(function() { 13 13 $('#timestampdiv').slideUp("normal"); 14 $('#mm').val($('#hidden_mm').val()); 15 $('#jj').val($('#hidden_jj').val()); 16 $('#aa').val($('#hidden_aa').val()); 17 $('#hh').val($('#hidden_hh').val()); 18 $('#mn').val($('#hidden_mn').val()); 14 $('#dd').val($('#hidden_dd').val()); 15 $('#tt').val($('#hidden_tt').val()); 19 16 $('#timestamp').html(stamp); 20 17 $('.edit-timestamp').show(); 21 18 return false; 22 19 }); 23 20 24 21 $('.save-timestamp').click(function () { // crazyhorse - multiple ok cancels 25 var aa = $('#aa').val(), mm = $('#mm').val(), jj = $('#jj').val(), hh = $('#hh').val(), mn = $('#mn').val(), 26 newD = new Date( aa, mm - 1, jj, hh, mn ); 22 var dateRE = new RegExp(commonL10n.date_regexp); 23 var dateCompOrder = commonL10n.date_components_order.split(','); 24 var timeRE = new RegExp(commonL10n.time_regexp); 25 26 var dd = $('#dd').val(), tt = $('#tt').val(); 27 28 var dateREResult = dateRE.exec(dd); 29 var timeREResult = timeRE.exec(tt); 30 if (dateREResult == null || timeREResult == null) 31 { 32 $('.timestamp-wrap', '#timestampdiv').addClass('form-invalid'); 33 return false; 34 } 35 36 var dateCompIndices = new Object(); 37 for (var i = 0; i < dateCompOrder.length; i++) 38 dateCompIndices[dateCompOrder[i]] = i + 1; 39 40 var newD = new Date(dateREResult[dateCompIndices.year], dateREResult[dateCompIndices.month] - 1, dateREResult[dateCompIndices.day], timeREResult[1], timeREResult[2]); 27 41 28 if ( newD.getFullYear() != aa || (1 + newD.getMonth()) != mm || newD.getDate() != jj || newD.getMinutes() != mn) {42 if ( newD.getFullYear() != dateREResult[dateCompIndices.year] || (1 + newD.getMonth()) != dateREResult[dateCompIndices.month] || newD.getDate() != dateREResult[dateCompIndices.day] || newD.getMinutes() != timeREResult[2] ) { 29 43 $('.timestamp-wrap', '#timestampdiv').addClass('form-invalid'); 30 44 return false; 31 45 } else { … … 34 48 35 49 $('#timestampdiv').slideUp("normal"); 36 50 $('.edit-timestamp').show(); 37 $('#timestamp').html( 38 commentL10n.submittedOn + ' <b>' + 39 $( '#mm option[value="' + mm + '"]' ).text() + ' ' + 40 jj + ', ' + 41 aa + ' @ ' + 42 hh + ':' + 43 mn + '</b> ' 44 ); 51 $('#timestamp').html( commentL10n.submittedOn + ' <b>' + $( '#dd' ).val() + ' @ ' + $( '#tt' ).val() + '</b> ' ); 45 52 return false; 46 53 }); 47 54 }); -
wp-admin/js/post.dev.js
369 369 370 370 function updateText() { 371 371 var attemptedDate, originalDate, currentDate, publishOn, postStatus = $('#post_status'), 372 optPublish = $('option[value="publish"]', postStatus), aa = $('#aa').val(), 373 mm = $('#mm').val(), jj = $('#jj').val(), hh = $('#hh').val(), mn = $('#mn').val(); 372 optPublish = $('option[value="publish"]', postStatus), dd = $('#dd').val(), tt = $('#tt').val(); 374 373 375 attemptedDate = new Date( aa, mm - 1, jj, hh, mn ); 376 originalDate = new Date( $('#hidden_aa').val(), $('#hidden_mm').val() -1, $('#hidden_jj').val(), $('#hidden_hh').val(), $('#hidden_mn').val() ); 377 currentDate = new Date( $('#cur_aa').val(), $('#cur_mm').val() -1, $('#cur_jj').val(), $('#cur_hh').val(), $('#cur_mn').val() ); 374 var dateRE = new RegExp(commonL10n.date_regexp); 375 var dateCompOrder = commonL10n.date_components_order.split(','); 376 var timeRE = new RegExp(commonL10n.time_regexp); 377 378 var dateREResult = dateRE.exec(dd); 379 var hiddenDateREResult = dateRE.exec( $('#hidden_dd').val() ); 380 var curDateREResult = dateRE.exec( $('#cur_dd').val() ); 381 var timeREResult = timeRE.exec(tt); 382 var hiddenTimeREResult = timeRE.exec( $('#hidden_tt').val() ); 383 var curTimeREResult = timeRE.exec( $('#cur_tt').val() ); 384 if (dateREResult == null || hiddenDateREResult == null || curDateREResult == null 385 || timeREResult == null || hiddenTimeREResult == null || curTimeREResult == null) 386 { 387 $('.timestamp-wrap', '#timestampdiv').addClass('form-invalid'); 388 return false; 389 } 378 390 379 if ( attemptedDate.getFullYear() != aa || (1 + attemptedDate.getMonth()) != mm || attemptedDate.getDate() != jj || attemptedDate.getMinutes() != mn ) { 391 var dateCompIndices = new Object(); 392 for (var i = 0; i < dateCompOrder.length; i++) 393 dateCompIndices[dateCompOrder[i]] = i + 1; 394 395 attemptedDate = new Date( dateREResult[dateCompIndices.year], dateREResult[dateCompIndices.month] - 1, dateREResult[dateCompIndices.day], timeREResult[1], timeREResult[2] ); 396 originalDate = new Date( hiddenDateREResult[dateCompIndices.year], hiddenDateREResult[dateCompIndices.month] - 1, hiddenDateREResult[dateCompIndices.day], hiddenTimeREResult[1], hiddenTimeREResult[2] ); 397 currentDate = new Date( curDateREResult[dateCompIndices.year], curDateREResult[dateCompIndices.month] - 1, curDateREResult[dateCompIndices.day], curTimeREResult[1], curTimeREResult[2] ); 398 399 if ( attemptedDate.getFullYear() != dateREResult[dateCompIndices.year] || (1 + attemptedDate.getMonth()) != dateREResult[dateCompIndices.month] || attemptedDate.getDate() != dateREResult[dateCompIndices.day] || attemptedDate.getMinutes() != timeREResult[2] ) { 380 400 $('.timestamp-wrap', '#timestampdiv').addClass('form-invalid'); 381 401 return false; 382 402 } else { … … 393 413 publishOn = postL10n.publishOnPast; 394 414 $('#publish').val( postL10n.update ); 395 415 } 396 if ( originalDate. toUTCString() == attemptedDate.toUTCString() ) { //hack416 if ( originalDate.getTime() == attemptedDate.getTime() ) { 397 417 $('#timestamp').html(stamp); 398 418 } else { 399 $('#timestamp').html( 400 publishOn + ' <b>' + 401 $('option[value="' + $('#mm').val() + '"]', '#mm').text() + ' ' + 402 jj + ', ' + 403 aa + ' @ ' + 404 hh + ':' + 405 mn + '</b> ' 406 ); 419 $('#timestamp').html(publishOn + ' <b>' + $('#dd').val() + ' @ ' + $('#tt').val() + '</b>' ); 407 420 } 408 421 409 422 if ( $('input:radio:checked', '#post-visibility-select').val() == 'private' ) { … … 496 509 497 510 $('.cancel-timestamp', '#timestampdiv').click(function() { 498 511 $('#timestampdiv').slideUp('fast'); 499 $('#mm').val($('#hidden_mm').val()); 500 $('#jj').val($('#hidden_jj').val()); 501 $('#aa').val($('#hidden_aa').val()); 502 $('#hh').val($('#hidden_hh').val()); 503 $('#mn').val($('#hidden_mn').val()); 512 $('#dd').val($('#hidden_dd').val()); 513 $('#tt').val($('#hidden_tt').val()); 504 514 $('#timestampdiv').siblings('a.edit-timestamp').show(); 505 515 updateText(); 506 516 return false; -
wp-admin/js/common.dev.js
368 368 }); 369 369 370 370 })(jQuery); 371 372 function setupDateAndTimePickers(useContext, context) { 373 var ctx = null; 374 if (useContext === true) 375 ctx = jQuery(context); 376 377 jQuery('.datepicker', ctx).datepicker( { 378 dateFormat: commonL10n.datePicker_dateFormat, 379 firstDay: commonL10n.datePicker_firstDay 380 } ); 381 382 jQuery('.timepicker', ctx).timepicker( { 383 hourText: commonL10n.timePicker_hourText, 384 minuteText: commonL10n.timePicker_minuteText, 385 showPeriodLabels: false, 386 minutes: { 387 starts: 0, 388 ends: 0, 389 interval: 1 390 }, 391 rows: 6 392 } ); 393 } -
wp-admin/js/inline-edit-post.dev.js
129 129 if ( typeof(id) == 'object' ) 130 130 id = t.getId(id); 131 131 132 fields = ['post_title', 'post_name', 'post_author', '_status', ' jj', 'mm', 'aa', 'hh', 'mn', 'ss', 'post_password'];132 fields = ['post_title', 'post_name', 'post_author', '_status', 'dd', 'tt', 'ss', 'post_password']; 133 133 if ( t.type == 'page' ) 134 134 fields.push('post_parent', 'menu_order', 'page_template'); 135 135 … … 215 215 $(editRow).attr('id', 'edit-'+id).addClass('inline-editor').show(); 216 216 $('.ptitle', editRow).focus(); 217 217 218 setupDateAndTimePickers(true, editRow); 219 218 220 return false; 219 221 }, 220 222 -
wp-admin/admin-header.php
41 41 wp_admin_css(); 42 42 wp_admin_css( 'colors' ); 43 43 wp_admin_css( 'ie' ); 44 wp_admin_css( 'jquery-ui-core' ); 45 wp_admin_css( 'jquery-ui-theme' ); 46 wp_admin_css( 'jquery-ui-timepicker' ); 47 wp_admin_css( 'jquery-ui-datepicker' ); 44 48 if ( is_multisite() ) 45 49 wp_admin_css( 'ms' ); 46 50 wp_enqueue_script('utils'); 51 wp_enqueue_script( 'jquery-ui-timepicker' ); 52 wp_enqueue_script( 'jquery-ui-datepicker' ); 53 wp_enqueue_script( 'jquery-ui-datepicker-i18n' ); 47 54 48 55 $admin_body_class = preg_replace('/[^a-z0-9_-]+/i', '-', $hook_suffix); 49 56 ?> -
wp-admin/css/wp-admin.dev.css
2104 2104 float: left; 2105 2105 } 2106 2106 2107 .inline-edit-row fieldset input[name=jj], 2108 .inline-edit-row fieldset input[name=hh], 2109 .inline-edit-row fieldset input[name=mn] { 2107 .inline-edit-row fieldset input[name=dd] { 2110 2108 font-size: 12px; 2111 width: 2.1em;2109 width: 10.1em; 2112 2110 } 2113 2111 2112 .inline-edit-row fieldset input[name=tt] { 2113 font-size: 12px; 2114 width: 5.1em; 2115 } 2116 2114 2117 .inline-edit-row fieldset input[name=aa] { 2115 2118 font-size: 12px; 2116 2119 width: 3.5em; … … 2682 2685 vertical-align: top; 2683 2686 } 2684 2687 2685 # jj, #hh, #mn{2686 width: 2em;2688 #dd { 2689 width: 10em; 2687 2690 padding: 1px; 2688 2691 font-size: 12px; 2689 2692 } 2690 2693 2694 #tt { 2695 width: 5em; 2696 padding: 1px; 2697 font-size: 12px; 2698 } 2699 2691 2700 #aa { 2692 2701 width: 3.4em; 2693 2702 padding: 1px;