<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[13747] trunk/wp-links-opml.php: Clean up OPML link export script.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13747">13747</a></dd>
<dt>Author</dt> <dd>dd32</dd>
<dt>Date</dt> <dd>2010-03-18 08:39:01 +0000 (Thu, 18 Mar 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Clean up OPML link export script.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwplinksopmlphp">trunk/wp-links-opml.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwplinksopmlphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-links-opml.php (13746 => 13747)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-links-opml.php        2010-03-18 07:58:53 UTC (rev 13746)
+++ trunk/wp-links-opml.php        2010-03-18 08:39:01 UTC (rev 13747)
</span><span class="lines">@@ -12,54 +12,51 @@
</span><span class="cx">  * @package WordPress
</span><span class="cx">  */
</span><span class="cx"> 
</span><del>-if (empty($wp)) {
</del><ins>+if ( empty($wp) ) {
</ins><span class="cx">         require_once('./wp-load.php');
</span><span class="cx">         wp();
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
</span><del>-$link_cat = $_GET['link_cat'];
-if ((empty ($link_cat)) || ($link_cat == 'all') || ($link_cat == '0')) {
-        $link_cat = '';
-} else { // be safe
-        $link_cat = '' . urldecode($link_cat) . '';
-        $link_cat = intval($link_cat);
</del><ins>+$link_cat = '';
+if ( !empty($_GET['link_cat']) ) {
+        $link_cat = $_GET['link_cat'];
+        if ( !in_array($link_cat, array('all', '0')) )
+                $link_cat = absint( (string)urldecode($link_cat) );
</ins><span class="cx"> }
</span><del>-?&gt;&lt;?php echo '&lt;?xml version=&quot;1.0&quot;?'.&quot;&gt;\n&quot;; ?&gt;
</del><ins>+
+echo '&lt;?xml version=&quot;1.0&quot;?'.&quot;&gt;\n&quot;;
+?&gt;
</ins><span class="cx"> &lt;opml version=&quot;1.0&quot;&gt;
</span><span class="cx">         &lt;head&gt;
</span><del>-                &lt;title&gt;Links for &lt;?php echo esc_attr(get_bloginfo('name', 'display').$cat_name); ?&gt;&lt;/title&gt;
</del><ins>+                &lt;title&gt;&lt;?php printf( __('Links for %s'), esc_attr(get_bloginfo('name', 'display')) ); ?&gt;&lt;/title&gt;
</ins><span class="cx">                 &lt;dateCreated&gt;&lt;?php echo gmdate(&quot;D, d M Y H:i:s&quot;); ?&gt; GMT&lt;/dateCreated&gt;
</span><span class="cx">                 &lt;?php do_action('opml_head'); ?&gt;
</span><span class="cx">         &lt;/head&gt;
</span><span class="cx">         &lt;body&gt;
</span><span class="cx"> &lt;?php
</span><del>-
-if (empty ($link_cat))
</del><ins>+if ( empty($link_cat) )
</ins><span class="cx">         $cats = get_categories(array('type' =&gt; 'link', 'hierarchical' =&gt; 0));
</span><span class="cx"> else
</span><span class="cx">         $cats = get_categories(array('type' =&gt; 'link', 'hierarchical' =&gt; 0, 'include' =&gt; $link_cat));
</span><span class="cx"> 
</span><del>-foreach ((array) $cats as $cat) {
</del><ins>+foreach ( (array)$cats as $cat ) :
</ins><span class="cx">         $catname = apply_filters('link_category', $cat-&gt;name);
</span><span class="cx"> 
</span><span class="cx"> ?&gt;
</span><span class="cx"> &lt;outline type=&quot;category&quot; title=&quot;&lt;?php echo esc_attr($catname); ?&gt;&quot;&gt;
</span><span class="cx"> &lt;?php
</span><del>-
</del><span class="cx">         $bookmarks = get_bookmarks(array(&quot;category&quot; =&gt; $cat-&gt;term_id));
</span><del>-        foreach ((array) $bookmarks as $bookmark) {
-                $title = esc_attr(apply_filters('link_title', $bookmark-&gt;link_name));
</del><ins>+        foreach ( (array)$bookmarks as $bookmark ) :
+                $title = apply_filters('link_title', $bookmark-&gt;link_name);
</ins><span class="cx"> ?&gt;
</span><del>-        &lt;outline text=&quot;&lt;?php echo $title; ?&gt;&quot; type=&quot;link&quot; xmlUrl=&quot;&lt;?php echo esc_attr($bookmark-&gt;link_rss); ?&gt;&quot; htmlUrl=&quot;&lt;?php echo esc_attr($bookmark-&gt;link_url); ?&gt;&quot; updated=&quot;&lt;?php if ('0000-00-00 00:00:00' != $bookmark-&gt;link_updated) echo $bookmark-&gt;link_updated; ?&gt;&quot; /&gt;
</del><ins>+        &lt;outline text=&quot;&lt;?php echo esc_attr($title); ?&gt;&quot; type=&quot;link&quot; xmlUrl=&quot;&lt;?php echo esc_attr($bookmark-&gt;link_rss); ?&gt;&quot; htmlUrl=&quot;&lt;?php echo esc_attr($bookmark-&gt;link_url); ?&gt;&quot; updated=&quot;&lt;?php if ('0000-00-00 00:00:00' != $bookmark-&gt;link_updated) echo $bookmark-&gt;link_updated; ?&gt;&quot; /&gt;
</ins><span class="cx"> &lt;?php
</span><del>-
-        }
</del><ins>+        endforeach; // $bookmarks
</ins><span class="cx"> ?&gt;
</span><span class="cx"> &lt;/outline&gt;
</span><span class="cx"> &lt;?php
</span><del>-
-}
</del><ins>+endforeach; // $cats
</ins><span class="cx"> ?&gt;
</span><span class="cx"> &lt;/body&gt;
</span><span class="cx"> &lt;/opml&gt;
</span></span></pre>
</div>
</div>

</body>
</html>