Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/WP_Export_Oxymel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@ public function optional_cdata( $tag_name, $contents ) {
}

public function cdata( $text ) {
if ( is_string( $text ) && ! seems_utf8( $text ) ) {
$text = mb_convert_encoding( $text, 'UTF-8' );
if ( is_string( $text ) ) {
if ( function_exists( 'wp_is_valid_utf8' ) ) {
if ( ! wp_is_valid_utf8( $text ) ) {
$text = mb_convert_encoding( $text, 'UTF-8' );
}
} elseif ( ! seems_utf8( $text ) ) { // phpcs:ignore WordPress.WP.DeprecatedFunctions.seems_utf8Found
$text = mb_convert_encoding( $text, 'UTF-8' );

}
}
return parent::cdata( $text );
}
Expand Down
5 changes: 4 additions & 1 deletion src/WP_Export_Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ private function author_where() {

private function start_date_where() {
global $wpdb;
$timestamp = strtotime( $this->filters['start_date'] );
$timestamp = $this->filters['start_date'] ? strtotime( $this->filters['start_date'] ) : null;
if ( ! $timestamp ) {
return;
}
Expand All @@ -254,6 +254,9 @@ private function start_date_where() {

private function end_date_where() {
global $wpdb;
if ( ! $this->filters['end_date'] ) {
return;
}
if ( preg_match( '/^\d{4}-\d{2}$/', $this->filters['end_date'] ) ) {
$timestamp = $this->get_timestamp_for_the_last_day_of_a_month( $this->filters['end_date'] );
} else {
Expand Down
5 changes: 4 additions & 1 deletion src/WP_Export_WXR_Formatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
* Responsible for formatting the data in WP_Export_Query to WXR
*/
class WP_Export_WXR_Formatter {
private $export;
private $wxr_version;

public function __construct( $export ) {
$this->export = $export;
$this->wxr_version = WXR_VERSION;
Expand Down Expand Up @@ -51,7 +54,7 @@ public function after_posts() {
public function header() {
$oxymel = new Oxymel();
$wp_generator_tag = $this->export->wp_generator_tag();
$comment = <<<COMMENT
$comment = <<<'COMMENT'

This is a WordPress eXtended RSS file generated by WordPress as an export of your site.
It contains information about your site's posts, pages, comments, categories, and other content.
Expand Down
2 changes: 2 additions & 0 deletions src/WP_Map_Iterator.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

class WP_Map_Iterator extends IteratorIterator {
private $callback;

public function __construct( $iterator, $callback ) {
$this->callback = $callback;
parent::__construct( $iterator );
Expand Down
10 changes: 9 additions & 1 deletion src/WP_Post_IDs_Iterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ class WP_Post_IDs_Iterator implements Iterator {
private $limit = 100;
private $post_ids;
private $ids_left;
private $results = array();
private $results = array();
private $global_index = 0;
private $index_in_results = 0;
private $db;

public function __construct( $post_ids, $limit = null ) {
$this->db = $GLOBALS['wpdb'];
Expand All @@ -15,26 +18,31 @@ public function __construct( $post_ids, $limit = null ) {
}
}

#[\ReturnTypeWillChange]
public function current() {
return $this->results[ $this->index_in_results ];
}

#[\ReturnTypeWillChange]
public function key() {
return $this->global_index;
}

#[\ReturnTypeWillChange]
public function next() {
++$this->index_in_results;
++$this->global_index;
}

#[\ReturnTypeWillChange]
public function rewind() {
$this->results = array();
$this->global_index = 0;
$this->index_in_results = 0;
$this->ids_left = $this->post_ids;
}

#[\ReturnTypeWillChange]
public function valid() {
if ( isset( $this->results[ $this->index_in_results ] ) ) {
return true;
Expand Down