'',
'link' => $slicejack_url,
'url' => $slicejack_url . '?feed=rss2',
'title' => __( 'SliceJack Blog', 'briar' ),
'items' => 5,
'show_summary' => 1,
'show_author' => 0,
'show_date' => 1,
);
define( 'DOING_AJAX', true );
wp_dashboard_cached_rss_widget( 'dashboard_slicejack', 'sj_dashboard_widget_output', $feed );
}
/**
* Display the SliceJack news feed.
*
* @since 1.0
*
* @param string $widget_id Widget ID.
* @param array $feed Array of informations about RSS feed.
*/
function sj_dashboard_widget_output( $widget_id, $feed ) {
global $slicejack_url; ?>
' . sprintf( esc_html__( 'RSS Error: %s', 'briar' ), esc_html( $rss->get_error_message() ) ) . '';
}
return;
}
$default_args = array( 'show_author' => 0, 'show_date' => 0, 'show_summary' => 0, 'items' => 0 );
$args = wp_parse_args( $args, $default_args );
$items = (int) $args['items'];
if ( $items < 1 || 20 < $items ) {
$items = 10;
}
$show_summary = (int) $args['show_summary'];
$show_author = (int) $args['show_author'];
$show_date = (int) $args['show_date'];
if ( ! $rss->get_item_quantity() ) {
echo '- ' . esc_html__( 'An error has occurred, which probably means the feed is down. Try again later.', 'briar' ) . '
';
$rss->__destruct();
unset( $rss );
return;
}
echo '';
foreach ( $rss->get_items( 0, $items ) as $item ) {
$link = $item->get_link();
while ( stristr( $link, 'http' ) !== $link ) {
$link = substr( $link, 1 );
}
$link = strip_tags( $link );
$title = trim( strip_tags( $item->get_title() ) );
if ( empty( $title ) ) {
$title = __( 'Untitled', 'briar' );
}
$desc = html_entity_decode( $item->get_description(), ENT_QUOTES, get_option( 'blog_charset' ) );
$desc = esc_attr( wp_trim_words( $desc, 55, ' […]' ) );
$summary = '';
if ( $show_summary ) {
$summary = $desc;
// Change existing [...] to […].
if ( '[...]' === substr( $summary, -5 ) ) {
$summary = substr( $summary, 0, -5 ) . '[…]';
}
$summary = '';
}
$date = '';
if ( $show_date ) {
$date = $item->get_date( 'U' );
if ( $date ) {
$date = ' ';
}
}
$author = '';
if ( $show_author ) {
$author = $item->get_author();
if ( is_object( $author ) ) {
$author = $author->get_name();
$author = ' ' . esc_html( strip_tags( $author ) ) . '';
}
}
$read_more = '';
if ( '' !== $link ) {
$read_more = '' . __( 'Read more', 'briar' ) . '';
}
if ( '' === $link ) {
echo '- ' . esc_html( $title ) . wp_kses( $date, array( 'span' => array( 'class' => true ) ) ) . wp_kses( $summary, array( 'div' => array( 'class' => true ) ) ) . wp_kses( $author, array( 'cite' ) ) . '
';
} elseif ( $show_summary ) {
echo '- ' . wp_kses( $date, array( 'span' => array( 'class' => true ) ) ) . wp_kses( $summary, array( 'div' => array( 'class' => true ) ) ) . wp_kses( $author, array( 'cite' ) ) . wp_kses( $read_more, array( 'a' => array( 'href' => array(), 'style' => array() ) ) ) . '
';
} else {
echo '- ' . wp_kses( $date, array( 'span' => array( 'class' => true ) ) ) . wp_kses( $author, array( 'cite' ) ) . wp_kses( $read_more, array( 'a' => array( 'href' => true, 'style' => true ) ) ) . '
';
}
}
echo '
';
$rss->__destruct();
unset( $rss );
}