Changeset 38075 for trunk/src/wp-admin/import.php
- Timestamp:
- 07/17/2016 03:31:29 PM (10 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-admin/import.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)