Changeset 42343 for trunk/src/wp-admin/includes/import.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/import.php
r41605 r42343 54 54 function register_importer( $id, $name, $description, $callback ) { 55 55 global $wp_importers; 56 if ( is_wp_error( $callback ) ) 56 if ( is_wp_error( $callback ) ) { 57 57 return $callback; 58 $wp_importers[$id] = array ( $name, $description, $callback ); 58 } 59 $wp_importers[ $id ] = array( $name, $description, $callback ); 59 60 } 60 61 … … 82 83 if ( ! isset( $_FILES['import'] ) ) { 83 84 return array( 84 'error' => __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.' ) 85 'error' => __( 'File is empty. Please upload something more substantial. This error could also be caused by uploads being disabled in your php.ini or by post_max_size being defined as smaller than upload_max_filesize in php.ini.' ), 85 86 ); 86 87 } 87 88 88 $overrides = array( 'test_form' => false, 'test_type' => false ); 89 $overrides = array( 90 'test_form' => false, 91 'test_type' => false, 92 ); 89 93 $_FILES['import']['name'] .= '.txt'; 90 $upload = wp_handle_upload( $_FILES['import'], $overrides );94 $upload = wp_handle_upload( $_FILES['import'], $overrides ); 91 95 92 96 if ( isset( $upload['error'] ) ) { … … 96 100 // Construct the object array 97 101 $object = array( 98 'post_title' => basename( $upload['file'] ),99 'post_content' => $upload['url'],102 'post_title' => basename( $upload['file'] ), 103 'post_content' => $upload['url'], 100 104 'post_mime_type' => $upload['type'], 101 'guid' => $upload['url'],102 'context' => 'import',103 'post_status' => 'private'105 'guid' => $upload['url'], 106 'context' => 'import', 107 'post_status' => 'private', 104 108 ); 105 109 … … 113 117 wp_schedule_single_event( time() + DAY_IN_SECONDS, 'importer_scheduled_cleanup', array( $id ) ); 114 118 115 return array( 'file' => $upload['file'], 'id' => $id ); 119 return array( 120 'file' => $upload['file'], 121 'id' => $id, 122 ); 116 123 } 117 124 … … 126 133 include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version 127 134 128 $locale = get_user_locale();129 $cache_key = 'popular_importers_' . md5( $locale . $wp_version );135 $locale = get_user_locale(); 136 $cache_key = 'popular_importers_' . md5( $locale . $wp_version ); 130 137 $popular_importers = get_site_transient( $cache_key ); 131 138 132 139 if ( ! $popular_importers ) { 133 $url = add_query_arg( array( 134 'locale' => $locale, 135 'version' => $wp_version, 136 ), 'http://api.wordpress.org/core/importers/1.1/' ); 140 $url = add_query_arg( 141 array( 142 'locale' => $locale, 143 'version' => $wp_version, 144 ), 'http://api.wordpress.org/core/importers/1.1/' 145 ); 137 146 $options = array( 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ) ); 138 147 … … 141 150 } 142 151 143 $response = wp_remote_get( $url, $options );152 $response = wp_remote_get( $url, $options ); 144 153 $popular_importers = json_decode( wp_remote_retrieve_body( $response ), true ); 145 154 … … 153 162 if ( is_array( $popular_importers ) ) { 154 163 // If the data was received as translated, return it as-is. 155 if ( $popular_importers['translated'] ) 164 if ( $popular_importers['translated'] ) { 156 165 return $popular_importers['importers']; 166 } 157 167 158 168 foreach ( $popular_importers['importers'] as &$importer ) { 159 169 $importer['description'] = translate( $importer['description'] ); 160 if ( $importer['name'] != 'WordPress' ) 170 if ( $importer['name'] != 'WordPress' ) { 161 171 $importer['name'] = translate( $importer['name'] ); 172 } 162 173 } 163 174 return $popular_importers['importers']; … … 166 177 return array( 167 178 // slug => name, description, plugin slug, and register_importer() slug 168 'blogger' => array(169 'name' => __( 'Blogger' ),179 'blogger' => array( 180 'name' => __( 'Blogger' ), 170 181 'description' => __( 'Import posts, comments, and users from a Blogger blog.' ), 171 182 'plugin-slug' => 'blogger-importer', 172 183 'importer-id' => 'blogger', 173 184 ), 174 'wpcat2tag' => array(175 'name' => __( 'Categories and Tags Converter' ),185 'wpcat2tag' => array( 186 'name' => __( 'Categories and Tags Converter' ), 176 187 'description' => __( 'Convert existing categories to tags or tags to categories, selectively.' ), 177 188 'plugin-slug' => 'wpcat2tag-importer', … … 179 190 ), 180 191 'livejournal' => array( 181 'name' => __( 'LiveJournal' ),192 'name' => __( 'LiveJournal' ), 182 193 'description' => __( 'Import posts from LiveJournal using their API.' ), 183 194 'plugin-slug' => 'livejournal-importer', … … 185 196 ), 186 197 'movabletype' => array( 187 'name' => __( 'Movable Type and TypePad' ),198 'name' => __( 'Movable Type and TypePad' ), 188 199 'description' => __( 'Import posts and comments from a Movable Type or TypePad blog.' ), 189 200 'plugin-slug' => 'movabletype-importer', 190 201 'importer-id' => 'mt', 191 202 ), 192 'opml' => array(193 'name' => __( 'Blogroll' ),203 'opml' => array( 204 'name' => __( 'Blogroll' ), 194 205 'description' => __( 'Import links in OPML format.' ), 195 206 'plugin-slug' => 'opml-importer', 196 207 'importer-id' => 'opml', 197 208 ), 198 'rss' => array(199 'name' => __( 'RSS' ),209 'rss' => array( 210 'name' => __( 'RSS' ), 200 211 'description' => __( 'Import posts from an RSS feed.' ), 201 212 'plugin-slug' => 'rss-importer', 202 213 'importer-id' => 'rss', 203 214 ), 204 'tumblr' => array(205 'name' => __( 'Tumblr' ),215 'tumblr' => array( 216 'name' => __( 'Tumblr' ), 206 217 'description' => __( 'Import posts & media from Tumblr using their API.' ), 207 218 'plugin-slug' => 'tumblr-importer', 208 219 'importer-id' => 'tumblr', 209 220 ), 210 'wordpress' => array(211 'name' => 'WordPress',221 'wordpress' => array( 222 'name' => 'WordPress', 212 223 'description' => __( 'Import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.' ), 213 224 'plugin-slug' => 'wordpress-importer',
Note: See TracChangeset
for help on using the changeset viewer.