Changeset 38075
- Timestamp:
- 07/17/2016 03:31:29 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/css/common.css
r38033 r38075 2276 2276 } 2277 2277 2278 .importers td {2279 padding-right: 14px;2280 }2281 2282 2278 .importers { 2283 2279 font-size: 16px; 2284 2280 width: auto; 2281 } 2282 2283 .importers td { 2284 padding-right: 14px; 2285 line-height: 1.5em; 2286 } 2287 2288 .importers .import-system { 2289 max-width: 250px; 2290 } 2291 2292 .importers td.desc { 2293 max-width: 500px; 2294 } 2295 2296 .importer-title, 2297 .importer-desc, 2298 .importer-action { 2299 display: block; 2300 } 2301 2302 .importer-title { 2303 color: #000; 2304 font-size: 14px; 2305 font-weight: 400; 2306 margin-bottom: .2em; 2307 } 2308 2309 .importer-action { 2310 line-height: 20px; /* Same as with .updating-message */ 2311 color: #ddd; 2312 margin-bottom: 1em; 2313 } 2314 2315 .not-installed-main-site .importer-action { 2316 color: #555; 2285 2317 } 2286 2318 -
trunk/src/wp-admin/import.php
r37998 r38075 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' … … 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 … … 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 } … … 86 90 <table class="widefat importers striped"> 87 91 88 <?php 89 foreach ($importers as $importer_id => $data) { 90 $action = ''; 92 <?php 93 foreach ( $importers as $importer_id => $data ) { 94 $plugin_slug = $action = ''; 95 $is_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: %s: Importer name */ 115 esc_attr( sprintf( __( 'Run %s' ), $data[0] ) ), 116 __( 'Run Importer' ) 117 ); 118 119 $is_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" data-name="%3$s" aria-label="%4$s">%5$s</a>', 132 esc_url( $url ), 133 esc_attr( $plugin_slug ), 134 esc_attr( $data[0] ), 135 /* translators: %s: Importer name */ 136 esc_attr( sprintf( __( 'Install %s' ), $data[0] ) ), 137 __( 'Install Now' ) 138 ); 108 139 } 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' ) ); 140 $action = sprintf( 141 /* translators: URL to wp-admin/import.php */ 142 __( 'This importer is not installed. Please install importers from <a href="%s">the main site</a>.' ), 143 get_admin_url( get_current_network_id(), 'import.php' ) 144 ); 111 145 } 112 146 } 113 147 } else { 114 $action = "<a href='" . esc_url( "admin.php?import=$importer_id" ) . "' title='" . esc_attr( wptexturize( strip_tags( $data[1] ) ) ) ."'>{$data[0]}</a>"; 148 $url = add_query_arg( array( 149 'import' => $importer_id, 150 ), self_admin_url( 'admin.php' ) ); 151 $action = sprintf( 152 '<a href="%1$s" aria-label="%2$s">%3$s</a>', 153 esc_url( $url ), 154 /* translators: %s: Importer name */ 155 esc_attr( sprintf( __( 'Run %s' ), $data[0] ) ), 156 __( 'Run Importer' ) 157 ); 158 159 $is_plugin_installed = true; 115 160 } 116 161 162 if ( ! $is_plugin_installed && is_main_site() ) { 163 $url = add_query_arg( array( 164 'tab' => 'plugin-information', 165 'plugin' => $plugin_slug, 166 'from' => 'import', 167 'TB_iframe' => 'true', 168 'width' => 600, 169 'height' => 550, 170 ), network_admin_url( 'plugin-install.php' ) ); 171 $action .= sprintf( 172 ' | <a href="%1$s" class="thickbox open-plugin-details-modal" aria-label="%2$s">%3$s</a>', 173 esc_url( $url ), 174 /* translators: %s: Importer name */ 175 esc_attr( sprintf( __( 'More information about %s' ), $data[0] ) ), 176 __( 'Details' ) 177 ); 178 } 179 117 180 echo " 118 <tr> 119 <td class='import-system row-title'>$action</td> 120 <td class='desc'>{$data[1]}</td> 181 <tr class='importer-item'> 182 <td class='import-system'> 183 <span class='importer-title'>{$data[0]}</span> 184 <span class='importer-action'>{$action}</span> 185 </td> 186 <td class='desc'> 187 <span class='importer-desc'>{$data[1]}</span> 188 </td> 121 189 </tr>"; 122 190 } 123 ?> 124 191 ?> 125 192 </table> 126 193 <?php -
trunk/src/wp-admin/includes/import.php
r34566 r38075 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 … … 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', … … 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', … … 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', … … 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', … … 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', … … 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', … … 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', … … 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', -
trunk/src/wp-admin/js/updates.js
r38057 r38075 504 504 505 505 if ( 'import' === pagenow ) { 506 $message = $( ' a[href*="' + args.slug + '"]' );507 } else {508 $message.text( wp.updates.l10n.installing ); 509 }506 $message = $( '[data-slug="' + args.slug + '"]' ); 507 } 508 509 $message.text( wp.updates.l10n.installing ); 510 510 511 511 $message … … 626 626 } ); 627 627 628 $( 'a[href*="' + response.slug + '"]' ) 629 .removeClass( 'thickbox open-plugin-details-modal updating-message' ) 630 .off( 'click' ) 631 .attr( 'href', response.activateUrl + '&from=import' ) 632 .attr( 'title', wp.updates.l10n.activateImporter ); 628 $( '[data-slug="' + response.slug + '"]' ) 629 .removeClass( 'install-now updating-message' ) 630 .addClass( 'activate-now' ) 631 .attr({ 632 'href': response.activateUrl + '&from=import', 633 'aria-label': wp.updates.l10n.activateImporterLabel.replace( '%s', response.pluginName ) 634 }) 635 .text( wp.updates.l10n.activateImporter ); 633 636 634 637 wp.a11y.speak( wp.updates.l10n.installedMsg, 'polite' ); … … 650 653 */ 651 654 wp.updates.installImporterError = function( response ) { 652 var errorMessage = wp.updates.l10n.installFailed.replace( '%s', response.errorMessage ); 655 var errorMessage = wp.updates.l10n.installFailed.replace( '%s', response.errorMessage ), 656 $installLink = $( '[data-slug="' + response.slug + '"]' ), 657 pluginName = $installLink.data( 'name' ); 653 658 654 659 if ( ! wp.updates.isValidResponse( response, 'install' ) ) { … … 666 671 } ); 667 672 668 $( 'a[href*="' + response.slug + '"]' ).removeClass( 'updating-message' ); 673 $installLink 674 .removeClass( 'updating-message' ) 675 .text( wp.updates.l10n.installNow ) 676 .attr( 'aria-label', wp.updates.l10n.installNowLabel.replace( '%s', pluginName ) ); 669 677 670 678 wp.a11y.speak( errorMessage, 'assertive' ); … … 1767 1775 1768 1776 /** 1777 * Click handler for importer plugins installs in the Import screen. 1778 * 1779 * @since 4.6.0 1780 * 1781 * @param {Event} event Event interface. 1782 */ 1783 $document.on( 'click', '.importer-item .install-now', function( event ) { 1784 var $button = $( event.target ), 1785 pluginName = $( this ).data( 'name' ); 1786 1787 event.preventDefault(); 1788 1789 if ( $button.hasClass( 'updating-message' ) ) { 1790 return; 1791 } 1792 1793 if ( wp.updates.shouldRequestFilesystemCredentials && ! wp.updates.ajaxLocked ) { 1794 wp.updates.requestFilesystemCredentials( event ); 1795 1796 $document.on( 'credential-modal-cancel', function() { 1797 1798 $button 1799 .removeClass( 'updating-message' ) 1800 .text( wp.updates.l10n.installNow ) 1801 .attr( 'aria-label', wp.updates.l10n.installNowLabel.replace( '%s', pluginName ) ); 1802 1803 wp.a11y.speak( wp.updates.l10n.updateCancel, 'polite' ); 1804 } ); 1805 } 1806 1807 wp.updates.installPlugin( { 1808 slug: $button.data( 'slug' ), 1809 success: wp.updates.installImporterSuccess, 1810 error: wp.updates.installImporterError 1811 } ); 1812 } ); 1813 1814 /** 1769 1815 * Click handler for plugin deletions. 1770 1816 * -
trunk/src/wp-includes/script-loader.php
r38070 r38075 608 608 'updateNow' => __( 'Update Now' ), 609 609 'updateFailedShort' => __( 'Update Failed!' ), 610 /* translators: Error string for a failed update */610 /* translators: %s: Error string for a failed update */ 611 611 'updateFailed' => __( 'Update Failed: %s' ), 612 /* translators: Plugin name and version */612 /* translators: %s: Plugin name and version */ 613 613 'updatingLabel' => __( 'Updating %s...' ), // No ellipsis. 614 /* translators: Plugin name and version */614 /* translators: %s: Plugin name and version */ 615 615 'updatedLabel' => __( '%s updated!' ), 616 /* translators: Plugin name and version */616 /* translators: %s: Plugin name and version */ 617 617 'updateFailedLabel' => __( '%s update failed' ), 618 618 /* translators: JavaScript accessible string */ … … 624 624 'beforeunload' => __( 'Updates may not complete if you navigate away from this page.' ), 625 625 'installNow' => __( 'Install Now' ), 626 /* translators: %s: Plugin name */ 627 'installNowLabel' => __( 'Install %s' ), 626 628 'installing' => __( 'Installing...' ), 627 629 'installed' => __( 'Installed!' ), 628 630 'installFailedShort' => __( 'Install Failed!' ), 629 /* translators: Error string for a failed installation */631 /* translators: %s: Error string for a failed installation */ 630 632 'installFailed' => __( 'Installation failed: %s' ), 631 /* translators: Plugin name and version */633 /* translators: %s: Plugin name and version */ 632 634 'pluginInstallingLabel' => _x( 'Installing %s...', 'plugin' ), // no ellipsis 633 /* translators: Theme name and version */635 /* translators: %s: Theme name and version */ 634 636 'themeInstallingLabel' => _x( 'Installing %s...', 'theme' ), // no ellipsis 635 /* translators: Plugin name and version */637 /* translators: %s: Plugin name and version */ 636 638 'pluginInstalledLabel' => _x( '%s installed!', 'plugin' ), 637 /* translators: Theme name and version */639 /* translators: %s: Theme name and version */ 638 640 'themeInstalledLabel' => _x( '%s installed!', 'theme' ), 639 /* translators: Plugin name and version */641 /* translators: %s: Plugin name and version */ 640 642 'pluginInstallFailedLabel' => _x( '%s installation failed', 'plugin' ), 641 /* translators: Theme name and version */643 /* translators: %s: Theme name and version */ 642 644 'themeInstallFailedLabel' => _x( '%s installation failed', 'theme' ), 643 645 'installingMsg' => __( 'Installing... please wait.' ), 644 646 'installedMsg' => __( 'Installation completed successfully.' ), 645 /* translators: Activation URL */646 'importerInstalledMsg' => __( 'Importer installed successfully. <a href="%s"> Activate plugin & run importer</a>' ),647 /* translators: %s: Activation URL */ 648 'importerInstalledMsg' => __( 'Importer installed successfully. <a href="%s">Run importer</a>' ), 647 649 /* translators: %s: Theme name */ 648 650 'aysDelete' => __( 'Are you sure you want to delete %s?' ), … … 662 664 /* translators: %s: Theme name */ 663 665 'activateThemeLabel' => is_network_admin() ? _x( 'Network Activate %s', 'theme' ) : _x( 'Activate %s', 'theme' ), 664 'activateImporter' => __( 'Activate importer' ), 666 'activateImporter' => __( 'Run Importer' ), 667 /* translators: %s: Importer name */ 668 'activateImporterLabel' => __( 'Run %s' ), 665 669 'unknownError' => __( 'An unknown error occurred' ), 666 670 'pluginsFound' => __( 'Number of plugins found: %d' ), -
trunk/tests/qunit/fixtures/updates.js
r38057 r38075 31 31 'installingMsg': 'Installing... please wait.', 32 32 'installedMsg': 'Installation completed successfully.', 33 'importerInstalledMsg': 'Importer installed successfully. <a href="%s"> Activate plugin & run importer</a>',33 'importerInstalledMsg': 'Importer installed successfully. <a href="%s">Run importer</a>', 34 34 'aysDelete': 'Are you sure you want to delete %s?', 35 35 'aysDeleteUninstall': 'Are you sure you want to delete %s and its data?', … … 44 44 'activatePluginLabel': 'Activate %s', 45 45 'activateThemeLabel': 'Activate %s', 46 'activateImporter': ' Activate importer',46 'activateImporter': 'Run Importer', 47 47 'unknownError': 'An unknown error occurred', 48 48 'pluginsFound': 'Number of plugins found: %d',
Note: See TracChangeset
for help on using the changeset viewer.