Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/wp-admin/link-import.php

    r4734 r5438  
    1313<?php
    1414switch ($step) {
    15     case 0:
    16     {
    17         include_once('admin-header.php');
    18         if ( !current_user_can('manage_links') )
    19             wp_die(__('Cheatin&#8217; uh?'));
     15    case 0: {
     16        include_once('admin-header.php');
     17        if ( !current_user_can('manage_links') )
     18            wp_die(__('Cheatin&#8217; uh?'));
    2019
    21         $opmltype = 'blogrolling'; // default.
     20        $opmltype = 'blogrolling'; // default.
    2221?>
    2322
    2423<div class="wrap">
     24
    2525<h2><?php _e('Import your blogroll from another system') ?> </h2>
    2626<form enctype="multipart/form-data" action="link-import.php" method="post" name="blogroll">
     
    4141</div>
    4242
    43 
    4443</div>
    4544
     
    5049foreach ($categories as $category) {
    5150?>
    52 <option value="<?php echo $category->cat_ID; ?>"><?php echo wp_specialchars($category->cat_name); ?></option>
     51<option value="<?php echo $category->cat_ID; ?>"><?php echo wp_specialchars(apply_filters('link_category', $category->cat_name)); ?></option>
    5352<?php
    5453} // end foreach
     
    6160</div>
    6261<?php
    63                 break;
    64             } // end case 0
     62        break;
     63    } // end case 0
    6564
    66     case 1: {
     65    case 1: {
    6766        check_admin_referer('import-bookmarks');
    6867
    69                 include_once('admin-header.php');
    70                 if ( !current_user_can('manage_links') )
    71                     wp_die(__('Cheatin&#8217; uh?'));
     68        include_once('admin-header.php');
     69        if ( !current_user_can('manage_links') )
     70            wp_die(__('Cheatin&#8217; uh?'));
    7271?>
    7372<div class="wrap">
    7473
    75      <h2><?php _e('Importing...') ?></h2>
     74<h2><?php _e('Importing...') ?></h2>
    7675<?php
    77                 $cat_id = $_POST['cat_id'];
    78                 if (($cat_id == '') || ($cat_id == 0)) {
    79                     $cat_id  = 1;
    80                 }
     76        $cat_id = $_POST['cat_id'];
     77        if ( $cat_id == '' || $cat_id == 0 )
     78            $cat_id  = 1;
    8179
    82                 $opml_url = $_POST['opml_url'];
    83                 if (isset($opml_url) && $opml_url != '' && $opml_url != 'http://') {
    84                     $blogrolling = true;
    85                 }
    86                 else // try to get the upload file.
    87                 {
    88                     $overrides = array('test_form' => false, 'test_type' => false);
    89                     $file = wp_handle_upload($_FILES['userfile'], $overrides);
     80        $opml_url = $_POST['opml_url'];
     81        if ( isset($opml_url) && $opml_url != '' && $opml_url != 'http://' ) {
     82            $blogrolling = true;
     83        } else { // try to get the upload file.
     84            $overrides = array('test_form' => false, 'test_type' => false);
     85            $file = wp_handle_upload($_FILES['userfile'], $overrides);
    9086
    91                     if ( isset($file['error']) )
    92                         wp_die($file['error']);
     87            if ( isset($file['error']) )
     88                wp_die($file['error']);
    9389
    94                     $url = $file['url'];
    95                     $opml_url = $file['file'];
    96                     $blogrolling = false;
    97                 }
     90            $url = $file['url'];
     91            $opml_url = $file['file'];
     92            $blogrolling = false;
     93        }
    9894
    99                 if (isset($opml_url) && $opml_url != '') {
    100                     $opml = wp_remote_fopen($opml_url);
    101                     include_once('link-parse-opml.php');
     95        if ( isset($opml_url) && $opml_url != '' ) {
     96            if ( $blogrolling === true ) {
     97                $opml = wp_remote_fopen($opml_url);
     98            } else {
     99                $opml = file_get_contents($opml_url);
     100            }
     101           
     102            include_once('link-parse-opml.php');
    102103
    103                     $link_count = count($names);
    104                     for ($i = 0; $i < $link_count; $i++) {
    105                         if ('Last' == substr($titles[$i], 0, 4))
    106                             $titles[$i] = '';
    107                         if ('http' == substr($titles[$i], 0, 4))
    108                             $titles[$i] = '';
    109                         $link = array( 'link_url' => $urls[$i], 'link_name' => $wpdb->escape($names[$i]), 'link_category' => array($cat_id), 'link_description' => $wpdb->escape($descriptions[$i]), 'link_owner' => $user_ID, 'link_rss' => $feeds[$i]);                       
    110                         wp_insert_link($link);
    111                         echo sprintf('<p>'.__('Inserted <strong>%s</strong>').'</p>', $names[$i]);
    112                     }
     104            $link_count = count($names);
     105            for ( $i = 0; $i < $link_count; $i++ ) {
     106                if ('Last' == substr($titles[$i], 0, 4))
     107                    $titles[$i] = '';
     108                if ( 'http' == substr($titles[$i], 0, 4) )
     109                    $titles[$i] = '';
     110                $link = array( 'link_url' => $urls[$i], 'link_name' => $wpdb->escape($names[$i]), 'link_category' => array($cat_id), 'link_description' => $wpdb->escape($descriptions[$i]), 'link_owner' => $user_ID, 'link_rss' => $feeds[$i]);
     111                wp_insert_link($link);
     112                echo sprintf('<p>'.__('Inserted <strong>%s</strong>').'</p>', $names[$i]);
     113            }
    113114?>
    114      <p><?php printf(__('Inserted %1$d links into category %2$s. All done! Go <a href="%3$s">manage those links</a>.'), $link_count, $cat_id, 'link-manager.php') ?></p>
     115
     116<p><?php printf(__('Inserted %1$d links into category %2$s. All done! Go <a href="%3$s">manage those links</a>.'), $link_count, $cat_id, 'link-manager.php') ?></p>
     117
    115118<?php
    116                 } // end if got url
    117                 else
    118                 {
    119                     echo "<p>" . __("You need to supply your OPML url. Press back on your browser and try again") . "</p>\n";
    120                 } // end else
     119} // end if got url
     120else
     121{
     122    echo "<p>" . __("You need to supply your OPML url. Press back on your browser and try again") . "</p>\n";
     123} // end else
    121124
    122                 if ( ! $blogrolling )
    123                     @unlink($opml_url);
     125if ( ! $blogrolling )
     126    apply_filters( 'wp_delete_file', $opml_url);
     127    @unlink($opml_url);
    124128?>
    125129</div>
    126130<?php
    127                 break;
    128             } // end case 1
     131        break;
     132    } // end case 1
    129133} // end switch
    130134
Note: See TracChangeset for help on using the changeset viewer.