All Good Things Must Come To An End

As you all know, I have been doing WordPress plugins and supporting it for the past 6 years. These 6 years of my life, I have been through my polytechnic education, my national service as well as my university education.

I just graduated from university in December 2009 and have been looking for full-time jobs. I am offered a full-time job and will be starting work on 1st February 2010.

I regret to say that I am NOT ABLE to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

However, I WILL still update my plugins whenever I can and you still can report bugs to me via email and I will try to fix it.

Author Topic: WordPress RSS widget php function  (Read 11973 times)

0 Members and 1 Guest are viewing this topic.

Offline Romik84

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
WordPress RSS widget php function
« on: 08 May 2008, 09:09 »
Hi folks,

I need help with RSS widget in wp. I think you know that widget and I would need to add it like php function on my blog. Basicly that widget is added on the sidebar but I want to add it on the footer and like php function instead. Well, the output item looks like this in source:

Code: [Select]
<ul><li><a class='rsswidget' href='http://feeds.feedburner.com/~r/Phonearea/~3/285950275/' title='Phone Arena makes a hands-on preview of LG KF700, a phone that highly resembles the Viewty, but features a numeric keypad and a thumb-wheel on the back. '>VIDEO: LG KF700 Preview</a><span class="rss-date">May 8, 2008</span> <cite>Phone Arena</cite></li></ul>
I found a function which maybe is used for that in widgets.php file in wp-includes called wp_widget_rss_output:

Code: [Select]
function wp_widget_rss_output( $rss, $args = array() ) {
if ( is_string( $rss ) ) {
require_once(ABSPATH . WPINC . '/rss.php');
if ( !$rss = fetch_rss($rss) )
return;
} elseif ( is_array($rss) && isset($rss['url']) ) {
require_once(ABSPATH . WPINC . '/rss.php');
$args = $rss;
if ( !$rss = fetch_rss($rss['url']) )
return;
} elseif ( !is_object($rss) ) {
return;
}

extract( $args, EXTR_SKIP );

$items = (int) $items;
if ( $items < 1 || 20 < $items )
$items = 10;
$show_summary  = (int) $show_summary;
$show_author   = (int) $show_author;
$show_date     = (int) $show_date;

if ( is_array( $rss->items ) && !empty( $rss->items ) ) {
$rss->items = array_slice($rss->items, 0, $items);
echo '<ul>';
foreach ($rss->items as $item ) {
while ( strstr($item['link'], 'http') != $item['link'] )
$item['link'] = substr($item['link'], 1);
$link = clean_url(strip_tags($item['link']));
$title = attribute_escape(strip_tags($item['title']));
if ( empty($title) )
$title = __('Untitled');
$desc = '';
if ( isset( $item['description'] ) && is_string( $item['description'] ) )
$desc = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($item['description'], ENT_QUOTES))));
elseif ( isset( $item['summary'] ) && is_string( $item['summary'] ) )
$desc = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($item['summary'], ENT_QUOTES))));

$summary = '';
if ( isset( $item['description'] ) && is_string( $item['description'] ) )
$summary = $item['description'];
elseif ( isset( $item['summary'] ) && is_string( $item['summary'] ) )
$summary = $item['summary'];

$desc = str_replace(array("\n", "\r"), ' ', attribute_escape(strip_tags(html_entity_decode($summary, ENT_QUOTES))));

if ( $show_summary ) {
$desc = '';
$summary = wp_specialchars( $summary );
$summary = "<div class='rssSummary'>$summary</div>";
} else {
$summary = '';
}

$date = '';
if ( $show_date ) {
if ( isset($item['pubdate']) )
$date = $item['pubdate'];
elseif ( isset($item['published']) )
$date = $item['published'];

if ( $date ) {
if ( $date_stamp = strtotime( $date ) )
$date = '<span class="rss-date">' . date_i18n( get_option( 'date_format' ), $date_stamp ) . '</span>';
else
$date = '';
}
}

$author = '';
if ( $show_author ) {
if ( isset($item['dc']['creator']) )
$author = ' <cite>' . wp_specialchars( strip_tags( $item['dc']['creator'] ) ) . '</cite>';
elseif ( isset($item['author_name']) )
$author = ' <cite>' . wp_specialchars( strip_tags( $item['author_name'] ) ) . '</cite>';
}

echo "<li><a class='rsswidget' href='$link' title='$desc'>$title</a>{$date}{$summary}{$author}</li>";
}
echo '</ul>';
} else {
echo '<ul><li>' . __( 'An error has occurred; the feed is probably down. Try again later.' ) . '</li></ul>';
}
}

well, I need to get the same output like when I added in admin menu:number of items, title, date and author. Will you help me like to get it from that function?

I have tried this


Code: [Select]
<?php require_once(ABSPATH WPINC '/rss.php'); wp_widget_rss_output('http://feeds.feedburner.com/Phonearea'5);
?>

but its not what Im looking for


Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Re: WordPress RSS widget php function
« Reply #1 on: 08 May 2008, 09:24 »
Code: [Select]
<?php require_once(ABSPATH WPINC '/rss.php'); wp_widget_rss_output('http://feeds.feedburner.com/Phonearea''items=5');
?>

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline Romik84

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Re: WordPress RSS widget php function
« Reply #2 on: 08 May 2008, 09:28 »
Code: [Select]
<?php require_once(ABSPATH WPINC '/rss.php'); wp_widget_rss_output('http://feeds.feedburner.com/Phonearea''items=5');
?>

yes I've tried this one also but I still get 10 items, and I need to show the date and author also.

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Re: WordPress RSS widget php function
« Reply #3 on: 09 May 2008, 04:40 »
Judging from the code, it should be
Code: [Select]
<?php require_once(ABSPATH WPINC '/rss.php'); wp_widget_rss_output('http://feeds.feedburner.com/Phonearea''items=5&show_author=1&show_date=1');
?>

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline Romik84

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Re: WordPress RSS widget php function
« Reply #4 on: 09 May 2008, 08:00 »
unfortunately still not working, it shows only 10 items without author and date

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Re: WordPress RSS widget php function
« Reply #5 on: 09 May 2008, 08:11 »
Why not include 'wp-config.php' instead of just rss.

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline Romik84

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Re: WordPress RSS widget php function
« Reply #6 on: 09 May 2008, 09:00 »
Im not sure what you mean Lester  ???

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Re: WordPress RSS widget php function
« Reply #7 on: 09 May 2008, 09:49 »
Code: [Select]
<?php require_once('wp-config.php'); wp_widget_rss_output('http://feeds.feedburner.com/Phonearea''items=5&show_author=1&show_date=1');
?>


if it still does not work, ask in WPorg forums as i never use RSS before lol

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline Romik84

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Re: WordPress RSS widget php function
« Reply #8 on: 09 May 2008, 10:41 »
its a pity, hm, the WP forum is like nothing. Nobody always answer me or try to help me, great support...lol  :-\..thats why I came here

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Re: WordPress RSS widget php function
« Reply #9 on: 10 May 2008, 04:24 »
OH it is an array!

Code: [Select]
<?php require_once(ABSPATH WPINC '/rss.php'); wp_widget_rss_output('http://feeds.feedburner.com/Phonearea', array('items' => 5'show_author' => 1'show_date' => 1));
?>

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

Offline Romik84

  • Jr. Member
  • **
  • Posts: 99
    • View Profile
Re: WordPress RSS widget php function
« Reply #10 on: 10 May 2008, 07:06 »
thanks Lester, this works. I sent u little donation so u can buy a beer from me...lol  :D ;)

Offline GaMerZ

  • lesterchan.net
  • Administrator
  • *****
  • Posts: 11,692
    • View Profile
  • WordPress Version: WordPress 3.0.x
  • Theme Name: lesterchan.net v3.4
Re: WordPress RSS widget php function
« Reply #11 on: 10 May 2008, 07:17 »
Thanks =D

++ lesterchan.net - Lester Chan's Website

I regret to say that I am not able to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.