| 1 |
<?php |
| 2 |
|
| 3 |
function link_library_generate_rss_preview( $my_link_library_plugin ) { |
| 4 |
$linkid = intval( $_GET['linkid'] ); |
| 5 |
$itemcount = intval( $_GET['previewcount'] ); |
| 6 |
|
| 7 |
$link_rss = get_post_meta( $linkid, 'link_rss', true ); |
| 8 |
$link_url = get_post_meta( $linkid, 'link_url', true ); |
| 9 |
$link = get_post( $linkid ); |
| 10 |
|
| 11 |
$genoptions = get_option('LinkLibraryGeneral'); |
| 12 |
|
| 13 |
include_once(ABSPATH . WPINC . '/feed.php'); |
| 14 |
|
| 15 |
if ( !empty( $link_rss ) && !empty( $link ) ) { |
| 16 |
// Get a SimplePie feed object from the specified feed source. |
| 17 |
$rss = fetch_feed( $link_rss ); |
| 18 |
if ( !is_wp_error( $rss ) ) { // Checks that the object is created correctly |
| 19 |
// Figure out how many total items there are, but limit it to 5. |
| 20 |
$maxitems = $rss->get_item_quantity( $itemcount ); |
| 21 |
|
| 22 |
// Build an array of all the items, starting with element 0 (first element). |
| 23 |
$rss_items = $rss->get_items( 0, $maxitems ); |
| 24 |
|
| 25 |
} |
| 26 |
?> |
| 27 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| 28 |
|
| 29 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
| 30 |
<head> |
| 31 |
<title><?php echo ( empty( $_GET['feed'] ) ) ? 'RSS_PHP' : 'RSS_PHP: ' . $link->post_title; ?></title> |
| 32 |
|
| 33 |
<!-- META HTTP-EQUIV --> |
| 34 |
<meta http-equiv="content-type" content="text/html; charset=UTF-8; ?>" /> |
| 35 |
<meta http-equiv="imagetoolbar" content="false" /> |
| 36 |
|
| 37 |
<?php if ( isset( $genoptions['stylesheet'] ) && !empty( $genoptions['stylesheet'] ) ) { ?> |
| 38 |
<style id='LinkLibraryStyle' type='text/css'> |
| 39 |
<?php echo stripslashes( $genoptions['fullstylesheet'] ); ?> |
| 40 |
</style> |
| 41 |
<?php } ?> |
| 42 |
|
| 43 |
</head> |
| 44 |
|
| 45 |
<body> |
| 46 |
<div id="ll_rss_preview_results"> |
| 47 |
<?php if ( $rss_items ) { ?> |
| 48 |
<?php foreach($rss_items as $item): ?> |
| 49 |
<div class="ll_rss_preview_title" style="padding:0 5px 5px;"> |
| 50 |
<h1><a target="feedwindow" href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a><div class='ll_rss_preview_date'><?php echo $item->get_date('j F Y | g:i a'); ?></div></h1> |
| 51 |
<div class='ll_rss_preview_content'><?php echo $item->get_description(); ?></div> |
| 52 |
</div> |
| 53 |
<br /> |
| 54 |
<?php |
| 55 |
endforeach; |
| 56 |
?> |
| 57 |
<br /> |
| 58 |
<div> |
| 59 |
<a class="ll_rss_preview_button" target="feedwindow" href="<?php echo $link_rss; ?>"><span>More News from this Feed</span></a> <a class="ll_rss_preview_button" target="sitewindow" href="<?php echo $link_url; ?>"><span>See Full Web Site</span></a> |
| 60 |
</div> |
| 61 |
<br /> |
| 62 |
<br /> |
| 63 |
<?php } ?> |
| 64 |
</div> |
| 65 |
</body> |
| 66 |
</html> |
| 67 |
|
| 68 |
<?php |
| 69 |
exit; |
| 70 |
} |
| 71 |
} |
| 72 |
|