diff -r 3d4e9c994f10 -r a86126ab1dd4 wp/wp-admin/includes/export.php --- a/wp/wp-admin/includes/export.php Tue Oct 22 16:11:46 2019 +0200 +++ b/wp/wp-admin/includes/export.php Tue Dec 15 13:49:49 2020 +0100 @@ -25,7 +25,7 @@ * @since 2.1.0 * * @global wpdb $wpdb WordPress database abstraction object. - * @global WP_Post $post Global `$post`. + * @global WP_Post $post Global post object. * * @param array $args { * Optional. Arguments for generating the WXR export file for download. Default empty array. @@ -79,7 +79,7 @@ if ( ! empty( $sitename ) ) { $sitename .= '.'; } - $date = date( 'Y-m-d' ); + $date = gmdate( 'Y-m-d' ); $wp_filename = $sitename . 'WordPress.' . $date . '.xml'; /** * Filters the export filename. @@ -96,7 +96,7 @@ header( 'Content-Disposition: attachment; filename=' . $filename ); header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true ); - if ( 'all' != $args['content'] && post_type_exists( $args['content'] ) ) { + if ( 'all' !== $args['content'] && post_type_exists( $args['content'] ) ) { $ptype = get_post_type_object( $args['content'] ); if ( ! $ptype->can_export ) { $args['content'] = 'post'; @@ -106,34 +106,37 @@ } else { $post_types = get_post_types( array( 'can_export' => true ) ); $esses = array_fill( 0, count( $post_types ), '%s' ); - $where = $wpdb->prepare( "{$wpdb->posts}.post_type IN (" . implode( ',', $esses ) . ')', $post_types ); + + // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare + $where = $wpdb->prepare( "{$wpdb->posts}.post_type IN (" . implode( ',', $esses ) . ')', $post_types ); } - if ( $args['status'] && ( 'post' == $args['content'] || 'page' == $args['content'] ) ) { + if ( $args['status'] && ( 'post' === $args['content'] || 'page' === $args['content'] ) ) { $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_status = %s", $args['status'] ); } else { $where .= " AND {$wpdb->posts}.post_status != 'auto-draft'"; } $join = ''; - if ( $args['category'] && 'post' == $args['content'] ) { - if ( $term = term_exists( $args['category'], 'category' ) ) { + if ( $args['category'] && 'post' === $args['content'] ) { + $term = term_exists( $args['category'], 'category' ); + if ( $term ) { $join = "INNER JOIN {$wpdb->term_relationships} ON ({$wpdb->posts}.ID = {$wpdb->term_relationships}.object_id)"; $where .= $wpdb->prepare( " AND {$wpdb->term_relationships}.term_taxonomy_id = %d", $term['term_taxonomy_id'] ); } } - if ( 'post' == $args['content'] || 'page' == $args['content'] || 'attachment' == $args['content'] ) { + if ( in_array( $args['content'], array( 'post', 'page', 'attachment' ), true ) ) { if ( $args['author'] ) { $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_author = %d", $args['author'] ); } if ( $args['start_date'] ) { - $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date >= %s", date( 'Y-m-d', strtotime( $args['start_date'] ) ) ); + $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date >= %s", gmdate( 'Y-m-d', strtotime( $args['start_date'] ) ) ); } if ( $args['end_date'] ) { - $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date < %s", date( 'Y-m-d', strtotime( '+1 month', strtotime( $args['end_date'] ) ) ) ); + $where .= $wpdb->prepare( " AND {$wpdb->posts}.post_date < %s", gmdate( 'Y-m-d', strtotime( '+1 month', strtotime( $args['end_date'] ) ) ) ); } } @@ -144,21 +147,28 @@ * Get the requested terms ready, empty unless posts filtered by category * or all content. */ - $cats = $tags = $terms = array(); + $cats = array(); + $tags = array(); + $terms = array(); if ( isset( $term ) && $term ) { $cat = get_term( $term['term_id'], 'category' ); $cats = array( $cat->term_id => $cat ); unset( $term, $cat ); - } elseif ( 'all' == $args['content'] ) { + } elseif ( 'all' === $args['content'] ) { $categories = (array) get_categories( array( 'get' => 'all' ) ); $tags = (array) get_tags( array( 'get' => 'all' ) ); $custom_taxonomies = get_taxonomies( array( '_builtin' => false ) ); - $custom_terms = (array) get_terms( $custom_taxonomies, array( 'get' => 'all' ) ); + $custom_terms = (array) get_terms( + array( + 'taxonomy' => $custom_taxonomies, + 'get' => 'all', + ) + ); // Put categories in order with no child going before its parent. while ( $cat = array_shift( $categories ) ) { - if ( $cat->parent == 0 || isset( $cats[ $cat->parent ] ) ) { + if ( 0 == $cat->parent || isset( $cats[ $cat->parent ] ) ) { $cats[ $cat->term_id ] = $cat; } else { $categories[] = $cat; @@ -167,7 +177,7 @@ // Put terms in order with no child going before its parent. while ( $t = array_shift( $custom_terms ) ) { - if ( $t->parent == 0 || isset( $terms[ $t->parent ] ) ) { + if ( 0 == $t->parent || isset( $terms[ $t->parent ] ) ) { $terms[ $t->term_id ] = $t; } else { $custom_terms[] = $t; @@ -318,7 +328,7 @@ /** * Filters whether to selectively skip term meta used for WXR exports. * - * Returning a truthy value to the filter will skip the current meta + * Returning a truthy value from the filter will skip the current meta * object from being exported. * * @since 4.6.0 @@ -418,7 +428,7 @@ * @return bool */ function wxr_filter_postmeta( $return_me, $meta_key ) { - if ( '_edit_lock' == $meta_key ) { + if ( '_edit_lock' === $meta_key ) { $return_me = true; } return $return_me; @@ -458,7 +468,7 @@ <?php bloginfo_rss( 'name' ); ?> - + @@ -491,7 +501,7 @@ - term_id ); ?> + term_id ); ?> taxonomy ); ?> slug ); ?> parent ? $terms[ $t->parent ]->slug : '' ); ?> @@ -503,7 +513,7 @@ @@ -515,7 +525,7 @@ post_type ); ?> post_password ); ?> - post_type == 'attachment' ) : ?> + post_type ) : ?> ID ) ); ?> @@ -585,7 +595,7 @@ /** * Filters whether to selectively skip post meta used for WXR exports. * - * Returning a truthy value to the filter will skip the current meta + * Returning a truthy value from the filter will skip the current meta * object from being exported. * * @since 3.3.0 @@ -628,7 +638,7 @@ /** * Filters whether to selectively skip comment meta used for WXR exports. * - * Returning a truthy value to the filter will skip the current meta + * Returning a truthy value from the filter will skip the current meta * object from being exported. * * @since 4.0.0