wp_get_popular_importers

Returns a list from WordPress.org of popular importer plugins.

Description

(array) wp_get_popular_importers(); 

Returns (array)

Importers with metadata for each.


Usage

  1. if ( !function_exists( 'wp_get_popular_importers' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/import.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wp_get_popular_importers(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/import.php  
  1. function wp_get_popular_importers() { 
  2. include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version 
  3.  
  4. $locale = get_user_locale(); 
  5. $cache_key = 'popular_importers_' . md5( $locale . $wp_version ); 
  6. $popular_importers = get_site_transient( $cache_key ); 
  7.  
  8. if ( ! $popular_importers ) { 
  9. $url = add_query_arg( array( 
  10. 'locale' => get_user_locale(),  
  11. 'version' => $wp_version,  
  12. ), 'http://api.wordpress.org/core/importers/1.1/' ); 
  13. $options = array( 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url() ); 
  14. $response = wp_remote_get( $url, $options ); 
  15. $popular_importers = json_decode( wp_remote_retrieve_body( $response ), true ); 
  16.  
  17. if ( is_array( $popular_importers ) ) { 
  18. set_site_transient( $cache_key, $popular_importers, 2 * DAY_IN_SECONDS ); 
  19. } else { 
  20. $popular_importers = false; 
  21.  
  22. if ( is_array( $popular_importers ) ) { 
  23. // If the data was received as translated, return it as-is. 
  24. if ( $popular_importers['translated'] ) 
  25. return $popular_importers['importers']; 
  26.  
  27. foreach ( $popular_importers['importers'] as &$importer ) { 
  28. $importer['description'] = translate( $importer['description'] ); 
  29. if ( $importer['name'] != 'WordPress' ) 
  30. $importer['name'] = translate( $importer['name'] ); 
  31. return $popular_importers['importers']; 
  32.  
  33. return array( 
  34. // slug => name, description, plugin slug, and register_importer() slug 
  35. 'blogger' => array( 
  36. 'name' => __( 'Blogger' ),  
  37. 'description' => __( 'Import posts, comments, and users from a Blogger blog.' ),  
  38. 'plugin-slug' => 'blogger-importer',  
  39. 'importer-id' => 'blogger',  
  40. ),  
  41. 'wpcat2tag' => array( 
  42. 'name' => __( 'Categories and Tags Converter' ),  
  43. 'description' => __( 'Convert existing categories to tags or tags to categories, selectively.' ),  
  44. 'plugin-slug' => 'wpcat2tag-importer',  
  45. 'importer-id' => 'wp-cat2tag',  
  46. ),  
  47. 'livejournal' => array( 
  48. 'name' => __( 'LiveJournal' ),  
  49. 'description' => __( 'Import posts from LiveJournal using their API.' ),  
  50. 'plugin-slug' => 'livejournal-importer',  
  51. 'importer-id' => 'livejournal',  
  52. ),  
  53. 'movabletype' => array( 
  54. 'name' => __( 'Movable Type and TypePad' ),  
  55. 'description' => __( 'Import posts and comments from a Movable Type or TypePad blog.' ),  
  56. 'plugin-slug' => 'movabletype-importer',  
  57. 'importer-id' => 'mt',  
  58. ),  
  59. 'opml' => array( 
  60. 'name' => __( 'Blogroll' ),  
  61. 'description' => __( 'Import links in OPML format.' ),  
  62. 'plugin-slug' => 'opml-importer',  
  63. 'importer-id' => 'opml',  
  64. ),  
  65. 'rss' => array( 
  66. 'name' => __( 'RSS' ),  
  67. 'description' => __( 'Import posts from an RSS feed.' ),  
  68. 'plugin-slug' => 'rss-importer',  
  69. 'importer-id' => 'rss',  
  70. ),  
  71. 'tumblr' => array( 
  72. 'name' => __( 'Tumblr' ),  
  73. 'description' => __( 'Import posts & media from Tumblr using their API.' ),  
  74. 'plugin-slug' => 'tumblr-importer',  
  75. 'importer-id' => 'tumblr',  
  76. ),  
  77. 'wordpress' => array( 
  78. 'name' => 'WordPress',  
  79. 'description' => __( 'Import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.' ),  
  80. 'plugin-slug' => 'wordpress-importer',  
  81. 'importer-id' => 'wordpress',  
  82. ),  
  83. );