Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 66 lines (57 sloc) 1.986 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
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);
10c6b7e Changed to superglobals, and eliminated $use_cache (since we always do).
saxmatt authored
21 $link_cat = $_GET['link_cat'];
1cdc6a5 Update opml.
ryan authored
22 if ((empty ($link_cat)) || ($link_cat == 'all') || ($link_cat == '0')) {
23 $link_cat = '';
5ad9e0c First pass at OPML export of links.
mikelittle authored
24 } else { // be safe
1cdc6a5 Update opml.
ryan authored
25 $link_cat = '' . urldecode($link_cat) . '';
26 $link_cat = intval($link_cat);
5ad9e0c First pass at OPML export of links.
mikelittle authored
27 }
9c87de2 Updating OPML feed.
saxmatt authored
28 ?><?php echo '<?xml version="1.0"?'.">\n"; ?>
e9cfb43 Centralise generator generation, move theme generator generation to wp-h...
westi authored
29 <?php the_generator( 'comment' ); ?>
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>
8d349aa Add some filtering. Props jhodgdon. fixes #3595
ryan authored
32 <title>Links for <?php echo attribute_escape(get_bloginfo('name', 'display').$cat_name); ?></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>
34 </head>
35 <body>
5ad9e0c First pass at OPML export of links.
mikelittle authored
36 <?php
1cdc6a5 Update opml.
ryan authored
37
38 if (empty ($link_cat))
39 $cats = get_categories("type=link&hierarchical=0");
40 else
cc83c30 Allow wp-links-opml.php to return the links for just one category. Fixes...
westi authored
41 $cats = get_categories('type=link&hierarchical=0&include='.$link_cat);
1cdc6a5 Update opml.
ryan authored
42
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 ?>
328afed Link filters from jhodgdon. fixes #3595
ryan authored
47 <outline type="category" title="<?php echo attribute_escape($catname); ?>">
5ad9e0c First pass at OPML export of links.
mikelittle authored
48 <?php
1cdc6a5 Update opml.
ryan authored
49
3dc7205 Change cat_name, cat_ID to name, term_id.
ryan authored
50 $bookmarks = get_bookmarks("category={$cat->term_id}");
1cdc6a5 Update opml.
ryan authored
51 foreach ((array) $bookmarks as $bookmark) {
328afed Link filters from jhodgdon. fixes #3595
ryan authored
52 $title = attribute_escape(apply_filters('link_title', $bookmark->link_name));
5ad9e0c First pass at OPML export of links.
mikelittle authored
53 ?>
328afed Link filters from jhodgdon. fixes #3595
ryan authored
54 <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; ?>" />
5ad9e0c First pass at OPML export of links.
mikelittle authored
55 <?php
1cdc6a5 Update opml.
ryan authored
56
57 }
51944d9 Link OPML changes, fixes #2325
matt authored
58 ?>
1cdc6a5 Update opml.
ryan authored
59 </outline>
51944d9 Link OPML changes, fixes #2325
matt authored
60 <?php
1cdc6a5 Update opml.
ryan authored
61
62 }
5ad9e0c First pass at OPML export of links.
mikelittle authored
63 ?>
51944d9 Link OPML changes, fixes #2325
matt authored
64 </body>
cc83c30 Allow wp-links-opml.php to return the links for just one category. Fixes...
westi authored
65 </opml>
Something went wrong with that request. Please try again.