Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 59 lines (54 sloc) 1.997 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
fa9f9ed Do not Query for posts on OPML exports, Fixes OPML export script 404'ing...
dd32 authored
15 require_once('./wp-load.php');
5ad9e0c First pass at OPML export of links.
mikelittle authored
16
9ce729e Content-Type, not Content-type, as headers are case sensitive. Props foo...
rob1n authored
17 header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
973c124 Clean up OPML link export script.
dd32 authored
18 $link_cat = '';
19 if ( !empty($_GET['link_cat']) ) {
20 $link_cat = $_GET['link_cat'];
21 if ( !in_array($link_cat, array('all', '0')) )
22 $link_cat = absint( (string)urldecode($link_cat) );
5ad9e0c First pass at OPML export of links.
mikelittle authored
23 }
973c124 Clean up OPML link export script.
dd32 authored
24
25 echo '<?xml version="1.0"?'.">\n";
26 ?>
5ad9e0c First pass at OPML export of links.
mikelittle authored
27 <opml version="1.0">
9f534eb Remove trailing spaces and convert spaces to tabs. Props Nazgul. fixes ...
ryan authored
28 <head>
973c124 Clean up OPML link export script.
dd32 authored
29 <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
30 <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
31 <?php do_action('opml_head'); ?>
9f534eb Remove trailing spaces and convert spaces to tabs. Props Nazgul. fixes ...
ryan authored
32 </head>
33 <body>
5ad9e0c First pass at OPML export of links.
mikelittle authored
34 <?php
973c124 Clean up OPML link export script.
dd32 authored
35 if ( empty($link_cat) )
a3df4e0 Do not use deprecated argument in wp-links-opml.php. See #15195
dd32 authored
36 $cats = get_categories(array('taxonomy' => 'link_category', 'hierarchical' => 0));
1cdc6a5 Update opml.
ryan authored
37 else
a3df4e0 Do not use deprecated argument in wp-links-opml.php. See #15195
dd32 authored
38 $cats = get_categories(array('taxonomy' => 'link_category', 'hierarchical' => 0, 'include' => $link_cat));
1cdc6a5 Update opml.
ryan authored
39
973c124 Clean up OPML link export script.
dd32 authored
40 foreach ( (array)$cats as $cat ) :
3dc7205 Change cat_name, cat_ID to name, term_id.
ryan authored
41 $catname = apply_filters('link_category', $cat->name);
328afed Link filters from jhodgdon. fixes #3595
ryan authored
42
5ad9e0c First pass at OPML export of links.
mikelittle authored
43 ?>
6c2ffdd _a(), _ea(), _xa(), attr() are now esc_attr__(), esc_attr_e(), esc_attr_...
markjaquith authored
44 <outline type="category" title="<?php echo esc_attr($catname); ?>">
5ad9e0c First pass at OPML export of links.
mikelittle authored
45 <?php
cedfa01 Use array calling style. Props Denis-de-Bernardy. see #6647
ryan authored
46 $bookmarks = get_bookmarks(array("category" => $cat->term_id));
973c124 Clean up OPML link export script.
dd32 authored
47 foreach ( (array)$bookmarks as $bookmark ) :
48 $title = apply_filters('link_title', $bookmark->link_name);
5ad9e0c First pass at OPML export of links.
mikelittle authored
49 ?>
973c124 Clean up OPML link export script.
dd32 authored
50 <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
51 <?php
973c124 Clean up OPML link export script.
dd32 authored
52 endforeach; // $bookmarks
51944d9 Link OPML changes, fixes #2325
matt authored
53 ?>
1cdc6a5 Update opml.
ryan authored
54 </outline>
51944d9 Link OPML changes, fixes #2325
matt authored
55 <?php
973c124 Clean up OPML link export script.
dd32 authored
56 endforeach; // $cats
5ad9e0c First pass at OPML export of links.
mikelittle authored
57 ?>
51944d9 Link OPML changes, fixes #2325
matt authored
58 </body>
fa9f9ed Do not Query for posts on OPML exports, Fixes OPML export script 404'ing...
dd32 authored
59 </opml>
Something went wrong with that request. Please try again.