Make WordPress Core

Changeset 14985


Ignore:
Timestamp:
05/27/2010 11:04:08 AM (14 years ago)
Author:
dd32
Message:

Add Importer support to Plugin Install workflow, Offers to Activate Plugin & Run installer, and returning to Imports upon successful Importer Plugin Installation. See #13566

Location:
trunk/wp-admin
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/import.php

    r14970 r14985  
    2323    '<p>' . sprintf(__('<a href="%s">Support Forums</a>'), 'http://wordpress.org/support/') . '</p>'
    2424);
     25
     26$popular_importers = array();
     27if ( current_user_can('install_plugins') )
     28    $popular_importers = array(
     29        'blogger' => array( __('Blogger'), __('Install the Blogger importer to import posts, comments, and users from a Blogger blog.'), 'install' ),
     30        'wpcat2tag' => array(__('Categories and Tags Converter'), __('Install the category/tag converter to convert existing categories to tags or tags to categories, selectively.'), 'install', 'wp-cat2tag' ),
     31        'livejournal' => array( __( 'LiveJournal' ), __( 'Install the LiveJournal importer to import posts from LiveJournal using their API.' ), 'install' ),
     32        'movabletype' => array( __('Movable Type and TypePad'), __('Install the Movable Type importer to import posts and comments from a Movable Type or TypePad blog.'), 'install', 'mt' ),
     33        'opml' => array( __('Blogroll'), __('Install the blogroll importer to import links in OPML format.'), 'install' ),
     34        'rss' => array( __('RSS'), __('Install the RSS importer to import posts from an RSS feed.'), 'install' ),
     35        'wordpress' => array( 'WordPress', __('Install the WordPress importer to import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.'), 'install' )
     36    );
     37
     38if ( ! empty( $_GET['invalid'] ) && !empty($popular_importers[$_GET['invalid']][3]) ) {
     39    wp_redirect("import.php?import=" . $popular_importers[$_GET['invalid']][3]);
     40    exit;
     41}
    2542
    2643add_thickbox();
     
    5471@closedir($imports_dir);
    5572
    56 $popular_importers = array();
    57 if ( current_user_can('install_plugins') )
    58     $popular_importers = array(
    59         'blogger' => array( __('Blogger'), __('Install the Blogger importer to import posts, comments, and users from a Blogger blog.'), 'install' ),
    60         'wpcat2tag' => array(__('Categories and Tags Converter'), __('Install the category/tag converter to convert existing categories to tags or tags to categories, selectively.'), 'install', 'wp-cat2tag' ),
    61         'livejournal' => array( __( 'LiveJournal' ), __( 'Install the LiveJournal importer to import posts from LiveJournal using their API.' ), 'install' ),
    62         'movabletype' => array( __('Movable Type and TypePad'), __('Install the Movable Type importer to import posts and comments from a Movable Type or TypePad blog.'), 'install', 'mt' ),
    63         'opml' => array( __('Blogroll'), __('Install the blogroll importer to import links in OPML format.'), 'install' ),
    64         'rss' => array( __('RSS'), __('Install the RSS importer to import posts from an RSS feed.'), 'install' ),
    65         'wordpress' => array( 'WordPress', __('Install the WordPress importer to import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.'), 'install' )
    66     );
    67 
    6873$importers = get_importers();
    6974
     
    9398            $plugin_slug = $id . '-importer';
    9499            $action = '<a href="' . admin_url('plugin-install.php?tab=plugin-information&amp;plugin=' . $plugin_slug .
    95                                     '&amp;TB_iframe=true&amp;width=600&amp;height=550') . '" class="thickbox" title="' .
     100                                    '&amp;from=import&amp;TB_iframe=true&amp;width=600&amp;height=550') . '" class="thickbox" title="' .
    96101                                    esc_attr__('Install importer') . '">' . $data[0] . '</a>';
    97102        } else {
  • trunk/wp-admin/includes/class-wp-upgrader.php

    r14924 r14985  
    12621262        $plugin_file = $this->upgrader->plugin_info();
    12631263
    1264         $install_actions = array(
    1265             'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>',
    1266                             );
     1264        $install_actions = array();
     1265
     1266        $from = isset($_GET['from']) ? stripslashes($_GET['from']) : 'plugins';
     1267
     1268        if ( 'import' == $from )
     1269            $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;from=import&amp;plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin &amp; Run Importer') . '</a>';
     1270        else
     1271            $install_actions['activate_plugin'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>';
    12671272
    12681273        if ( is_multisite() && current_user_can( 'manage_network_plugins' ) )
    12691274            $install_actions['network_activate'] = '<a href="' . wp_nonce_url('plugins.php?action=activate&amp;networkwide=1&amp;plugin=' . $plugin_file, 'activate-plugin_' . $plugin_file) . '" title="' . __('Activate this plugin for all sites in this network') . '" target="_parent">' . __('Network Activate') . '</a>';
    12701275
    1271         if ( $this->type == 'web' )
     1276        if ( 'import' == $from )
     1277            $install_actions['importers_page'] = '<a href="' . admin_url('import.php') . '" title="' . esc_attr__('Return to Importers') . '" target="_parent">' . __('Return to Importers') . '</a>';
     1278        else if ( $this->type == 'web' )
    12721279            $install_actions['plugins_page'] = '<a href="' . admin_url('plugin-install.php') . '" title="' . esc_attr__('Return to Plugin Installer') . '" target="_parent">' . __('Return to Plugin Installer') . '</a>';
    12731280        else
  • trunk/wp-admin/includes/plugin-install.php

    r14647 r14985  
    474474        }
    475475    }
     476    if ( isset($_GET['from']) )
     477        $url .= '&amp;from=' . urlencode(stripslashes($_GET['from']));
    476478
    477479    return compact('status', 'url', 'version');
  • trunk/wp-admin/plugins.php

    r14956 r14985  
    5252            $result = activate_plugin($plugin, 'plugins.php?error=true&plugin=' . $plugin, $network_wide);
    5353            if ( is_wp_error( $result ) ) {
    54                 if ('unexpected_output' == $result->get_error_code()) {
     54                if ( 'unexpected_output' == $result->get_error_code() ) {
    5555                    $redirect = 'plugins.php?error=true&charsout=' . strlen($result->get_error_data()) . '&plugin=' . $plugin;
    5656                    wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect));
     
    6666                update_option('recently_activated', $recent);
    6767            }
    68 
    69             wp_redirect("plugins.php?activate=true&plugin_status=$status&paged=$page"); // overrides the ?error=true one above
     68            if ( isset($_GET['from']) && 'import' == $_GET['from'] ) {
     69                wp_redirect("import.php?import=" . str_replace('-importer', '', dirname($plugin)) ); // overrides the ?error=true one above and redirects to the Imports page, striping the -importer suffix
     70            } else {
     71                wp_redirect("plugins.php?activate=true&plugin_status=$status&paged=$page"); // overrides the ?error=true one above
     72            }
    7073            exit;
    7174            break;
     
    438441$total_dropins_plugins = count($dropins_plugins);
    439442
    440 //Searching.
     443// Searching.
    441444if ( !empty($_GET['s']) ) {
    442445    function _search_plugins_filter_callback($plugin) {
  • trunk/wp-admin/update.php

    r14348 r14985  
    111111        $nonce = 'install-plugin_' . $plugin;
    112112        $url = 'update.php?action=install-plugin&plugin=' . $plugin;
     113        if ( isset($_GET['from']) )
     114            $url .= '&from=' . urlencode(stripslashes($_GET['from']));
     115
    113116        $type = 'web'; //Install plugin type, From Web or an Upload.
    114117
Note: See TracChangeset for help on using the changeset viewer.