Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 63 lines (57 sloc) 2.002 kb
1cdc6a5 Update opml.
ryan authored
1 <?php
a6a1522 File file level phpdoc from jacobsantos. see #7037
ryan authored
2 /**
3 * Outputs the OPML XML format for getting the links defined in the link
4 * administration. This can be used to export links from one blog over to
5 * another. Links aren't exported by the WordPress export, so this file handles
6 * that.
7 *
8 * This file is not added by default to WordPress theme pages when outputting
9 * feed links. It will have to be added manually for browsers and users to pick
10 * up that this file exists.
11 *
12 * @package WordPress
13 */
1cdc6a5 Update opml.
ryan authored
14
973c124 Clean up OPML link export script.
dd32 authored
15 if ( empty($wp) ) {
5b81135 Allow wp-config.php to exist one level up from WordPress root directory....
ryan authored
16 require_once('./wp-load.php');
1cdc6a5 Update opml.
ryan authored
17 wp();
18 }
5ad9e0c First pass at OPML export of links.
mikelittle authored
19
9ce729e Content-Type, not Content-type, as headers are case sensitive. Props foo...
rob1n authored
20 header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
973c124 Clean up OPML link export script.
dd32 authored
21 $link_cat = '';
22 if ( !empty($_GET['link_cat']) ) {
23 $link_cat = $_GET['link_cat'];
24 if ( !in_array($link_cat, array('all', '0')) )
25 $link_cat = absint( (string)urldecode($link_cat) );
5ad9e0c First pass at OPML export of links.
mikelittle authored
26 }
973c124 Clean up OPML link export script.
dd32 authored
27
28 echo '<?xml version="1.0"?'.">\n";
29 ?>
5ad9e0c First pass at OPML export of links.
mikelittle authored
30 <opml version="1.0">
9f534eb Remove trailing spaces and convert spaces to tabs. Props Nazgul. fixes ...
ryan authored
31 <head>
973c124 Clean up OPML link export script.
dd32 authored
32 <title><?php printf( __('Links for %s'), esc_attr(get_bloginfo('name', 'display')) ); ?></title>
9f534eb Remove trailing spaces and convert spaces to tabs. Props Nazgul. fixes ...
ryan authored
33 <dateCreated><?php echo gmdate("D, d M Y H:i:s"); ?> GMT</dateCreated>
d8490ae Add the generator element in feeds through the {rss2|atom|rdf|rss|opml}_...
westi authored
34 <?php do_action('opml_head'); ?>
9f534eb Remove trailing spaces and convert spaces to tabs. Props Nazgul. fixes ...
ryan authored
35 </head>
36 <body>
5ad9e0c First pass at OPML export of links.
mikelittle authored
37 <?php
973c124 Clean up OPML link export script.
dd32 authored
38 if ( empty($link_cat) )
cedfa01 Use array calling style. Props Denis-de-Bernardy. see #6647
ryan authored
39 $cats = get_categories(array('type' => 'link', 'hierarchical' => 0));
1cdc6a5 Update opml.
ryan authored
40 else
cedfa01 Use array calling style. Props Denis-de-Bernardy. see #6647
ryan authored
41 $cats = get_categories(array('type' => 'link', 'hierarchical' => 0, 'include' => $link_cat));
1cdc6a5 Update opml.
ryan authored
42
973c124 Clean up OPML link export script.
dd32 authored
43 foreach ( (array)$cats as $cat ) :
3dc7205 Change cat_name, cat_ID to name, term_id.
ryan authored
44 $catname = apply_filters('link_category', $cat->name);
328afed Link filters from jhodgdon. fixes #3595
ryan authored
45
5ad9e0c First pass at OPML export of links.
mikelittle authored
46 ?>
6c2ffdd _a(), _ea(), _xa(), attr() are now esc_attr__(), esc_attr_e(), esc_attr_...
markjaquith authored
47 <outline type="category" title="<?php echo esc_attr($catname); ?>">
5ad9e0c First pass at OPML export of links.
mikelittle authored
48 <?php
cedfa01 Use array calling style. Props Denis-de-Bernardy. see #6647
ryan authored
49 $bookmarks = get_bookmarks(array("category" => $cat->term_id));
973c124 Clean up OPML link export script.
dd32 authored
50 foreach ( (array)$bookmarks as $bookmark ) :
51 $title = apply_filters('link_title', $bookmark->link_name);
5ad9e0c First pass at OPML export of links.
mikelittle authored
52 ?>
973c124 Clean up OPML link export script.
dd32 authored
53 <outline text="<?php echo esc_attr($title); ?>" type="link" xmlUrl="<?php echo esc_attr($bookmark->link_rss); ?>" htmlUrl="<?php echo esc_attr($bookmark->link_url); ?>" updated="<?php if ('0000-00-00 00:00:00' != $bookmark->link_updated) echo $bookmark->link_updated; ?>" />
5ad9e0c First pass at OPML export of links.
mikelittle authored
54 <?php
973c124 Clean up OPML link export script.
dd32 authored
55 endforeach; // $bookmarks
51944d9 Link OPML changes, fixes #2325
matt authored
56 ?>
1cdc6a5 Update opml.
ryan authored
57 </outline>
51944d9 Link OPML changes, fixes #2325
matt authored
58 <?php
973c124 Clean up OPML link export script.
dd32 authored
59 endforeach; // $cats
5ad9e0c First pass at OPML export of links.
mikelittle authored
60 ?>
51944d9 Link OPML changes, fixes #2325
matt authored
61 </body>
cc83c30 Allow wp-links-opml.php to return the links for just one category. Fixes...
westi authored
62 </opml>
Something went wrong with that request. Please try again.