--- 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 @@
<title><?php bloginfo_rss( 'name' ); ?></title>
<link><?php bloginfo_rss( 'url' ); ?></link>
<description><?php bloginfo_rss( 'description' ); ?></description>
- <pubDate><?php echo date( 'D, d M Y H:i:s +0000' ); ?></pubDate>
+ <pubDate><?php echo gmdate( 'D, d M Y H:i:s +0000' ); ?></pubDate>
<language><?php bloginfo_rss( 'language' ); ?></language>
<wp:wxr_version><?php echo WXR_VERSION; ?></wp:wxr_version>
<wp:base_site_url><?php echo wxr_site_url(); ?></wp:base_site_url>
@@ -491,7 +501,7 @@
<?php endforeach; ?>
<?php foreach ( $terms as $t ) : ?>
<wp:term>
- <wp:term_id><?php echo wxr_cdata( $t->term_id ); ?></wp:term_id>
+ <wp:term_id><?php echo intval( $t->term_id ); ?></wp:term_id>
<wp:term_taxonomy><?php echo wxr_cdata( $t->taxonomy ); ?></wp:term_taxonomy>
<wp:term_slug><?php echo wxr_cdata( $t->slug ); ?></wp:term_slug>
<wp:term_parent><?php echo wxr_cdata( $t->parent ? $terms[ $t->parent ]->slug : '' ); ?></wp:term_parent>
@@ -503,7 +513,7 @@
</wp:term>
<?php endforeach; ?>
<?php
- if ( 'all' == $args['content'] ) {
+ if ( 'all' === $args['content'] ) {
wxr_nav_menu_terms();}
?>
@@ -515,7 +525,7 @@
<?php
if ( $post_ids ) {
/**
- * @global WP_Query $wp_query
+ * @global WP_Query $wp_query WordPress Query object.
*/
global $wp_query;
@@ -575,7 +585,7 @@
<wp:post_type><?php echo wxr_cdata( $post->post_type ); ?></wp:post_type>
<wp:post_password><?php echo wxr_cdata( $post->post_password ); ?></wp:post_password>
<wp:is_sticky><?php echo intval( $is_sticky ); ?></wp:is_sticky>
- <?php if ( $post->post_type == 'attachment' ) : ?>
+ <?php if ( 'attachment' === $post->post_type ) : ?>
<wp:attachment_url><?php echo wxr_cdata( wp_get_attachment_url( $post->ID ) ); ?></wp:attachment_url>
<?php endif; ?>
<?php wxr_post_taxonomy(); ?>
@@ -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