export_date_options()
最后更新于:2021-11-26 04:04:51
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’
源文件
文件: gc-admin/export.php
function export_date_options( $post_type = 'post' ) {
global $gcdb, $gc_locale;
$months = $gcdb->get_results(
$gcdb->prepare(
"
SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
FROM $gcdb->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 === (int) $months[0]->month ) ) {
return;
}
foreach ( $months as $date ) {
if ( 0 === (int) $date->year ) {
continue;
}
$month = zeroise( $date->month, 2 );
echo '<option value="' . $date->year . '-' . $month . '">' . $gc_locale->get_month( $month ) . ' ' . $date->year . '</option>';
}
}