touch_time

函数


touch_time ( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 )
参数
  • (int|bool)
    $edit
    Accepts 1|true for editing the date, 0|false for adding the date.
    Required:
    Default: 1
  • (int|bool)
    $for_post
    Accepts 1|true for applying the date to a post, 0|false for a comment.
    Required:
    Default: 1
  • (int)
    $tab_index
    The tabindex attribute to add. Default 0.
    Required:
  • (int|bool)
    $multi
    Optional. Whether the additional fields and buttons should be added. Default 0|false.
    Required:
定义位置
  • wp-admin/includes/template.php
    , line 792
引入
0.71
弃用

打印出HTML表格的日期元素,用于编辑文章或评论的发布日期。

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' ), true ) && ( ! $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 '
'; $post_date = ( $for_post ) ? $post->post_date : get_comment()->comment_date; $jj = ( $edit ) ? mysql2date( 'd', $post_date, false ) : current_time( 'd' ); $mm = ( $edit ) ? mysql2date( 'm', $post_date, false ) : current_time( 'm' ); $aa = ( $edit ) ? mysql2date( 'Y', $post_date, false ) : current_time( 'Y' ); $hh = ( $edit ) ? mysql2date( 'H', $post_date, false ) : current_time( 'H' ); $mn = ( $edit ) ? mysql2date( 'i', $post_date, false ) : current_time( 'i' ); $ss = ( $edit ) ? mysql2date( 's', $post_date, false ) : current_time( 's' ); $cur_jj = current_time( 'd' ); $cur_mm = current_time( 'm' ); $cur_aa = current_time( 'Y' ); $cur_hh = current_time( 'H' ); $cur_mn = current_time( 'i' ); $month = ''; $day = ''; $year = ''; $hour = ''; $minute = ''; echo '
'; /* translators: 1: Month, 2: Day, 3: Year, 4: Hour, 5: Minute. */ printf( __( '%1$s %2$s, %3$s at %4$s:%5$s' ), $month, $day, $year, $hour, $minute ); echo '
'; if ( $multi ) { return; } echo "nn"; $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 '' . "n"; $cur_timeunit = 'cur_' . $timeunit; echo '' . "n"; } ?>