wip
This commit is contained in:
+29
-10
@@ -31,27 +31,46 @@ function render_block_core_rss( $attributes ) {
|
||||
|
||||
$rss_items = $rss->get_items( 0, $attributes['itemsToShow'] );
|
||||
$list_items = '';
|
||||
|
||||
$open_in_new_tab = ! empty( $attributes['openInNewTab'] );
|
||||
$rel = ! empty( $attributes['rel'] ) ? trim( $attributes['rel'] ) : '';
|
||||
|
||||
$link_attributes = '';
|
||||
|
||||
if ( $open_in_new_tab ) {
|
||||
$link_attributes .= ' target="_blank"';
|
||||
}
|
||||
|
||||
if ( '' !== $rel ) {
|
||||
$link_attributes .= ' rel="' . esc_attr( $rel ) . '"';
|
||||
}
|
||||
|
||||
foreach ( $rss_items as $item ) {
|
||||
$title = esc_html( trim( strip_tags( $item->get_title() ) ) );
|
||||
$title = esc_html( trim( strip_tags( html_entity_decode( $item->get_title() ) ) ) );
|
||||
|
||||
if ( empty( $title ) ) {
|
||||
$title = __( '(no title)' );
|
||||
}
|
||||
$link = $item->get_link();
|
||||
$link = esc_url( $link );
|
||||
|
||||
if ( $link ) {
|
||||
$title = "<a href='{$link}'>{$title}</a>";
|
||||
$title = "<a href='{$link}'{$link_attributes}>{$title}</a>";
|
||||
}
|
||||
$title = "<div class='wp-block-rss__item-title'>{$title}</div>";
|
||||
|
||||
$date = '';
|
||||
if ( $attributes['displayDate'] ) {
|
||||
$date = $item->get_date( 'U' );
|
||||
$date_markup = '';
|
||||
if ( ! empty( $attributes['displayDate'] ) ) {
|
||||
$timestamp = $item->get_date( 'U' );
|
||||
|
||||
if ( $date ) {
|
||||
$date = sprintf(
|
||||
if ( $timestamp ) {
|
||||
$gmt_offset = get_option( 'gmt_offset' );
|
||||
$timestamp += (int) ( (float) $gmt_offset * HOUR_IN_SECONDS );
|
||||
|
||||
$date_markup = sprintf(
|
||||
'<time datetime="%1$s" class="wp-block-rss__item-publish-date">%2$s</time> ',
|
||||
esc_attr( date_i18n( 'c', $date ) ),
|
||||
esc_attr( date_i18n( get_option( 'date_format' ), $date ) )
|
||||
esc_attr( date_i18n( 'c', $timestamp ) ),
|
||||
esc_html( date_i18n( get_option( 'date_format' ), $timestamp ) )
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -85,7 +104,7 @@ function render_block_core_rss( $attributes ) {
|
||||
$excerpt = '<div class="wp-block-rss__item-excerpt">' . esc_html( $excerpt ) . '</div>';
|
||||
}
|
||||
|
||||
$list_items .= "<li class='wp-block-rss__item'>{$title}{$date}{$author}{$excerpt}</li>";
|
||||
$list_items .= "<li class='wp-block-rss__item'>{$title}{$date_markup}{$author}{$excerpt}</li>";
|
||||
}
|
||||
|
||||
$classnames = array();
|
||||
|
||||
Reference in New Issue
Block a user