Make WordPress Core

Changeset 13747


Ignore:
Timestamp:
03/18/2010 08:39:01 AM (15 years ago)
Author:
dd32
Message:

Clean up OPML link export script.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-links-opml.php

    r13113 r13747  
    1313 */
    1414
    15 if (empty($wp)) {
     15if ( empty($wp) ) {
    1616    require_once('./wp-load.php');
    1717    wp();
     
    1919
    2020header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
    21 $link_cat = $_GET['link_cat'];
    22 if ((empty ($link_cat)) || ($link_cat == 'all') || ($link_cat == '0')) {
    23     $link_cat = '';
    24 } else { // be safe
    25     $link_cat = '' . urldecode($link_cat) . '';
    26     $link_cat = intval($link_cat);
     21$link_cat = '';
     22if ( !empty($_GET['link_cat']) ) {
     23    $link_cat = $_GET['link_cat'];
     24    if ( !in_array($link_cat, array('all', '0')) )
     25        $link_cat = absint( (string)urldecode($link_cat) );
    2726}
    28 ?><?php echo '<?xml version="1.0"?'.">\n"; ?>
     27
     28echo '<?xml version="1.0"?'.">\n";
     29?>
    2930<opml version="1.0">
    3031    <head>
    31         <title>Links for <?php echo esc_attr(get_bloginfo('name', 'display').$cat_name); ?></title>
     32        <title><?php printf( __('Links for %s'), esc_attr(get_bloginfo('name', 'display')) ); ?></title>
    3233        <dateCreated><?php echo gmdate("D, d M Y H:i:s"); ?> GMT</dateCreated>
    3334        <?php do_action('opml_head'); ?>
     
    3536    <body>
    3637<?php
    37 
    38 if (empty ($link_cat))
     38if ( empty($link_cat) )
    3939    $cats = get_categories(array('type' => 'link', 'hierarchical' => 0));
    4040else
    4141    $cats = get_categories(array('type' => 'link', 'hierarchical' => 0, 'include' => $link_cat));
    4242
    43 foreach ((array) $cats as $cat) {
     43foreach ( (array)$cats as $cat ) :
    4444    $catname = apply_filters('link_category', $cat->name);
    4545
     
    4747<outline type="category" title="<?php echo esc_attr($catname); ?>">
    4848<?php
    49 
    5049    $bookmarks = get_bookmarks(array("category" => $cat->term_id));
    51     foreach ((array) $bookmarks as $bookmark) {
    52         $title = esc_attr(apply_filters('link_title', $bookmark->link_name));
     50    foreach ( (array)$bookmarks as $bookmark ) :
     51        $title = apply_filters('link_title', $bookmark->link_name);
    5352?>
    54     <outline text="<?php echo $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; ?>" />
     53    <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; ?>" />
    5554<?php
    56 
    57     }
     55    endforeach; // $bookmarks
    5856?>
    5957</outline>
    6058<?php
    61 
    62 }
     59endforeach; // $cats
    6360?>
    6461</body>
Note: See TracChangeset for help on using the changeset viewer.