touch_time( int|bool $edit = 1, int|bool $for_post = 1, int $tab_index, int|bool $multi )
Print out HTML form date elements for editing post or comment publish date.
Description Description
Parameters Parameters
- $edit
-
(int|bool) (Optional) Accepts 1|true for editing the date, 0|false for adding the date.
Default value: 1
- $for_post
-
(int|bool) (Optional) Accepts 1|true for applying the date to a post, 0|false for a comment.
Default value: 1
- $tab_index
-
(int) (Required) The tabindex attribute to add. Default 0.
- $multi
-
(int|bool) (Optional) Whether the additional fields and buttons should be added. Default 0|false.
Source Source
File: wp-admin/includes/template.php
762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 | function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) { global $wp_locale ; $post = get_post(); if ( $for_post ) { $edit = ! ( in_array( $post ->post_status, array ( 'draft' , 'pending' ) ) && ( ! $post ->post_date_gmt || '0000-00-00 00:00:00' == $post ->post_date_gmt ) ); } $tab_index_attribute = '' ; if ( (int) $tab_index > 0 ) { $tab_index_attribute = " tabindex=\"$tab_index\"" ; } // todo: Remove this? // echo '<label for="timestamp" style="display: block;"><input type="checkbox" class="checkbox" name="edit_date" value="1" id="timestamp"'.$tab_index_attribute.' /> '.__( 'Edit timestamp' ).'</label><br />'; $time_adj = current_time( 'timestamp' ); $post_date = ( $for_post ) ? $post ->post_date : get_comment()->comment_date; $jj = ( $edit ) ? mysql2date( 'd' , $post_date , false ) : gmdate ( 'd' , $time_adj ); $mm = ( $edit ) ? mysql2date( 'm' , $post_date , false ) : gmdate ( 'm' , $time_adj ); $aa = ( $edit ) ? mysql2date( 'Y' , $post_date , false ) : gmdate ( 'Y' , $time_adj ); $hh = ( $edit ) ? mysql2date( 'H' , $post_date , false ) : gmdate ( 'H' , $time_adj ); $mn = ( $edit ) ? mysql2date( 'i' , $post_date , false ) : gmdate ( 'i' , $time_adj ); $ss = ( $edit ) ? mysql2date( 's' , $post_date , false ) : gmdate ( 's' , $time_adj ); $cur_jj = gmdate ( 'd' , $time_adj ); $cur_mm = gmdate ( 'm' , $time_adj ); $cur_aa = gmdate ( 'Y' , $time_adj ); $cur_hh = gmdate ( 'H' , $time_adj ); $cur_mn = gmdate ( 'i' , $time_adj ); $month = '<label><span class="screen-reader-text">' . __( 'Month' ) . '</span><select ' . ( $multi ? '' : 'id="mm" ' ) . 'name="mm"' . $tab_index_attribute . ">\n" ; for ( $i = 1; $i < 13; $i = $i + 1 ) { $monthnum = zeroise( $i , 2 ); $monthtext = $wp_locale ->get_month_abbrev( $wp_locale ->get_month( $i ) ); $month .= "\t\t\t" . '<option value="' . $monthnum . '" data-text="' . $monthtext . '" ' . selected( $monthnum , $mm , false ) . '>' ; /* translators: 1: month number (01, 02, etc.), 2: month abbreviation */ $month .= sprintf( __( '%1$s-%2$s' ), $monthnum , $monthtext ) . "</option>\n" ; } $month .= '</select></label>' ; $day = '<label><span class="screen-reader-text">' . __( 'Day' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="jj" ' ) . 'name="jj" value="' . $jj . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" /></label>' ; $year = '<label><span class="screen-reader-text">' . __( 'Year' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="aa" ' ) . 'name="aa" value="' . $aa . '" size="4" maxlength="4"' . $tab_index_attribute . ' autocomplete="off" /></label>' ; $hour = '<label><span class="screen-reader-text">' . __( 'Hour' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="hh" ' ) . 'name="hh" value="' . $hh . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" /></label>' ; $minute = '<label><span class="screen-reader-text">' . __( 'Minute' ) . '</span><input type="text" ' . ( $multi ? '' : 'id="mn" ' ) . 'name="mn" value="' . $mn . '" size="2" maxlength="2"' . $tab_index_attribute . ' autocomplete="off" /></label>' ; echo '<div class="timestamp-wrap">' ; /* translators: 1: month, 2: day, 3: year, 4: hour, 5: minute */ printf( __( '%1$s %2$s, %3$s @ %4$s:%5$s' ), $month , $day , $year , $hour , $minute ); echo '</div><input type="hidden" id="ss" name="ss" value="' . $ss . '" />' ; if ( $multi ) { return ; } echo "\n\n" ; $map = array ( 'mm' => array ( $mm , $cur_mm ), 'jj' => array ( $jj , $cur_jj ), 'aa' => array ( $aa , $cur_aa ), 'hh' => array ( $hh , $cur_hh ), 'mn' => array ( $mn , $cur_mn ), ); foreach ( $map as $timeunit => $value ) { list( $unit , $curr ) = $value ; echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $unit . '" />' . "\n" ; $cur_timeunit = 'cur_' . $timeunit ; echo '<input type="hidden" id="' . $cur_timeunit . '" name="' . $cur_timeunit . '" value="' . $curr . '" />' . "\n" ; } ?> <p> <a href= "#edit_timestamp" class = "save-timestamp hide-if-no-js button" ><?php _e( 'OK' ); ?></a> <a href= "#edit_timestamp" class = "cancel-timestamp hide-if-no-js button-cancel" ><?php _e( 'Cancel' ); ?></a> </p> <?php } |
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
4.4.0 | Converted to use get_comment() instead of the global $comment . |
0.71 | Introduced. |