Ticket #6393: wp_export_import_links.patch
| File wp_export_import_links.patch, 3.2 KB (added by , 18 years ago) |
|---|
-
wp-admin/link-import.php
100 100 101 101 include_once('link-parse-opml.php'); 102 102 103 $blogroll_cats = get_terms('link_category', 'get=all'); 104 foreach ($blogroll_cats as $category){ 105 $blogroll_categories[$category->name] = $category->term_id; 106 } 107 103 108 $link_count = count($names); 109 104 110 for ( $i = 0; $i < $link_count; $i++ ) { 111 112 if ( !$cat_id = is_term( $link_categories[$i], 'link_category' ) ) { 113 $cat_id = wp_insert_term( $link_categories[$i], 'link_category' ); 114 $cat_id = $cat_id['term_id']; 115 $blogroll_categories[$link_categories[$i]] = $cat_id; //adding item to an array of link_cateories from database 116 } 117 else { 118 $cat_id = (int) $blogroll_categories[$link_categories[$i]]; 119 } 120 105 121 if ('Last' == substr($titles[$i], 0, 4)) 106 122 $titles[$i] = ''; 107 123 if ( 'http' == substr($titles[$i], 0, 4) ) -
wp-admin/link-parse-opml.php
9 9 'TITLE' => 'link_name', 10 10 'TARGET' => 'link_target', 11 11 'DESCRIPTION' => 'link_description', 12 'XMLURL' => 'link_rss' 12 'XMLURL' => 'link_rss', 13 'CATEGORY' => 'category' 13 14 ); 14 15 15 16 $map = $opml_map; … … 20 21 **/ 21 22 function startElement($parser, $tagName, $attrs) { 22 23 global $updated_timestamp, $all_links, $map; 23 global $names, $urls, $targets, $descriptions, $feeds ;24 global $names, $urls, $targets, $descriptions, $feeds, $link_categories; 24 25 25 26 if ($tagName == 'OUTLINE') { 26 27 foreach (array_keys($map) as $key) { … … 37 38 $targets[] = $link_target; 38 39 $feeds[] = $link_rss; 39 40 $descriptions[] = $link_description; 41 $link_categories[] = $category; 40 42 } // end if outline 41 43 } 42 44 -
wp-links-opml.php
31 31 foreach ((array) $cats as $cat) { 32 32 $catname = apply_filters('link_category', $cat->name); 33 33 34 ?>35 <outline type="category" title="<?php echo attribute_escape($catname); ?>">36 <?php37 38 34 $bookmarks = get_bookmarks("category={$cat->term_id}"); 35 39 36 foreach ((array) $bookmarks as $bookmark) { 40 37 $title = attribute_escape(apply_filters('link_title', $bookmark->link_name)); 38 //adding category as an attribute to the outline. category is a valid attribute in OPML. 39 //so importer will create link_category if not exists in the database on the fly! 40 //generated OPML output has been validated on http://validator.opml.org/ 41 41 ?> 42 <outline text="<?php echo $title; ?>" type="link" xmlUrl="<?php echo attribute_escape($bookmark->link_rss); ?>" htmlUrl="<?php echo attribute_escape($bookmark->link_url); ?>" updated="<?php if ('0000-00-00 00:00:00' != $bookmark->link_updated) echo $bookmark->link_updated; ?>" />42 <outline text="<?php echo $title; ?>" type="link" url="<?php echo attribute_escape($bookmark->link_url); ?>" category="<?php echo $catname; ?>" /> 43 43 <?php 44 44 45 45 } 46 ?>47 </outline>48 <?php49 50 46 } 51 47 ?> 52 48 </body>
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)