diff --git a/src/WP_Export_Oxymel.php b/src/WP_Export_Oxymel.php index 0d3c75e3..5c5b7804 100644 --- a/src/WP_Export_Oxymel.php +++ b/src/WP_Export_Oxymel.php @@ -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 ); } diff --git a/src/WP_Export_Query.php b/src/WP_Export_Query.php index 4ddc9656..b0df9ee8 100644 --- a/src/WP_Export_Query.php +++ b/src/WP_Export_Query.php @@ -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; } @@ -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 { diff --git a/src/WP_Export_WXR_Formatter.php b/src/WP_Export_WXR_Formatter.php index 3910cc8e..fe6a29fb 100644 --- a/src/WP_Export_WXR_Formatter.php +++ b/src/WP_Export_WXR_Formatter.php @@ -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; @@ -51,7 +54,7 @@ public function after_posts() { public function header() { $oxymel = new Oxymel(); $wp_generator_tag = $this->export->wp_generator_tag(); - $comment = <<callback = $callback; parent::__construct( $iterator ); diff --git a/src/WP_Post_IDs_Iterator.php b/src/WP_Post_IDs_Iterator.php index b05c6f12..054a76ab 100644 --- a/src/WP_Post_IDs_Iterator.php +++ b/src/WP_Post_IDs_Iterator.php @@ -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']; @@ -15,19 +18,23 @@ 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; @@ -35,6 +42,7 @@ public function rewind() { $this->ids_left = $this->post_ids; } + #[\ReturnTypeWillChange] public function valid() { if ( isset( $this->results[ $this->index_in_results ] ) ) { return true;