Changes from trunk/wp-admin/link-import.php at r4734 to branches/2.2/wp-admin/link-import.php at r5438
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2/wp-admin/link-import.php
r4734 r5438 13 13 <?php 14 14 switch ($step) { 15 case 0: 16 { 17 include_once('admin-header.php'); 18 if ( !current_user_can('manage_links') ) 19 wp_die(__('Cheatin’ uh?')); 15 case 0: { 16 include_once('admin-header.php'); 17 if ( !current_user_can('manage_links') ) 18 wp_die(__('Cheatin’ uh?')); 20 19 21 20 $opmltype = 'blogrolling'; // default. 22 21 ?> 23 22 24 23 <div class="wrap"> 24 25 25 <h2><?php _e('Import your blogroll from another system') ?> </h2> 26 26 <form enctype="multipart/form-data" action="link-import.php" method="post" name="blogroll"> … … 41 41 </div> 42 42 43 44 43 </div> 45 44 … … 50 49 foreach ($categories as $category) { 51 50 ?> 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> 53 52 <?php 54 53 } // end foreach … … 61 60 </div> 62 61 <?php 63 64 62 break; 63 } // end case 0 65 64 66 65 case 1: { 67 66 check_admin_referer('import-bookmarks'); 68 67 69 70 71 68 include_once('admin-header.php'); 69 if ( !current_user_can('manage_links') ) 70 wp_die(__('Cheatin’ uh?')); 72 71 ?> 73 72 <div class="wrap"> 74 73 75 74 <h2><?php _e('Importing...') ?></h2> 76 75 <?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; 81 79 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); 90 86 91 92 87 if ( isset($file['error']) ) 88 wp_die($file['error']); 93 89 94 95 96 97 90 $url = $file['url']; 91 $opml_url = $file['file']; 92 $blogrolling = false; 93 } 98 94 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'); 102 103 103 104 for ($i = 0; $i < $link_count; $i++) {105 106 107 if ('http' == substr($titles[$i], 0, 4))108 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 111 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 } 113 114 ?> 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 115 118 <?php 116 117 118 119 120 119 } // end if got url 120 else 121 { 122 echo "<p>" . __("You need to supply your OPML url. Press back on your browser and try again") . "</p>\n"; 123 } // end else 121 124 122 if ( ! $blogrolling ) 123 @unlink($opml_url); 125 if ( ! $blogrolling ) 126 apply_filters( 'wp_delete_file', $opml_url); 127 @unlink($opml_url); 124 128 ?> 125 129 </div> 126 130 <?php 127 128 131 break; 132 } // end case 1 129 133 } // end switch 130 134
Note: See TracChangeset
for help on using the changeset viewer.