<?php
/*
Set $show_all to 0 (zero) to hide links set to 'No' under Visible
in Links Manager, or 1 to display all links.
*/
$show_all = 1;
/*
To restrict to a specific link category add the link category ID
under $link_cats. Separate multiples with a comma ('1,3,5'). Use
'all' or leave $link_cats empty ('') for all link categories.
*/
$link_cats = '';
if( isset($_GET['cat']) )
$link_cats = $_GET['cat'];
require_once('./wp-config.php');
header('Content-type: text/xml; charset=' . get_settings('blog_charset'), true);
function rss_it($link_array, $column) {
$column = 'link_' . $column;
$linkdata = strip_tags($link_array->$column);
$linkdata = htmlspecialchars($linkdata, ENT_QUOTES);
$linkdata = convert_chars($linkdata);
echo $linkdata;
}
$owner = get_userdata(1);
$name = ($owner->display_name) ? convert_chars($owner->display_name) : convert_chars($owner->user_firstname) . ' ' . convert_chars($owner->user_lastname) ;
$email = convert_chars($owner->user_email);
?>
<?php echo '<?xml version="1.0" encoding="'.get_settings('blog_charset').'"?'.'>'; ?>
<!--Links2OPML - a WordPress script created by Kaf Oseo (http://szub.net)
OPML generated by WordPress/<?php bloginfo_rss('version'); ?> -->
<opml version="1.1">
<head>
<title><?php bloginfo_rss('blogname'); ?> blogroll</title>
<ownerName><?php echo $name; ?></ownerName>
<ownerEmail><?php echo $email; ?></ownerEmail>
<dateModified></dateModified>
</head>
<body>
<?php
$query = "SELECT link_url, link_name, link_target, link_description, link_rss FROM $wpdb->links";
if(!$show_all) {
$query .= " WHERE link_visible = 'Y'";
}
if($link_cats && !('all' == $link_cats)) {
$link_cats = preg_split("/[\s,]+/", $link_cats);
foreach($link_cats as $link_cat) {
if($show_all && !$count) {
$query .= " WHERE link_category = '$link_cat'";
$count++;
} else {
if(!$count) {
$query .= " AND link_category = '$link_cat'";
$count++;
} else {
$query .= " OR link_category = '$link_cat'";
}
}
}
}
$links = $wpdb->get_results($query);
foreach($links as $link) :
?>
<outline text="<?php rss_it($link, 'name'); ?>" type="link" description="<?php rss_it($link, 'description'); ?>" url="<?php rss_it($link, 'url'); ?>" xmlurl="<?php rss_it($link, 'rss'); ?>" target="<?php rss_it($link, 'target'); ?>" />
<?php endforeach; ?>
</body>
</opml>