Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 61 lines (60 sloc) 2.363 kb
5ad9e0c First pass at OPML export of links.
mikelittle authored
1 <?php
2 $doing_rss = 1;
3
2d78e31 Vanquishing the terror of iso-8859-1.
saxmatt authored
4 require('wp-blog-header.php');
5 header('Content-type: text/xml; charset=' . get_settings('blog_charset'), true);
10c6b7e Changed to superglobals, and eliminated $use_cache (since we always do).
saxmatt authored
6 $link_cat = $_GET['link_cat'];
5ad9e0c First pass at OPML export of links.
mikelittle authored
7 if ((empty($link_cat)) || ($link_cat == 'all') || ($link_cat == '0')) {
8 $sql_cat = '';
9 } else { // be safe
10 $link_cat = ''.urldecode($link_cat).'';
11 $link_cat = addslashes_gpc($link_cat);
12 $link_cat = intval($link_cat);
13 if ($link_cat != 0) {
25ae03e Giant commit, sorry mailing list people. Move all table names to new $wp...
saxmatt authored
14 $sql_cat = "AND $wpdb->links.link_category = $link_cat";
15 $cat_name = $wpdb->get_var("SELECT $wpdb->linkcategories.cat_name FROM $wpdb->linkcategories WHERE $wpdb->linkcategories.cat_id = $link_cat");
5ad9e0c First pass at OPML export of links.
mikelittle authored
16 if (!empty($cat_name)) {
17 $cat_name = ": category $cat_name";
18 }
19 }
20 }
9c87de2 Updating OPML feed.
saxmatt authored
21 ?><?php echo '<?xml version="1.0"?'.">\n"; ?>
5ad9e0c First pass at OPML export of links.
mikelittle authored
22 <!-- generator="wordpress/<?php echo $wp_version ?>" -->
23 <opml version="1.0">
24 <head>
25 <title>Links for <?php echo get_bloginfo('name').$cat_name ?></title>
26 <dateCreated><?php echo gmdate("D, d M Y H:i:s"); ?> GMT</dateCreated>
27 </head>
28 <body>
9c87de2 Updating OPML feed.
saxmatt authored
29 <?php $sql = "SELECT $wpdb->links.link_url, link_rss, $wpdb->links.link_name, $wpdb->links.link_category, $wpdb->linkcategories.cat_name, link_updated
25ae03e Giant commit, sorry mailing list people. Move all table names to new $wp...
saxmatt authored
30 FROM $wpdb->links
3881ccd Older MySQL versions need "INNER" to be specified
markjaquith authored
31 INNER JOIN $wpdb->linkcategories on $wpdb->links.link_category = $wpdb->linkcategories.cat_id
51944d9 Link OPML changes, fixes #2325
matt authored
32 AND $wpdb->links.link_visible = 'Y'
db9aece Show RSS URIs in OPML file.
saxmatt authored
33 $sql_cat
25ae03e Giant commit, sorry mailing list people. Move all table names to new $wp...
saxmatt authored
34 ORDER BY $wpdb->linkcategories.cat_name, $wpdb->links.link_name \n";
5ad9e0c First pass at OPML export of links.
mikelittle authored
35 //echo("<!-- $sql -->");
36 $prev_cat_id = 0;
37 $results = $wpdb->get_results($sql);
38 if ($results) {
39 foreach ($results as $result) {
40 if ($result->link_category != $prev_cat_id) { // new category
41 if ($prev_cat_id != 0) { // not first time
42 ?>
43 </outline>
44 <?php
45 } // end if not first time
46 ?>
be708ef new function for escaping within attributes: attribute_escape()
markjaquith authored
47 <outline type="category" title="<?php echo attribute_escape($result->cat_name); ?>">
5ad9e0c First pass at OPML export of links.
mikelittle authored
48 <?php
49 $prev_cat_id = $result->link_category;
50 } // end if new category
51 ?>
be708ef new function for escaping within attributes: attribute_escape()
markjaquith authored
52 <outline text="<?php echo attribute_escape($result->link_name); ?>" type="link" xmlUrl="<?php echo attribute_escape($result->link_rss); ?>" htmlUrl="<?php echo attribute_escape($result->link_url); ?>" updated="<?php if ('0000-00-00 00:00:00' != $result->link_updated) echo $result->link_updated; ?>" />
5ad9e0c First pass at OPML export of links.
mikelittle authored
53 <?php
54 } // end foreach
51944d9 Link OPML changes, fixes #2325
matt authored
55 ?>
56 </outline>
57 <?php
5ad9e0c First pass at OPML export of links.
mikelittle authored
58 } // end if
59 ?>
51944d9 Link OPML changes, fixes #2325
matt authored
60 </body>
5ad9e0c First pass at OPML export of links.
mikelittle authored
61 </opml>
Something went wrong with that request. Please try again.