export_date_options

The timeline below displays how wordpress function export_date_options has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.4

/**
 * Creates the date options fields for exporting a given post type.
 *
 * @global wpdb      $wpdb      WordPress database abstraction object.
 * @global WP_Locale $wp_locale WordPress date and time locale object.
 *
 * @since 3.1.0
 *
 * @param string $post_type The post type. Default 'post'.
 */
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\n\t\t\tFROM {$wpdb->posts}\n\t\t\tWHERE post_type = %s AND post_status != 'auto-draft'\n\t\t\tORDER 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);
        printf('<option value="%1$s">%2$s</option>', esc_attr($date->year . '-' . $month), $wp_locale->get_month($month) . ' ' . $date->year);
    }
}

WordPress Version: 6.3

/**
 * Creates the date options fields for exporting a given post type.
 *
 * @global wpdb      $wpdb      WordPress database abstraction object.
 * @global WP_Locale $wp_locale WordPress date and time locale object.
 *
 * @since 3.1.0
 *
 * @param string $post_type The post type. Default 'post'.
 */
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\n\t\t\tFROM {$wpdb->posts}\n\t\t\tWHERE post_type = %s AND post_status != 'auto-draft'\n\t\t\tORDER 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 . '">' . $wp_locale->get_month($month) . ' ' . $date->year . '</option>';
    }
}

WordPress Version: 5.5

/**
 * Create the date options fields for exporting a given post type.
 *
 * @global wpdb      $wpdb      WordPress database abstraction object.
 * @global WP_Locale $wp_locale WordPress date and time locale object.
 *
 * @since 3.1.0
 *
 * @param string $post_type The post type. Default 'post'.
 */
function export_date_options($post_type = 'post')
{
    global $wpdb, $wp_locale;
    $months = $wpdb->get_results($wpdb->prepare("\n\t\tSELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month\n\t\tFROM {$wpdb->posts}\n\t\tWHERE post_type = %s AND post_status != 'auto-draft'\n\t\tORDER BY post_date DESC\n\t\t\t", $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 . '">' . $wp_locale->get_month($month) . ' ' . $date->year . '</option>';
    }
}

WordPress Version: 5.3

/**
 * Create the date options fields for exporting a given post type.
 *
 * @global wpdb      $wpdb      WordPress database abstraction object.
 * @global WP_Locale $wp_locale WordPress date and time locale object.
 *
 * @since 3.1.0
 *
 * @param string $post_type The post type. Default 'post'.
 */
function export_date_options($post_type = 'post')
{
    global $wpdb, $wp_locale;
    $months = $wpdb->get_results($wpdb->prepare("\n\t\tSELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month\n\t\tFROM {$wpdb->posts}\n\t\tWHERE post_type = %s AND post_status != 'auto-draft'\n\t\tORDER BY post_date DESC\n\t", $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>';
    }
}

WordPress Version: 4.1

/**
 * Create the date options fields for exporting a given post type.
 *
 * @global wpdb      $wpdb      WordPress database abstraction object.
 * @global WP_Locale $wp_locale Date and Time Locale object.
 *
 * @since 3.1.0
 *
 * @param string $post_type The post type. Default 'post'.
 */
function export_date_options($post_type = 'post')
{
    global $wpdb, $wp_locale;
    $months = $wpdb->get_results($wpdb->prepare("\n\t\tSELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month\n\t\tFROM {$wpdb->posts}\n\t\tWHERE post_type = %s AND post_status != 'auto-draft'\n\t\tORDER BY post_date DESC\n\t", $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>';
    }
}

WordPress Version: 3.7

/**
 * Create the date options fields for exporting a given post type.
 *
 * @global wpdb      $wpdb      WordPress database object.
 * @global WP_Locale $wp_locale Date and Time Locale object.
 *
 * @since 3.1.0
 *
 * @param string $post_type The post type. Default 'post'.
 */
function export_date_options($post_type = 'post')
{
    global $wpdb, $wp_locale;
    $months = $wpdb->get_results($wpdb->prepare("\n\t\tSELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month\n\t\tFROM {$wpdb->posts}\n\t\tWHERE post_type = %s AND post_status != 'auto-draft'\n\t\tORDER BY post_date DESC\n\t", $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>';
    }
}