diff --git src/wp-admin/css/common.css src/wp-admin/css/common.css
index 705e64d..2ba6782 100644
|
|
body.iframe { |
2277 | 2277 | |
2278 | 2278 | .importers td { |
2279 | 2279 | padding-right: 14px; |
| 2280 | line-height: 1.5em; |
2280 | 2281 | } |
2281 | 2282 | |
2282 | 2283 | .importers { |
… |
… |
body.iframe { |
2284 | 2285 | width: auto; |
2285 | 2286 | } |
2286 | 2287 | |
| 2288 | .importer-title, |
| 2289 | .importer-desc, |
| 2290 | .importer-status, |
| 2291 | .importer-action { |
| 2292 | display: block; |
| 2293 | } |
| 2294 | |
| 2295 | .importer-action { |
| 2296 | margin-bottom: 1em; |
| 2297 | color: #ddd; |
| 2298 | } |
| 2299 | |
2287 | 2300 | #post-body #post-body-content #namediv h3, /* Back-compat for pre-4.4 */ |
2288 | 2301 | #post-body #post-body-content #namediv h2 { |
2289 | 2302 | margin-top: 0; |
diff --git src/wp-admin/import.php src/wp-admin/import.php
index 962db68..f7fff19 100644
|
|
get_current_screen()->set_help_sidebar( |
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'] ] ) ) { |
… |
… |
$parent_file = 'tools.php'; |
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. |
… |
… |
foreach ( $popular_importers as $pop_importer => $pop_data ) { |
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 | |
… |
… |
if ( empty( $importers ) ) { |
87 | 91 | |
88 | 92 | <?php |
89 | 93 | foreach ($importers as $importer_id => $data) { |
90 | | $action = ''; |
| 94 | $plugin_slug = $action = $status = $status_class = ''; |
| 95 | |
91 | 96 | if ( isset( $data['install'] ) ) { |
92 | 97 | $plugin_slug = $data['install']; |
| 98 | |
93 | 99 | if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin_slug ) ) { |
94 | | // Looks like Importer is installed, But not active |
| 100 | // Looks like an importer is installed, but not active. |
95 | 101 | $plugins = get_plugins( '/' . $plugin_slug ); |
96 | 102 | if ( !empty($plugins) ) { |
97 | 103 | $keys = array_keys($plugins); |
98 | 104 | $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>'; |
| 105 | $status = _x( 'Inactive', 'importer plugin' ); |
| 106 | $status_class = ' importer-inactive'; |
| 107 | $url = esc_url( wp_nonce_url( add_query_arg( array( |
| 108 | 'action' => 'activate', |
| 109 | 'plugin' => $plugin_file, |
| 110 | 'from' => 'import', |
| 111 | ), admin_url( 'plugins.php' ) ), 'activate-plugin_' . $plugin_file ) ); |
| 112 | $action = sprintf( '<a href="%1$s">%2$s</a>', $url, __( 'Activate' ) ); |
101 | 113 | } |
102 | 114 | } |
| 115 | |
103 | 116 | if ( empty($action) ) { |
104 | 117 | 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>'; |
| 118 | $url = esc_url( wp_nonce_url( add_query_arg( array( |
| 119 | 'action' => 'install-plugin', |
| 120 | 'plugin' => $plugin_slug, |
| 121 | 'from' => 'import', |
| 122 | ), self_admin_url( 'update.php' ) ), 'install-plugin_' . $plugin_slug ) ); |
| 123 | $action = sprintf( |
| 124 | '<a href="%1$s" class="install-now" data-slug="%2$s">%3$s</a>', |
| 125 | $url, |
| 126 | esc_attr( $plugin_slug ), |
| 127 | __( 'Install Now' ) |
| 128 | ); |
108 | 129 | } 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' ) ); |
| 130 | $action = sprintf( __( 'This importer is not installed. Please install importers from <a href="%s">the main site</a>.' ), |
| 131 | get_admin_url( get_current_network_id(), 'import.php' ) |
| 132 | ); |
111 | 133 | } |
| 134 | |
| 135 | $status = _x( 'Not installed', 'importer plugin' ); |
112 | 136 | } |
113 | 137 | } else { |
114 | | $action = "<a href='" . esc_url( "admin.php?import=$importer_id" ) . "' title='" . esc_attr( wptexturize( strip_tags( $data[1] ) ) ) ."'>{$data[0]}</a>"; |
| 138 | $status = _x( 'Active', 'importer plugin' ); |
| 139 | $status_class = ' importer-active'; |
| 140 | $url = esc_url( add_query_arg( array( |
| 141 | 'import' => $importer_id, |
| 142 | ), self_admin_url( 'admin.php' ) ) ); |
| 143 | $action = sprintf( '<a href="%1$s">%2$s</a>', $url, __( 'Run' ) ); |
| 144 | } |
| 145 | |
| 146 | if ( '' !== $plugin_slug ) { |
| 147 | $url = esc_url( add_query_arg( array( |
| 148 | 'tab' => 'plugin-information', |
| 149 | 'plugin' => $plugin_slug, |
| 150 | 'from' => 'import', |
| 151 | 'TB_iframe' => 'true', |
| 152 | 'width' => 600, |
| 153 | 'height' => 550, |
| 154 | ), network_admin_url( 'plugin-install.php' ) ) ); |
| 155 | $action .= sprintf( ' | <a href="%1$s" class="thickbox open-plugin-details-modal">%2$s</a>', $url, __( 'Details' ) ); |
115 | 156 | } |
116 | 157 | |
117 | 158 | echo " |
118 | | <tr> |
119 | | <td class='import-system row-title'>$action</td> |
120 | | <td class='desc'>{$data[1]}</td> |
| 159 | <tr class='importer-item{$status_class}'> |
| 160 | <td class='import-system'> |
| 161 | <span class='importer-title row-title'>{$data[0]}</span> |
| 162 | <span class='importer-action'>{$action}</span> |
| 163 | </td> |
| 164 | <td class='desc'> |
| 165 | <span class='importer-status'>{$status}</span> |
| 166 | <span class='importer-desc'>{$data[1]}</span> |
| 167 | </td> |
121 | 168 | </tr>"; |
122 | 169 | } |
123 | 170 | ?> |
diff --git src/wp-admin/includes/import.php src/wp-admin/includes/import.php
index fa980e6..5f2d944 100644
|
|
function wp_get_popular_importers() { |
157 | 157 | // slug => name, description, plugin slug, and register_importer() slug |
158 | 158 | 'blogger' => array( |
159 | 159 | 'name' => __( 'Blogger' ), |
160 | | 'description' => __( 'Install the Blogger importer to import posts, comments, and users from a Blogger blog.' ), |
| 160 | 'description' => __( 'Import posts, comments, and users from a Blogger blog.' ), |
161 | 161 | 'plugin-slug' => 'blogger-importer', |
162 | 162 | 'importer-id' => 'blogger', |
163 | 163 | ), |
164 | 164 | 'wpcat2tag' => array( |
165 | 165 | 'name' => __( 'Categories and Tags Converter' ), |
166 | | 'description' => __( 'Install the category/tag converter to convert existing categories to tags or tags to categories, selectively.' ), |
| 166 | 'description' => __( 'Convert existing categories to tags or tags to categories, selectively.' ), |
167 | 167 | 'plugin-slug' => 'wpcat2tag-importer', |
168 | 168 | 'importer-id' => 'wp-cat2tag', |
169 | 169 | ), |
170 | 170 | 'livejournal' => array( |
171 | 171 | 'name' => __( 'LiveJournal' ), |
172 | | 'description' => __( 'Install the LiveJournal importer to import posts from LiveJournal using their API.' ), |
| 172 | 'description' => __( 'Import posts from LiveJournal using their API.' ), |
173 | 173 | 'plugin-slug' => 'livejournal-importer', |
174 | 174 | 'importer-id' => 'livejournal', |
175 | 175 | ), |
176 | 176 | 'movabletype' => array( |
177 | 177 | 'name' => __( 'Movable Type and TypePad' ), |
178 | | 'description' => __( 'Install the Movable Type importer to import posts and comments from a Movable Type or TypePad blog.' ), |
| 178 | 'description' => __( 'Import posts and comments from a Movable Type or TypePad blog.' ), |
179 | 179 | 'plugin-slug' => 'movabletype-importer', |
180 | 180 | 'importer-id' => 'mt', |
181 | 181 | ), |
182 | 182 | 'opml' => array( |
183 | 183 | 'name' => __( 'Blogroll' ), |
184 | | 'description' => __( 'Install the blogroll importer to import links in OPML format.' ), |
| 184 | 'description' => __( 'Import links in OPML format.' ), |
185 | 185 | 'plugin-slug' => 'opml-importer', |
186 | 186 | 'importer-id' => 'opml', |
187 | 187 | ), |
188 | 188 | 'rss' => array( |
189 | 189 | 'name' => __( 'RSS' ), |
190 | | 'description' => __( 'Install the RSS importer to import posts from an RSS feed.' ), |
| 190 | 'description' => __( 'Import posts from an RSS feed.' ), |
191 | 191 | 'plugin-slug' => 'rss-importer', |
192 | 192 | 'importer-id' => 'rss', |
193 | 193 | ), |
194 | 194 | 'tumblr' => array( |
195 | 195 | 'name' => __( 'Tumblr' ), |
196 | | 'description' => __( 'Install the Tumblr importer to import posts & media from Tumblr using their API.' ), |
| 196 | 'description' => __( 'Import posts & media from Tumblr using their API.' ), |
197 | 197 | 'plugin-slug' => 'tumblr-importer', |
198 | 198 | 'importer-id' => 'tumblr', |
199 | 199 | ), |
200 | 200 | 'wordpress' => array( |
201 | 201 | 'name' => 'WordPress', |
202 | | 'description' => __( 'Install the WordPress importer to import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.' ), |
| 202 | 'description' => __( 'Import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.' ), |
203 | 203 | 'plugin-slug' => 'wordpress-importer', |
204 | 204 | 'importer-id' => 'wordpress', |
205 | 205 | ), |
diff --git src/wp-admin/js/updates.js src/wp-admin/js/updates.js
index 0de60b5..106bbc4 100644
|
|
|
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-modal updating-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 |
diff --git src/wp-includes/script-loader.php src/wp-includes/script-loader.php
index 2945b48..0b84e94 100644
|
|
function wp_default_scripts( &$scripts ) { |
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' => __( 'Activate' ), |
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.' ), |
diff --git tests/qunit/fixtures/updates.js tests/qunit/fixtures/updates.js
index d570aa6..54c5cb2 100644
|
|
window._wpUpdatesSettings = { |
38 | 38 | 'livePreview': 'Live Preview', |
39 | 39 | 'activatePlugin': 'Activate', |
40 | 40 | 'activateTheme': 'Activate', |
41 | | 'activateImporter': 'Activate importer', |
| 41 | 'activateImporter': 'Activate', |
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.' |