web/wp-links-opml.php
changeset 194 32102edaa81b
parent 136 bde1974c263b
equal deleted inserted replaced
193:2f6f6f7551ca 194:32102edaa81b
    10  * up that this file exists.
    10  * up that this file exists.
    11  *
    11  *
    12  * @package WordPress
    12  * @package WordPress
    13  */
    13  */
    14 
    14 
    15 if (empty($wp)) {
    15 require_once('./wp-load.php');
    16 	require_once('./wp-load.php');
    16 
    17 	wp();
    17 header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
       
    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) );
    18 }
    23 }
    19 
    24 
    20 header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
    25 echo '<?xml version="1.0"?'.">\n";
    21 $link_cat = $_GET['link_cat'];
    26 ?>
    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);
       
    27 }
       
    28 ?><?php echo '<?xml version="1.0"?'.">\n"; ?>
       
    29 <?php the_generator( 'comment' ); ?>
       
    30 <opml version="1.0">
    27 <opml version="1.0">
    31 	<head>
    28 	<head>
    32 		<title>Links for <?php echo esc_attr(get_bloginfo('name', 'display').$cat_name); ?></title>
    29 		<title><?php printf( __('Links for %s'), esc_attr(get_bloginfo('name', 'display')) ); ?></title>
    33 		<dateCreated><?php echo gmdate("D, d M Y H:i:s"); ?> GMT</dateCreated>
    30 		<dateCreated><?php echo gmdate("D, d M Y H:i:s"); ?> GMT</dateCreated>
       
    31 		<?php do_action('opml_head'); ?>
    34 	</head>
    32 	</head>
    35 	<body>
    33 	<body>
    36 <?php
    34 <?php
       
    35 if ( empty($link_cat) )
       
    36 	$cats = get_categories(array('taxonomy' => 'link_category', 'hierarchical' => 0));
       
    37 else
       
    38 	$cats = get_categories(array('taxonomy' => 'link_category', 'hierarchical' => 0, 'include' => $link_cat));
    37 
    39 
    38 if (empty ($link_cat))
    40 foreach ( (array)$cats as $cat ) :
    39 	$cats = get_categories("type=link&hierarchical=0");
       
    40 else
       
    41 	$cats = get_categories('type=link&hierarchical=0&include='.$link_cat);
       
    42 
       
    43 foreach ((array) $cats as $cat) {
       
    44 	$catname = apply_filters('link_category', $cat->name);
    41 	$catname = apply_filters('link_category', $cat->name);
    45 
    42 
    46 ?>
    43 ?>
    47 <outline type="category" title="<?php echo esc_attr($catname); ?>">
    44 <outline type="category" title="<?php echo esc_attr($catname); ?>">
    48 <?php
    45 <?php
    49 
    46 	$bookmarks = get_bookmarks(array("category" => $cat->term_id));
    50 	$bookmarks = get_bookmarks("category={$cat->term_id}");
    47 	foreach ( (array)$bookmarks as $bookmark ) :
    51 	foreach ((array) $bookmarks as $bookmark) {
    48 		$title = apply_filters('link_title', $bookmark->link_name);
    52 		$title = esc_attr(apply_filters('link_title', $bookmark->link_name));
       
    53 ?>
    49 ?>
    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; ?>" />
    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; ?>" />
    55 <?php
    51 <?php
    56 
    52 	endforeach; // $bookmarks
    57 	}
       
    58 ?>
    53 ?>
    59 </outline>
    54 </outline>
    60 <?php
    55 <?php
    61 
    56 endforeach; // $cats
    62 }
       
    63 ?>
    57 ?>
    64 </body>
    58 </body>
    65 </opml>
    59 </opml>