wppaste
WordPress

WP_Importer

Since
3.0.0
Source
wp-admin/includes/class-wp-importer.php:10
WP_Importer base class

Compatibility

WordPress
since 3.0.0
  • 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 · 11

Source code

#[AllowDynamicProperties]class WP_Importer { 	/**	 * 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';			$results  = $wpdb->get_results(				$wpdb->prepare(					"SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = %s LIMIT %d,%d",					$meta_key,					$offset,					$limit				)			); 			// 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';		$result   = $wpdb->get_results(			$wpdb->prepare(				"SELECT COUNT( post_id ) AS cnt FROM $wpdb->postmeta WHERE meta_key = %s",				$meta_key			)		); 		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.

Changelog

Introduced in 3.0.0. 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
3.0.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 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.