' . sprintf(__('RSS Error: %s', 'better-twitter-widget'), $rss->get_error_message()) . '
'; } return; } $args = wp_parse_args($args, $this->defaults_args()); 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; // Set the cache duration $rss->enable_cache($enable_cache); $rss->set_cache_duration($cache_duration); $rss->init(); if (!$rss->get_item_quantity()) { print '
';
// retweet icon
print '
';
// like icon
print '
';
// view on twitter icon
print '
';
print ''; // close action bar
// close li
print $html_close;
}
}
print '' . $args['html_parent'] . '>';
}
/**
* Widget Update method
* @param array $new_instance
* @param array $old_instance
* @return array
*/
function update($new_instance, $old_instance) {
return $new_instance;
}
/**
* Load the instance defaults.
*
* @param array $instance
* @return array
*/
function defaults($instance) {
/* Fix any old instances to use new naming convention. */
if (isset($instance['url'])) {
$instance['rss-url'] = $instance['url'];
$instance['title_url'] = $instance['titleurl'];
$instance['show_icon'] = $instance['showicon'];
$instance['show_summary'] = $instance['showsummary'];
$instance['show_author'] = $instance['showauthor'];
$instance['show_date'] = $instance['showdate'];
$instance['show_time'] = $instance['showtime'];
$instance['link_target'] = $instance['linktarget'];
$instance['title_legnth'] = (isset($instance['title_length']) ? $instance['title_length'] : $this->options->title_length);
}
/* This is the new naming convention for the form fields */
$new_defaults = array(
'rss_url' => '',
'title' => '',
'title_url' => '',
'no_link_title' => false,
'show_icon' => false,
'link_icon' => 'rss_url',
'show_summary' => $this->options->show_summary,
'show_author' => $this->options->show_author,
'show_date' => $this->options->show_date,
'show_time' => $this->options->show_time,
'link_target' => $this->options->link_target,
'nofollow' => $this->options->nofollow,
'enable_cache' => $this->options->enable_cache,
'cache_duration' => $this->options->cache_duration,
'is_home' => $this->options->is_home_default,
'is_front' => $this->options->is_front_default,
'is_archive' => $this->options->is_archive_default,
'is_search' => $this->options->is_search_default,
'is_category' => $this->options->is_category_default,
'is_tag' => $this->options->is_tag_default,
'is_single' => $this->options->is_single_default,
'is_date' => $this->options->is_date_default,
'title_length' => $this->options->title_length,
'excerpt' => $this->options->excerpt,
'items' => $this->options->items
);
return wp_parse_args($instance, $new_defaults);
}
/**
* Widget form.
*
* @param array $instance
*/
function form($instance) {
if (count($instance) < 1) {
$instance = $this->defaults($instance);
}
include( $this->pluginPath . '/includes/widget-form.php');
}
/**
* Method for the [better-rss] short code.
*
* @param array $atts
* @return string
*/
function shortcode_handler($atts) {
global $post;
$atts = (object) wp_parse_args($atts, $this->defaults_args());
if (!$atts->feed) {
return false;
}
if ($atts->use_title) {
$add_url[] = str_replace(' ', '+', $post->post_title);
}
if ($atts->use_tags) {
foreach (get_the_tags() as $tag) {
$add_url[] = str_replace(' ', '+', $tag->name);
}
}
if (isset($add_url) and is_array($add_url)) {
$atts->feed = $atts->feed . implode('+', $add_url);
}
ob_start();
$this->rss_output($atts->feed, $atts);
$output.= ob_get_contents();
ob_end_clean();
return $output;
}
function defaults_args() {
return array(
// Query Attributes
'feed' => NULL,
'use_title' => false,
'use_tags' => false,
'use_category' => false,
'items' => 10,
'hide_title' => false,
'hide_link' => false,
'show_author' => $this->options->show_author,
'show_date' => $this->options->show_author,
'show_time' => $this->options->show_time,
'show_summary' => $this->options->show_summary,
'link_target' => $this->options->link_target,
'nofollow' => $this->options->nofollow,
'cache_duration' => $this->options->cache_duration,
'excerpt' => $this->options->excerpt,
'html_parent' => 'ul',
'html_item' => 'li'
);
}
/**
* Get an object with all of the post types.
*
* @return object
*/
function get_post_types($args = array()) {
if (function_exists('get_post_types')) {
$post_types = get_post_types(array('public' => true));
unset($post_types['attachment']);
} else {
$post_types = array('post', 'page');
}
$defaults = array(
'output' => 'object',
'name' => 'post_type',
'id' => 'post_type'
);
$args = (object) wp_parse_args($args, $defaults);
switch ($args->output) {
case 'dropdown':
$results = '';
break;
default:
$results = (object) $post_types;
}
return $results;
}
/**
* Display the list of contributors.
* @return boolean
*/
function contributor_list() {
if (function_exists('simplexml_load_file')) {
$this->showFields = array('NAME', 'LOCATION', 'COUNTRY');
print '