WordPress.org

Make WordPress Core

Ticket #19307: 19307.diff

File 19307.diff, 3.7 KB (added by sorich87, 6 years ago)
  • wp-admin/includes/export.php

     
    6565                }
    6666        }
    6767
    68         if ( 'post' == $args['content'] || 'page' == $args['content'] ) {
    69                 if ( $args['author'] )
    70                         $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_author = %d", $args['author'] );
     68        if ( $args['author'] )
     69                $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_author = %d", $args['author'] );
    7170
    72                 if ( $args['start_date'] )
    73                         $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date >= %s", date( 'Y-m-d', strtotime($args['start_date']) ) );
     71        if ( $args['start_date'] )
     72                $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date >= %s", date( 'Y-m-d', strtotime($args['start_date']) ) );
    7473
    75                 if ( $args['end_date'] )
    76                         $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date < %s", date( 'Y-m-d', strtotime('+1 month', strtotime($args['end_date'])) ) );
    77         }
     74        if ( $args['end_date'] )
     75                $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date < %s", date( 'Y-m-d', strtotime('+1 month', strtotime($args['end_date'])) ) );
    7876
    7977        // grab a snapshot of post IDs, just in case it changes during the export
    8078        $post_ids = $wpdb->get_col( "SELECT ID FROM {$wpdb->posts} $join WHERE $where" );
  • wp-admin/export.php

     
    2323        jQuery(document).ready(function($){
    2424                var form = $('#export-filters'),
    2525                        filters = form.find('.export-filters');
    26                 filters.hide();
     26                filters.not('#all-filters').hide();
    2727                form.find('input:radio').change(function() {
    2828                        filters.slideUp('fast');
    2929                        switch ( $(this).val() ) {
     30                                case 'all'  : $('#all-filters').slideDown(); break;
    3031                                case 'posts': $('#post-filters').slideDown(); break;
    3132                                case 'pages': $('#page-filters').slideDown(); break;
    3233                        }
     
    5657
    5758        if ( ! isset( $_GET['content'] ) || 'all' == $_GET['content'] ) {
    5859                $args['content'] = 'all';
     60
     61                if ( $_GET['all_start_date'] || $_GET['all_end_date'] ) {
     62                        $args['start_date'] = $_GET['all_start_date'];
     63                        $args['end_date'] = $_GET['all_end_date'];
     64                }
    5965        } else if ( 'posts' == $_GET['content'] ) {
    6066                $args['content'] = 'post';
    6167
     
    98104function export_date_options( $post_type = 'post' ) {
    99105        global $wpdb, $wp_locale;
    100106
     107        $post_type_clause = '';
     108        if ( 'all' != $post_type )
     109                $post_type_clause = $wpdb->prepare( 'post_type = %s AND', $post_type );
     110
    101111        $months = $wpdb->get_results( $wpdb->prepare( "
    102112                SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
    103113                FROM $wpdb->posts
    104                 WHERE post_type = %s AND post_status != 'auto-draft'
     114                WHERE $post_type_clause post_status != 'auto-draft'
    105115                ORDER BY post_date DESC
    106116        ", $post_type ) );
    107117
     
    132142<input type="hidden" name="download" value="true" />
    133143<p><label><input type="radio" name="content" value="all" checked="checked" /> <?php _e( 'All content' ); ?></label>
    134144<span class="description"><?php _e( 'This will contain all of your posts, pages, comments, custom fields, terms, navigation menus and custom posts.' ); ?></span></p>
     145<ul id="all-filters" class="export-filters">
     146        <li>
     147                <label><?php _e( 'Date range:' ); ?></label>
     148                <select name="all_start_date">
     149                        <option value="0"><?php _e( 'Start Date' ); ?></option>
     150                        <?php export_date_options( 'all' ); ?>
     151                </select>
     152                <select name="all_end_date">
     153                        <option value="0"><?php _e( 'End Date' ); ?></option>
     154                        <?php export_date_options( 'all' ); ?>
     155                </select>
     156        </li>
     157</ul>
    135158
    136159<p><label><input type="radio" name="content" value="posts" /> <?php _e( 'Posts' ); ?></label></p>
    137160<ul id="post-filters" class="export-filters">