| 34 | | if ( current_user_can('install_plugins') ) |
| 35 | | $popular_importers = array( |
| 36 | | 'blogger' => array( __('Blogger'), __('Install the Blogger importer to import posts, comments, and users from a Blogger blog.'), 'install' ), |
| 37 | | 'wpcat2tag' => array(__('Categories and Tags Converter'), __('Install the category/tag converter to convert existing categories to tags or tags to categories, selectively.'), 'install', 'wp-cat2tag' ), |
| 38 | | 'livejournal' => array( __( 'LiveJournal' ), __( 'Install the LiveJournal importer to import posts from LiveJournal using their API.' ), 'install' ), |
| 39 | | 'movabletype' => array( __('Movable Type and TypePad'), __('Install the Movable Type importer to import posts and comments from a Movable Type or TypePad blog.'), 'install', 'mt' ), |
| 40 | | 'opml' => array( __('Blogroll'), __('Install the blogroll importer to import links in OPML format.'), 'install' ), |
| 41 | | 'rss' => array( __('RSS'), __('Install the RSS importer to import posts from an RSS feed.'), 'install' ), |
| 42 | | 'tumblr' => array( __('Tumblr'), __('Install the Tumblr importer to import posts & media from Tumblr using their API.'), 'install' ), |
| 43 | | 'wordpress' => array( 'WordPress', __('Install the WordPress importer to import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.'), 'install' ) |
| 44 | | ); |
| | 34 | if ( current_user_can('install_plugins') ) { |
| 46 | | if ( ! empty( $_GET['invalid'] ) && !empty($popular_importers[$_GET['invalid']][3]) ) { |
| 47 | | wp_redirect( admin_url('import.php?import=' . $popular_importers[$_GET['invalid']][3]) ); |
| | 36 | $popular_importers = get_site_transient( 'popular_importers' ); |
| | 37 | if ( empty( $popular_importers ) ) { |
| | 38 | $popular_importers = maybe_unserialize( wp_remote_retrieve_body( wp_remote_get( 'http://api.wordpress.org/core/importers/1.0/' ) ) ); |
| | 39 | |
| | 40 | if ( $popular_importers ) { |
| | 41 | false && update_site_transient( 'popular_importers', $popular_importers, 604800 ); // week |
| | 42 | |
| | 43 | foreach ( $popular_importers as &$importer ) { |
| | 44 | // API: importer slug => name, description, register_importer() id |
| | 45 | // $wp_importers: importer slug => name, description, callback |
| | 46 | if ( isset( $importer[2] ) ) |
| | 47 | $importer[3] = $importer[2]; |
| | 48 | $importer[2] = 'install'; // dummy callback |
| | 49 | $importer[1] = translate( $importer[1] ); |
| | 50 | } |
| | 51 | unset( $importer ); |
| | 52 | |
| | 53 | } else { |
| | 54 | // importer slug => name, description, 'install', register_importer() id (if not slug) |
| | 55 | $popular_importers = array( |
| | 56 | 'blogger' => array( |
| | 57 | __('Blogger'), |
| | 58 | __('Install the Blogger importer to import posts, comments, and users from a Blogger blog.'), |
| | 59 | 'install', |
| | 60 | ), |
| | 61 | 'wpcat2tag' => array( |
| | 62 | __('Categories and Tags Converter'), |
| | 63 | __('Install the category/tag converter to convert existing categories to tags or tags to categories, selectively.'), |
| | 64 | 'install', |
| | 65 | 'wp-cat2tag', |
| | 66 | ), |
| | 67 | 'livejournal' => array( |
| | 68 | __( 'LiveJournal' ), |
| | 69 | __( 'Install the LiveJournal importer to import posts from LiveJournal using their API.' ), |
| | 70 | 'install', |
| | 71 | ), |
| | 72 | 'movabletype' => array( |
| | 73 | __('Movable Type and TypePad'), |
| | 74 | __('Install the Movable Type importer to import posts and comments from a Movable Type or TypePad blog.'), |
| | 75 | 'install', |
| | 76 | 'mt', |
| | 77 | ), |
| | 78 | 'opml' => array( |
| | 79 | __('Blogroll'), |
| | 80 | __('Install the blogroll importer to import links in OPML format.'), |
| | 81 | 'install', |
| | 82 | ), |
| | 83 | 'rss' => array( |
| | 84 | __('RSS'), |
| | 85 | __('Install the RSS importer to import posts from an RSS feed.'), |
| | 86 | 'install', |
| | 87 | 'rss', |
| | 88 | ), |
| | 89 | 'tumblr' => array( |
| | 90 | __('Tumblr'), |
| | 91 | __('Install the Tumblr importer to import posts & media from Tumblr using their API.'), |
| | 92 | 'install', |
| | 93 | ), |
| | 94 | 'wordpress' => array( |
| | 95 | 'WordPress', |
| | 96 | __('Install the WordPress importer to import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.'), |
| | 97 | 'install', |
| | 98 | ) |
| | 99 | ); |
| | 100 | } |
| | 101 | } |
| | 102 | } |
| | 103 | |
| | 104 | // Redirect invalid importers. |
| | 105 | if ( ! empty( $_GET['invalid'] ) && ! empty( $popular_importers[ $_GET['invalid'] ][3] ) ) { |
| | 106 | wp_redirect( admin_url('import.php?import=' . $popular_importers[ $_GET['invalid'] ][3] ) ); |