wppaste
WordPress

WP_Importer

Source
wp-admin/includes/class-wp-importer.php:5
WP_Importer base class

Compatibility

WordPress
core
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Methods · 12

Source code

#[AllowDynamicProperties]class WP_Importer {	/**	 * Class Constructor	 */	public function __construct() {} 	/**	 * Returns array with imported permalinks from WordPress database.	 *	 * @global wpdb $wpdb WordPress database abstraction object.	 *	 * @param string $importer_name	 * @param string $blog_id	 * @return array	 */	public function get_imported_posts( $importer_name, $blog_id ) {		global $wpdb; 		$hashtable = array(); 		$limit  = 100;		$offset = 0; 		// Grab all posts in chunks.		do {			$meta_key = $importer_name . '_' . $blog_id . '_permalink';			$sql      = $wpdb->prepare( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = %s LIMIT %d,%d", $meta_key, $offset, $limit );			$results  = $wpdb->get_results( $sql ); 			// Increment offset.			$offset = ( $limit + $offset ); 			if ( ! empty( $results ) ) {				foreach ( $results as $r ) {					// Set permalinks into array.					$hashtable[ $r->meta_value ] = (int) $r->post_id;				}			}		} while ( count( $results ) === $limit ); 		return $hashtable;	} 	/**	 * Returns count of imported permalinks from WordPress database.	 *	 * @global wpdb $wpdb WordPress database abstraction object.	 *	 * @param string $importer_name	 * @param string $blog_id	 * @return int	 */	public function count_imported_posts( $importer_name, $blog_id ) {		global $wpdb; 		$count = 0; 		// Get count of permalinks.		$meta_key = $importer_name . '_' . $blog_id . '_permalink';		$sql      = $wpdb->prepare( "SELECT COUNT( post_id ) AS cnt FROM $wpdb->postmeta WHERE meta_key = %s", $meta_key ); 		$result = $wpdb->get_results( $sql ); 		if ( ! empty( $result ) ) {			$count = (int) $result[0]->cnt;		} 		return $count;	} 	/**	 * Sets array with imported comments from WordPress database.	 *	 * @global wpdb $wpdb WordPress database abstraction object.	 *	 * @param string $blog_id	 * @return array	 */	public function get_imported_comments( $blog_id ) {

Changelog

One change between 6.7.7 and 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

7.1.0
Method __construct() removed.verified against source

About this page

Parsed data
Generated from the wordpress-develop 6.7.7 tag, from src/wp-admin/includes/class-wp-importer.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.