Ticket #35191: 35191.12.diff
File 35191.12.diff, 15.7 KB (added by , 8 years ago) |
---|
-
src/wp-admin/css/common.css
2277 2277 2278 2278 .importers td { 2279 2279 padding-right: 14px; 2280 line-height: 1.5em; 2280 2281 } 2281 2282 2282 2283 .importers { … … 2284 2285 width: auto; 2285 2286 } 2286 2287 2288 .importer-title, 2289 .importer-desc, 2290 .importer-action { 2291 display: block; 2292 } 2293 2294 .importer-title { 2295 color: #000; 2296 font-size: 14px; 2297 font-weight: 400; 2298 margin-bottom: .2em; 2299 } 2300 2301 .importer-action { 2302 margin-bottom: 1em; 2303 color: #ddd; 2304 } 2305 2287 2306 #post-body #post-body-content #namediv h3, /* Back-compat for pre-4.4 */ 2288 2307 #post-body #post-body-content #namediv h2 { 2289 2308 margin-top: 0; -
src/wp-admin/import.php
30 30 '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' 31 31 ); 32 32 33 if ( current_user_can( 'install_plugins' ) ) 33 if ( current_user_can( 'install_plugins' ) ) { 34 // List of popular importer plugins from the WordPress.org API. 34 35 $popular_importers = wp_get_popular_importers(); 35 else 36 $popular_importers = array(); 36 } else { 37 $popular_importers = array(); 38 } 37 39 38 40 // Detect and redirect invalid importers like 'movabletype', which is registered as 'mt' 39 41 if ( ! empty( $_GET['invalid'] ) && isset( $popular_importers[ $_GET['invalid'] ] ) ) { … … 66 68 <p><?php _e('If you have posts or comments in another system, WordPress can import those into this site. To get started, choose a system to import from below:'); ?></p> 67 69 68 70 <?php 69 71 // Registered (already installed) importers. They're stored in the global $wp_importers. 70 72 $importers = get_importers(); 71 73 72 74 // If a popular importer is not registered, create a dummy registration that links to the plugin installer. … … 75 77 continue; 76 78 if ( isset( $importers[ $pop_data['importer-id'] ] ) ) 77 79 continue; 80 81 // Fill the array of registered (already installed) importers with data of the popular importers from the WordPress.org API. 78 82 $importers[ $pop_data['importer-id'] ] = array( $pop_data['name'], $pop_data['description'], 'install' => $pop_data['plugin-slug'] ); 79 83 } 80 84 … … 87 91 88 92 <?php 89 93 foreach ($importers as $importer_id => $data) { 90 $action = ''; 94 $plugin_slug = $action = ''; 95 $plugin_installed = false; 96 91 97 if ( isset( $data['install'] ) ) { 92 98 $plugin_slug = $data['install']; 99 93 100 if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin_slug ) ) { 94 // Looks like Importer is installed, But not active101 // Looks like an importer is installed, but not active. 95 102 $plugins = get_plugins( '/' . $plugin_slug ); 96 if ( ! empty($plugins) ) {97 $keys = array_keys( $plugins);103 if ( ! empty( $plugins ) ) { 104 $keys = array_keys( $plugins ); 98 105 $plugin_file = $plugin_slug . '/' . $keys[0]; 99 $action = '<a href="' . esc_url(wp_nonce_url(admin_url('plugins.php?action=activate&plugin=' . $plugin_file . '&from=import'), 'activate-plugin_' . $plugin_file)) . 100 '"title="' . esc_attr__('Activate importer') . '"">' . $data[0] . '</a>'; 106 $url = wp_nonce_url( add_query_arg( array( 107 'action' => 'activate', 108 'plugin' => $plugin_file, 109 'from' => 'import', 110 ), admin_url( 'plugins.php' ) ), 'activate-plugin_' . $plugin_file ); 111 $action = sprintf( 112 '<a href="%s" aria-label="%s">%s</a>', 113 esc_url( $url ), 114 /* translators: name of importer */ 115 esc_attr( sprintf( __( 'Run “%s”' ), $data[0] ) ), 116 __( 'Run Importer' ) 117 ); 118 119 $plugin_installed = true; 101 120 } 102 121 } 103 if ( empty($action) ) { 122 123 if ( empty( $action ) ) { 104 124 if ( is_main_site() ) { 105 $action = '<a href="' . esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_slug . 106 '&from=import&TB_iframe=true&width=600&height=550' ) ) . '" class="thickbox open-plugin-details-modal" title="' . 107 esc_attr__('Install importer') . '">' . $data[0] . '</a>'; 125 $url = wp_nonce_url( add_query_arg( array( 126 'action' => 'install-plugin', 127 'plugin' => $plugin_slug, 128 'from' => 'import', 129 ), self_admin_url( 'update.php' ) ), 'install-plugin_' . $plugin_slug ); 130 $action = sprintf( 131 '<a href="%1$s" class="install-now" data-slug="%2$s" aria-label="%3$s">%4$s</a>', 132 esc_url( $url ), 133 esc_attr( $plugin_slug ), 134 /* translators: name of importer */ 135 esc_attr( sprintf( __( 'Install “%s”' ), $data[0] ) ), 136 __( 'Install Now' ) 137 ); 108 138 } else { 109 $action = $data[0]; 110 $data[1] = sprintf( __( 'This importer is not installed. Please install importers from <a href="%s">the main site</a>.' ), get_admin_url( $current_site->blog_id, 'import.php' ) ); 139 $action = sprintf( 140 __( 'This importer is not installed. Please install importers from <a href="%s">the main site</a>.' ), 141 get_admin_url( get_current_network_id(), 'import.php' ) 142 ); 111 143 } 112 144 } 113 145 } else { 114 $action = "<a href='" . esc_url( "admin.php?import=$importer_id" ) . "' title='" . esc_attr( wptexturize( strip_tags( $data[1] ) ) ) ."'>{$data[0]}</a>"; 146 $plugin_installed = true; 147 $url = add_query_arg( array( 148 'import' => $importer_id, 149 ), self_admin_url( 'admin.php' ) ); 150 $action = sprintf( 151 '<a href="%1$s" aria-label="%2$s">%3$s</a>', 152 esc_url( $url ), 153 /* translators: name of importer */ 154 esc_attr( sprintf( __( 'Run “%s”' ), $data[0] ) ), 155 __( 'Run Importer' ) 156 ); 115 157 } 116 158 159 if ( ! $plugin_installed ) { 160 $url = add_query_arg( array( 161 'tab' => 'plugin-information', 162 'plugin' => $plugin_slug, 163 'from' => 'import', 164 'TB_iframe' => 'true', 165 'width' => 600, 166 'height' => 550, 167 ), network_admin_url( 'plugin-install.php' ) ); 168 $action .= sprintf( 169 ' | <a href="%1$s" class="thickbox open-plugin-details-modal" aria-label="%2$s">%3$s</a>', 170 esc_url( $url ), 171 /* translators: name of importer */ 172 esc_attr( sprintf( __( 'More information about “%s”' ), $data[0] ) ), 173 __( 'Details' ) 174 ); 175 } 176 117 177 echo " 118 <tr> 119 <td class='import-system row-title'>$action</td> 120 <td class='desc'>{$data[1]}</td> 178 <tr class='importer-item'> 179 <td class='import-system'> 180 <span class='importer-title'>{$data[0]}</span> 181 <span class='importer-action'>{$action}</span> 182 </td> 183 <td class='desc'> 184 <span class='importer-desc'>{$data[1]}</span> 185 </td> 121 186 </tr>"; 122 187 } 123 188 ?> -
src/wp-admin/includes/import.php
126 126 include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version 127 127 128 128 $locale = get_locale(); 129 $popular_importers = get_site_transient( 'popular_importers_' . $locale ); 129 $cache_key = 'popular_importers_' . md5( $locale . $wp_version ); 130 $popular_importers = get_site_transient( $cache_key ); 130 131 131 132 if ( ! $popular_importers ) { 132 $url = add_query_arg( 'locale', get_locale(), 'http://api.wordpress.org/core/importers/1.1/' ); 133 $url = add_query_arg( array( 134 'locale' => get_locale(), 135 'version' => $wp_version, 136 ), 'http://api.wordpress.org/core/importers/1.1/' ); 133 137 $options = array( 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url() ); 134 138 $response = wp_remote_get( $url, $options ); 135 139 $popular_importers = json_decode( wp_remote_retrieve_body( $response ), true ); 136 140 137 if ( is_array( $popular_importers ) ) 138 set_site_transient( 'popular_importers_' . $locale, $popular_importers, 2 * DAY_IN_SECONDS );139 else141 if ( is_array( $popular_importers ) ) { 142 set_site_transient( $cache_key, $popular_importers, 2 * DAY_IN_SECONDS ); 143 } else { 140 144 $popular_importers = false; 145 } 141 146 } 142 147 143 148 if ( is_array( $popular_importers ) ) { … … 157 162 // slug => name, description, plugin slug, and register_importer() slug 158 163 'blogger' => array( 159 164 'name' => __( 'Blogger' ), 160 'description' => __( 'I nstall the Blogger importer to import posts, comments, and users from a Blogger blog.' ),165 'description' => __( 'Import posts, comments, and users from a Blogger blog.' ), 161 166 'plugin-slug' => 'blogger-importer', 162 167 'importer-id' => 'blogger', 163 168 ), 164 169 'wpcat2tag' => array( 165 170 'name' => __( 'Categories and Tags Converter' ), 166 'description' => __( ' Install the category/tag converter to convert existing categories to tags or tags to categories, selectively.' ),171 'description' => __( 'Convert existing categories to tags or tags to categories, selectively.' ), 167 172 'plugin-slug' => 'wpcat2tag-importer', 168 173 'importer-id' => 'wp-cat2tag', 169 174 ), 170 175 'livejournal' => array( 171 176 'name' => __( 'LiveJournal' ), 172 'description' => __( 'I nstall the LiveJournal importer to import posts from LiveJournal using their API.' ),177 'description' => __( 'Import posts from LiveJournal using their API.' ), 173 178 'plugin-slug' => 'livejournal-importer', 174 179 'importer-id' => 'livejournal', 175 180 ), 176 181 'movabletype' => array( 177 182 'name' => __( 'Movable Type and TypePad' ), 178 'description' => __( 'I nstall the Movable Type importer to import posts and comments from a Movable Type or TypePad blog.' ),183 'description' => __( 'Import posts and comments from a Movable Type or TypePad blog.' ), 179 184 'plugin-slug' => 'movabletype-importer', 180 185 'importer-id' => 'mt', 181 186 ), 182 187 'opml' => array( 183 188 'name' => __( 'Blogroll' ), 184 'description' => __( 'I nstall the blogroll importer to import links in OPML format.' ),189 'description' => __( 'Import links in OPML format.' ), 185 190 'plugin-slug' => 'opml-importer', 186 191 'importer-id' => 'opml', 187 192 ), 188 193 'rss' => array( 189 194 'name' => __( 'RSS' ), 190 'description' => __( 'I nstall the RSS importer to import posts from an RSS feed.' ),195 'description' => __( 'Import posts from an RSS feed.' ), 191 196 'plugin-slug' => 'rss-importer', 192 197 'importer-id' => 'rss', 193 198 ), 194 199 'tumblr' => array( 195 200 'name' => __( 'Tumblr' ), 196 'description' => __( 'I nstall the Tumblr importer to import posts & media from Tumblr using their API.' ),201 'description' => __( 'Import posts & media from Tumblr using their API.' ), 197 202 'plugin-slug' => 'tumblr-importer', 198 203 'importer-id' => 'tumblr', 199 204 ), 200 205 'wordpress' => array( 201 206 'name' => 'WordPress', 202 'description' => __( 'I nstall the WordPress importer to import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.' ),207 'description' => __( 'Import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.' ), 203 208 'plugin-slug' => 'wordpress-importer', 204 209 'importer-id' => 'wordpress', 205 210 ), -
src/wp-admin/js/updates.js
503 503 }, args ); 504 504 505 505 if ( 'import' === pagenow ) { 506 $message = $( ' a[href*="' + args.slug + '"]' );506 $message = $( '[data-slug="' + args.slug + '"]' ); 507 507 } else { 508 508 $message.text( wp.updates.l10n.installing ); 509 509 } … … 621 621 message: wp.updates.l10n.importerInstalledMsg.replace( '%s', response.activateUrl + '&from=import' ) 622 622 } ); 623 623 624 $( ' a[href*="' + response.slug + '"]' )625 .removeClass( ' thickbox open-plugin-details-modalupdating-message' )626 . off( 'click' )624 $( '[data-slug="' + response.slug + '"]' ) 625 .removeClass( 'install-now updating-message' ) 626 .addClass( 'activate-now' ) 627 627 .attr( 'href', response.activateUrl + '&from=import' ) 628 . attr( 'title',wp.updates.l10n.activateImporter );628 .text( wp.updates.l10n.activateImporter ); 629 629 630 630 wp.a11y.speak( wp.updates.l10n.installedMsg, 'polite' ); 631 631 … … 661 661 message: errorMessage 662 662 } ); 663 663 664 $( ' a[href*="' + response.slug + '"]' ).removeClass( 'updating-message' );664 $( '[data-slug="' + response.slug + '"]' ).removeClass( 'updating-message' ); 665 665 666 666 wp.a11y.speak( errorMessage, 'assertive' ); 667 667 … … 1758 1758 } ); 1759 1759 1760 1760 /** 1761 * Click handler for plugin installs in plugin install view. 1762 * 1763 * @since 4.6.0 1764 * 1765 * @param {Event} event Event interface. 1766 */ 1767 $document.on( 'click', '.importer-item .install-now', function( event ) { 1768 var $button = $( event.target ); 1769 event.preventDefault(); 1770 1771 if ( $button.hasClass( 'updating-message' ) ) { 1772 return; 1773 } 1774 1775 if ( wp.updates.shouldRequestFilesystemCredentials && ! wp.updates.ajaxLocked ) { 1776 wp.updates.requestFilesystemCredentials( event ); 1777 1778 $document.on( 'credential-modal-cancel', function() { 1779 var $message = $( '.install-now.updating-message' ); 1780 1781 $message 1782 .removeClass( 'updating-message' ) 1783 .text( wp.updates.l10n.installNow ); 1784 1785 wp.a11y.speak( wp.updates.l10n.updateCancel, 'polite' ); 1786 } ); 1787 } 1788 1789 wp.updates.installPlugin( { 1790 slug: $button.data( 'slug' ), 1791 success: wp.updates.installImporterSuccess, 1792 error: wp.updates.installImporterError 1793 } ); 1794 } ); 1795 1796 /** 1761 1797 * Click handler for plugin deletions. 1762 1798 * 1763 1799 * @since 4.6.0 -
src/wp-includes/script-loader.php
637 637 'installingMsg' => __( 'Installing... please wait.' ), 638 638 'installedMsg' => __( 'Installation completed successfully.' ), 639 639 /* translators: Activation URL */ 640 'importerInstalledMsg' => __( 'Importer installed successfully. <a href="%s"> Activate plugin & run importer</a>' ),640 'importerInstalledMsg' => __( 'Importer installed successfully. <a href="%s">Run importer</a>' ), 641 641 /* translators: %s: Theme name */ 642 642 'aysDelete' => __( 'Are you sure you want to delete %s?' ), 643 643 /* translators: %s: Plugin name */ … … 651 651 'livePreview' => __( 'Live Preview' ), 652 652 'activatePlugin' => is_network_admin() ? __( 'Network Activate' ) : __( 'Activate' ), 653 653 'activateTheme' => is_network_admin() ? __( 'Network Enable' ) : __( 'Activate' ), 654 'activateImporter' => __( ' Activate importer' ),654 'activateImporter' => __( 'Run Importer' ), 655 655 'unknownError' => __( 'An unknown error occured' ), 656 656 'pluginsFound' => __( 'Number of plugins found: %d' ), 657 657 'noPluginsFound' => __( 'No plugins found. Try a different search.' ), -
tests/qunit/fixtures/updates.js
27 27 'installFailedLabel': '%s installation failed', 28 28 'installingMsg': 'Installing... please wait.', 29 29 'installedMsg': 'Installation completed successfully.', 30 'importerInstalledMsg': 'Importer installed successfully. <a href="%s"> Activate plugin & run importer</a>',30 'importerInstalledMsg': 'Importer installed successfully. <a href="%s">Run importer</a>', 31 31 'aysDelete': 'Are you sure you want to delete %s?', 32 32 'aysDeleteUninstall': 'Are you sure you want to delete %s and its data?', 33 33 'aysBulkDelete': 'Are you sure you want to delete the selected plugins and their data?', … … 38 38 'livePreview': 'Live Preview', 39 39 'activatePlugin': 'Activate', 40 40 'activateTheme': 'Activate', 41 'activateImporter': ' Activate importer',41 'activateImporter': 'Run Importer', 42 42 'unknownError': 'An unknown error occured', 43 43 'pluginsFound': 'Number of plugins found: %d', 44 44 'noPluginsFound': 'No plugins found. Try a different search.'