root/tags/2.1.2/wp-links-opml.php

Revision 4656, 1.4 kB (checked in by markjaquith, 2 years ago)

new function for escaping within attributes: attribute_escape()

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 <?php
2
3 if (empty($wp)) {
4     require_once('./wp-config.php');
5     wp();
6 }
7
8 header('Content-type: text/xml; charset=' . get_option('blog_charset'), true);
9 $link_cat = $_GET['link_cat'];
10 if ((empty ($link_cat)) || ($link_cat == 'all') || ($link_cat == '0')) {
11     $link_cat = '';
12 } else { // be safe
13     $link_cat = '' . urldecode($link_cat) . '';
14     $link_cat = intval($link_cat);
15 }
16 ?><?php echo '<?xml version="1.0"?'.">\n"; ?>
17 <!-- generator="wordpress/<?php bloginfo_rss('version') ?>" -->
18 <opml version="1.0">
19     <head>
20         <title>Links for <?php echo get_bloginfo('name').$cat_name ?></title>
21         <dateCreated><?php echo gmdate("D, d M Y H:i:s"); ?> GMT</dateCreated>
22     </head>
23     <body>
24 <?php
25
26 if (empty ($link_cat))
27     $cats = get_categories("type=link&hierarchical=0");
28 else
29     $cats = array (get_category($link_cat));
30
31 foreach ((array) $cats as $cat) {
32 ?>
33 <outline type="category" title="<?php echo attribute_escape($cat->cat_name); ?>">
34 <?php
35
36     $bookmarks = get_bookmarks("category={$cat->cat_ID}");
37     foreach ((array) $bookmarks as $bookmark) {
38 ?>
39     <outline text="<?php echo attribute_escape($bookmark->link_name); ?>" 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; ?>" />
40 <?php
41
42     }
43 ?>
44 </outline>
45 <?php
46
47 }
48 ?>
49 </body>
50 </opml>
Note: See TracBrowser for help on using the browser.