wp_get_popular_importers(): array
- Since
- 3.5.0
- Source
wp-admin/includes/import.php:138
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
- Scaling
- Scales with input
- Instructions
- 21–142
- Plugin surface
- None
- Called by
- 0
Reaches an outbound HTTP request via wp_remote_get().
The body loops, so the work grows with how much data it finds.
Executed per call on PHP 8.4, depending on the branch taken. The body compiles to 171.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- transienttransient
get_site_transient()called directly - httpoutbound HTTP request
wp_remote_get()called directly - serializeserialisation
json_decode()called directly - querycontent query
get_user_by()one call below wp_get_popular_importers() - hookthird-party callbacks
apply_filters()one call below wp_get_popular_importers() - cacheobject cache
wp_cache_get()one call below wp_get_popular_importers() - optionnetwork option
get_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.
| When | Instructions | Calls it makes |
|---|---|---|
is_array($popular_importers) | 21–25 | get_user_locale(), wp_get_wp_version(), md5(), get_site_transient() |
!wp_http_supports() | 59–63 | get_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–68 | get_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–70 | get_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–75 | get_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) | 92 | get_user_locale(), wp_get_wp_version(), md5(), get_site_transient(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __() |
!wp_http_supports() && !is_array($popular_importers) | 130 | get_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) | 135 | get_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() | 137 | get_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() | 142 | get_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
- get_user_locale()Retrieves the locale of a user.
- wp_get_wp_version()Returns the current WordPress version.
- get_site_transient()Retrieves the value of a site transient.
- add_query_arg()Retrieves a modified URL query string.
- home_url()Retrieves the URL for the current site where the front end is accessible.
- wp_http_supports()Determines if there is an HTTP Transport that can process this request.
- set_url_scheme()Sets the scheme for a URL.
- wp_remote_get()Performs an HTTP request using the GET method and returns its response.
- wp_remote_retrieve_body()Retrieves only the body from the raw response.
- set_site_transient()Sets/updates the value of a site transient.
- translate()Retrieves the translation of $text.
- __()Retrieves the translation of $text.
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.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.0.4 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.