WordPress.org

Make WordPress Core

Changeset 14759


Ignore:
Timestamp:
05/20/10 19:20:25 (5 years ago)
Author:
ryan
Message:

Add install links to the importer list if popular importers are not present. see #13465

Location:
trunk/wp-admin
Files:
2 edited

Legend:

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

    r14491 r14759  
    1414if ( !defined('WP_ADMIN') ) 
    1515    define('WP_ADMIN', TRUE); 
     16 
     17if ( isset($_GET['import']) && !defined('WP_LOAD_IMPORTERS') ) 
     18    define('WP_LOAD_IMPORTERS', true); 
    1619 
    1720require_once(dirname(dirname(__FILE__)) . '/wp-load.php'); 
  • trunk/wp-admin/import.php

    r14313 r14759  
    77 */ 
    88 
     9define('WP_LOAD_IMPORTERS', true); 
     10 
    911/** Load WordPress Bootstrap */ 
    1012require_once ('admin.php'); 
     
    1416 
    1517$title = __('Import'); 
     18add_thickbox(); 
    1619require_once ('admin-header.php'); 
    1720$parent_file = 'tools.php'; 
     
    4043@closedir($imports_dir); 
    4144 
     45$popular_importers = array(); 
     46if ( current_user_can('install_plugins') ) 
     47    $popular_importers = array( 
     48        'blogger' => array( __('Blogger'), __('Install the Blogger importer to import posts, comments, and users from a Blogger blog.'), 'install' ), 
     49        'livejournal' => array( __( 'LiveJournal' ), __( 'Install the LiveJounral importer to import posts from LiveJournal using their API.' ), 'install' ), 
     50        'mt' => array( __('Movable Type and TypePad'), __('Install the Movable Type importer to import posts and comments from a Movable Type or TypePad blog.'), 'install' ), 
     51        'opml' => array( __('Blogroll'), __('Install the blogroll importer to import links in OPML format.'), 'install' ), 
     52        'rss' => array( __('RSS'), __('Install the RSS importer to import posts from an RSS feed.'), 'install' ), 
     53        'wordpress' => array( 'WordPress', __('Install the WordPress importer to import posts, pages, comments, custom fields, categories, and tags from a WordPress export file.'), 'install' ) 
     54    ); 
     55 
    4256$importers = get_importers(); 
     57 
     58// If a popular importer is not registered, create a dummy registration that links to the plugin installer. 
     59foreach ( array_keys($popular_importers) as $pop_importer ) { 
     60    if ( isset($importers[$pop_importer] ) ) 
     61        continue; 
     62 
     63    $importers[$pop_importer] = $popular_importers[$pop_importer]; 
     64} 
     65 
     66uasort($importers, create_function('$a, $b', 'return strcmp($a[0], $b[0]);')); 
    4367 
    4468if (empty ($importers)) { 
     
    5276    foreach ($importers as $id => $data) { 
    5377        $style = ('class="alternate"' == $style || 'class="alternate active"' == $style) ? '' : 'alternate'; 
    54         $action = "<a href='admin.php?import=$id' title='".wptexturize(strip_tags($data[1]))."'>{$data[0]}</a>"; 
     78        if ( 'install' == $data[2] ) { 
     79            $plugin_slug = $id . '-importer'; 
     80            $action = '<a href="' . admin_url('plugin-install.php?tab=plugin-information&amp;plugin=' . $plugin_slug . 
     81                                    '&amp;TB_iframe=true&amp;width=600&amp;height=550') . '" class="thickbox" title="' . 
     82                                    esc_attr__('Install importer') . '">' . $data[0] . '</a>'; 
     83        } else { 
     84            $action = "<a href='" . esc_url('admin.php?import=$id') . "' title='" . esc_attr( wptexturize(strip_tags($data[1])) ) ."'>{$data[0]}</a>"; 
     85        } 
    5586 
    5687        if ($style != '') 
     
    6798<?php 
    6899} 
     100 
     101if ( current_user_can('install_plugins') ) 
     102    echo '<p>' . sprintf('If the importer you need is not listed, <a href="%s">search the plugins directory</a> to see if an importer is available.', admin_url('plugin-install.php?tab=search&type=tag&s=importer') ) . '</p>'; 
    69103?> 
    70104 
Note: See TracChangeset for help on using the changeset viewer.