export_date_options() - WordPress 函数参考中文文档

返回介绍

export_date_options()

发布于 2017-09-10 字数1801 浏览 743 评论 0

export_date_options( string $post_type = 'post' )

Create the date options fields for exporting a given post type.


描述


参数

$post_type

(string)
(Optional)
The post type.

Default value: ‘post’


源代码

File: wp-admin/export.php

function export_date_options( $post_type = 'post' ) {
	global $wpdb, $wp_locale;

	$months = $wpdb->get_results( $wpdb->prepare( "
		SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
		FROM $wpdb->posts
		WHERE post_type = %s AND post_status != 'auto-draft'
		ORDER BY post_date DESC
	", $post_type ) );

	$month_count = count( $months );
	if ( !$month_count || ( 1 == $month_count && 0 == $months[0]->month ) )
		return;

	foreach ( $months as $date ) {
		if ( 0 == $date->year )
			continue;

		$month = zeroise( $date->month, 2 );
		echo '<option value="' . $date->year . '-' . $month . '">' . $wp_locale->get_month( $month ) . ' ' . $date->year . '</option>';
	}
}

更新日志

Version 描述
3.1.0 Introduced.

相关函数

Uses

  • wp-includes/formatting.php:
    zeroise()
  • wp-includes/class-wp-locale.php:
    WP_Locale::get_month()
  • wp-includes/wp-db.php:
    wpdb::get_results()
  • wp-includes/wp-db.php:
    wpdb::prepare()

User Contributed Notes

上一篇:export_add_js()

下一篇:export_wp()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!