wppaste
WordPress

wp_get_popular_importers(): array

Since
3.5.0
Source
wp-admin/includes/import.php:138
Returns a list from WordPress.org of popular importer plugins.

Return value

array
Importers with metadata for each.

Performance profile

How much work a call to wp_get_popular_importers() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Expensive

Reaches an outbound HTTP request via wp_remote_get().

Scaling
Scales with input

The body loops, so the work grows with how much data it finds.

Instructions
21–142

Executed per call on PHP 8.4, depending on the branch taken. The body compiles to 171.

Plugin surface
None

Nothing here hands control to plugin code.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • transienttransientget_site_transient()called directly
  • httpoutbound HTTP requestwp_remote_get()called directly
  • serializeserialisationjson_decode()called directly
  • querycontent queryget_user_by()one call below wp_get_popular_importers()
  • hookthird-party callbacksapply_filters()one call below wp_get_popular_importers()
  • cacheobject cachewp_cache_get()one call below wp_get_popular_importers()
  • optionnetwork optionget_site_option()one call below wp_get_popular_importers()

What one call costs · 10 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_get_popular_importers() can have, taken from its control-flow graph on PHP 8.4.

WhenInstructionsCalls it makes
is_array($popular_importers)21–25get_user_locale(), wp_get_wp_version(), md5(), get_site_transient()
!wp_http_supports()59–63get_user_locale(), wp_get_wp_version(), md5(), get_site_transient(), wp_get_wp_version(), locale(), wp_get_wp_version(), home_url(), wp_http_supports(), wp_remote_get(), wp_remote_retrieve_body(), json_decode()
wp_http_supports()64–68get_user_locale(), wp_get_wp_version(), md5(), get_site_transient(), wp_get_wp_version(), locale(), wp_get_wp_version(), home_url(), wp_http_supports(), set_url_scheme(), wp_remote_get(), wp_remote_retrieve_body(), json_decode()
!wp_http_supports() && is_array($popular_importers)66–70get_user_locale(), wp_get_wp_version(), md5(), get_site_transient(), wp_get_wp_version(), locale(), wp_get_wp_version(), home_url(), wp_http_supports(), wp_remote_get(), wp_remote_retrieve_body(), json_decode(), set_site_transient()
wp_http_supports() && is_array($popular_importers)71–75get_user_locale(), wp_get_wp_version(), md5(), get_site_transient(), wp_get_wp_version(), locale(), wp_get_wp_version(), home_url(), wp_http_supports(), set_url_scheme(), wp_remote_get(), wp_remote_retrieve_body(), json_decode(), set_site_transient()
!is_array($popular_importers)92get_user_locale(), wp_get_wp_version(), md5(), get_site_transient(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __()
!wp_http_supports() && !is_array($popular_importers)130get_user_locale(), wp_get_wp_version(), md5(), get_site_transient(), wp_get_wp_version(), locale(), wp_get_wp_version(), home_url(), wp_http_supports(), wp_remote_get(), wp_remote_retrieve_body(), json_decode(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __()
wp_http_supports() && !is_array($popular_importers)135get_user_locale(), wp_get_wp_version(), md5(), get_site_transient(), wp_get_wp_version(), locale(), wp_get_wp_version(), home_url(), wp_http_supports(), set_url_scheme(), wp_remote_get(), wp_remote_retrieve_body(), json_decode(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __()
!wp_http_supports()137get_user_locale(), wp_get_wp_version(), md5(), get_site_transient(), wp_get_wp_version(), locale(), wp_get_wp_version(), home_url(), wp_http_supports(), wp_remote_get(), wp_remote_retrieve_body(), json_decode(), set_site_transient(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __()
wp_http_supports()142get_user_locale(), wp_get_wp_version(), md5(), get_site_transient(), wp_get_wp_version(), locale(), wp_get_wp_version(), home_url(), wp_http_supports(), set_url_scheme(), wp_remote_get(), wp_remote_retrieve_body(), json_decode(), set_site_transient(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __()

Across PHP versions

Compiles the same on PHP 7.4, 8.1, 8.2, 8.3 and 8.4: 171 instructions, 21–142 executed per call, 8 branches. The work does not change between versions.

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Uses · 12

Source code

function wp_get_popular_importers() {	$locale            = get_user_locale();	$cache_key         = 'popular_importers_' . md5( $locale . wp_get_wp_version() );	$popular_importers = get_site_transient( $cache_key ); 	if ( ! $popular_importers ) {		$url     = add_query_arg(			array(				'locale'  => $locale,				'version' => wp_get_wp_version(),			),			'http://api.wordpress.org/core/importers/1.1/'		);		$options = array( 'user-agent' => 'WordPress/' . wp_get_wp_version() . '; ' . home_url( '/' ) ); 		if ( wp_http_supports( array( 'ssl' ) ) ) {			$url = set_url_scheme( $url, 'https' );		} 		$response          = wp_remote_get( $url, $options );		$popular_importers = json_decode( wp_remote_retrieve_body( $response ), true ); 		if ( is_array( $popular_importers ) ) {			set_site_transient( $cache_key, $popular_importers, 2 * DAY_IN_SECONDS );		} else {			$popular_importers = false;		}	} 	if ( is_array( $popular_importers ) ) {		// If the data was received as translated, return it as-is.		if ( $popular_importers['translated'] ) {			return $popular_importers['importers'];		} 		foreach ( $popular_importers['importers'] as &$importer ) {			// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText			$importer['description'] = translate( $importer['description'] );			if ( 'WordPress' !== $importer['name'] ) {				// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText				$importer['name'] = translate( $importer['name'] );			}		}		return $popular_importers['importers'];	} 	return array(		// slug => name, description, plugin slug, and register_importer() slug.		'blogger'     => array(			'name'        => __( 'Blogger' ),			'description' => __( 'Import posts, comments, and users from a Blogger blog.' ),			'plugin-slug' => 'blogger-importer',			'importer-id' => 'blogger',		),		'wpcat2tag'   => array(			'name'        => __( 'Categories and Tags Converter' ),			'description' => __( 'Convert existing categories to tags or tags to categories, selectively.' ),			'plugin-slug' => 'wpcat2tag-importer',			'importer-id' => 'wp-cat2tag',		),		'livejournal' => array(			'name'        => __( 'LiveJournal' ),			'description' => __( 'Import posts from LiveJournal using their API.' ),			'plugin-slug' => 'livejournal-importer',			'importer-id' => 'livejournal',		),		'movabletype' => array(			'name'        => __( 'Movable Type and TypePad' ),			'description' => __( 'Import posts and comments from a Movable Type or TypePad blog.' ),			'plugin-slug' => 'movabletype-importer',			'importer-id' => 'mt',		),		'rss'         => array(			'name'        => __( 'RSS' ),			'description' => __( 'Import posts from an RSS feed.' ),			'plugin-slug' => 'rss-importer',			'importer-id' => 'rss',		),		'tumblr'      => array(			'name'        => __( 'Tumblr' ),

Changelog

Introduced in 3.5.0. Unchanged from 6.7.7 through 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.

About this page

Parsed data
Generated from the wordpress-develop 6.8.8 tag, from src/wp-admin/includes/import.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.