508 lines
21 KiB
PHP
508 lines
21 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
if ( defined( 'WPRSS_VERSION' ) && version_compare( WPRSS_VERSION, '4.5.2', '>=' ) ) {
|
||
|
|
add_filter( 'wprss_template_extra_options', 'wprss_et_display_options', 10, 3 );
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Loads the excerpt and thumbnail meta data.
|
||
|
|
*
|
||
|
|
* This is run when the core is loading the settings and meta data in the display
|
||
|
|
* function, prior to outputting the feed items.
|
||
|
|
* The options generated by this function will be passed back later when displaying
|
||
|
|
* the excerpts and the thumbnails when using the display template hooks.
|
||
|
|
*
|
||
|
|
* @since 1.8
|
||
|
|
* @param array $options The options array to be filtered
|
||
|
|
* @param array $args The shortcode arguments being passed
|
||
|
|
* @return array The filtered options.
|
||
|
|
*/
|
||
|
|
function wprss_et_display_options( $options, $args ) {
|
||
|
|
// Load the args - contain shortcode args
|
||
|
|
extract( $args );
|
||
|
|
|
||
|
|
// Load the settings
|
||
|
|
$excerpts_settings = get_option( 'wprss_settings_excerpts' );
|
||
|
|
$thumbnails_settings = get_option( 'wprss_settings_thumbnails' );
|
||
|
|
|
||
|
|
// Check if thumbnails enabled
|
||
|
|
$thumbnails_enabled = ( isset( $thumbnails ) )? $thumbnails : $thumbnails_settings['thumbnails_enable'];
|
||
|
|
$thumbnails_enabled = strcasecmp( $thumbnails_enabled, 'true' ) == 0
|
||
|
|
|| strcasecmp( $thumbnails_enabled, '1' ) == 0
|
||
|
|
|| strcasecmp( $thumbnails_enabled, 'on' ) == 0
|
||
|
|
|| strcasecmp( $thumbnails_enabled, 'yes' ) == 0;
|
||
|
|
|
||
|
|
// Check if using the default thumnail
|
||
|
|
$use_def_thumbnail_str = ( isset( $thumbnails_settings['use_def_thumbnail'] ) )? $thumbnails_settings['use_def_thumbnail'] : 'true';
|
||
|
|
$use_def_thumbnail = ( strtolower( $use_def_thumbnail_str ) == 'false' )? false : true;
|
||
|
|
// Check if the thumbnail is to be linked
|
||
|
|
$link_thumbnail = ( isset( $thumbnails_settings['link_thumbnail'] ) )? $thumbnails_settings['link_thumbnail'] : 'false';
|
||
|
|
// Get the default thumbnail
|
||
|
|
$def_thumbnail = $thumbnails_settings['default_thumbnail'];
|
||
|
|
// Get thumnail dimension settings
|
||
|
|
$thumb_width = isset( $args['thumb_width'] ) && !empty( $args['thumb_width'] )
|
||
|
|
? $args['thumb_width']
|
||
|
|
: $thumbnails_settings['thumbnail_width'];
|
||
|
|
$thumb_height = isset( $args['thumb_height'] ) && !empty( $args['thumb_height'] )
|
||
|
|
? $args['thumb_height']
|
||
|
|
: $thumbnails_settings['thumbnail_height'];
|
||
|
|
|
||
|
|
$thumb_opts = compact(
|
||
|
|
'thumbnails_enabled',
|
||
|
|
'use_def_thumbnail',
|
||
|
|
'link_thumbnail',
|
||
|
|
'def_thumbnail',
|
||
|
|
'thumb_width',
|
||
|
|
'thumb_height'
|
||
|
|
);
|
||
|
|
|
||
|
|
// Check if excerpts enabled
|
||
|
|
$excerpts_enabled = ( isset( $excerpts ) )? $excerpts : $excerpts_settings['excerpts_enable'];
|
||
|
|
$excerpts_enabled = strcasecmp( $excerpts_enabled, 'true' ) == 0
|
||
|
|
|| strcasecmp( $excerpts_enabled, '1' ) == 0
|
||
|
|
|| strcasecmp( $excerpts_enabled, 'on' ) == 0
|
||
|
|
|| strcasecmp( $excerpts_enabled, 'yes' ) == 0;
|
||
|
|
|
||
|
|
// Get the excerpt word limit
|
||
|
|
$word_limit = $excerpts_settings['excerpts_word_limit'];
|
||
|
|
// Get the excerpt ending
|
||
|
|
$excerpts_ending = $excerpts_settings['excerpts_ending'];
|
||
|
|
// Get the more link enabled option and the read more text
|
||
|
|
$excerpts_more_link_enabled = $excerpts_settings['morelink_enable'];
|
||
|
|
$excerpts_read_more = trim( $excerpts_settings['excerpts_read_more'] );
|
||
|
|
|
||
|
|
$excerpt_opts = compact(
|
||
|
|
'excerpts_enabled',
|
||
|
|
'word_limit',
|
||
|
|
'excerpts_ending',
|
||
|
|
'excerpts_more_link_enabled',
|
||
|
|
'excerpts_read_more'
|
||
|
|
);
|
||
|
|
|
||
|
|
return array_merge( $thumb_opts, $excerpt_opts );
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
if ( defined( 'WPRSS_VERSION' ) && version_compare( WPRSS_VERSION, '4.5.2', '>=' ) ) {
|
||
|
|
add_filter( 'wprss_template_extra_meta', 'wprss_et_display_meta', 10, 3 );
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Prepares the meta fields for the next item to be displayed.
|
||
|
|
*
|
||
|
|
* @since 1.8
|
||
|
|
* @param array $meta The data, currently consisting of the E&T general settings.
|
||
|
|
* @param array $args The arguments passed from the shortcode.
|
||
|
|
* @param int $item_id The ID of the feed item.
|
||
|
|
* @return array The filtered meta data.
|
||
|
|
*/
|
||
|
|
function wprss_et_display_meta( $meta, $args, $item_id ) {
|
||
|
|
// Get the feed source ID
|
||
|
|
$feed_source_id = get_post_meta( $item_id, 'wprss_feed_id', TRUE );
|
||
|
|
|
||
|
|
//== PREPARE THE THUMBNAIL ==
|
||
|
|
|
||
|
|
// Get the thumbnail and set to NULL if not found
|
||
|
|
$thumbnail_img = get_post_meta( get_the_ID(), 'wprss_item_thumbnail', true );
|
||
|
|
if ( empty( $thumbnail_img ) || $thumbnail_img == '' ) {
|
||
|
|
$thumbnail_img = NULL;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Assing the fallback as needed
|
||
|
|
$fallback_img = NULL;
|
||
|
|
// If the item has no thumbnail, and allowed to use the feed source fallback
|
||
|
|
if ( $thumbnail_img == NULL && $meta['use_def_thumbnail'] == true ) {
|
||
|
|
// Get feed source fallback
|
||
|
|
$fallback = get_post_thumbnail_id( $feed_source_id );
|
||
|
|
// If set ...
|
||
|
|
if ( $fallback !== '' ) {
|
||
|
|
// Get the URL
|
||
|
|
$fallback_img_info = wp_get_attachment_image_src( $fallback );
|
||
|
|
$fallback_img = $fallback_img_info[0];
|
||
|
|
// Use the fallback as the thumbnail
|
||
|
|
$thumbnail_img = $fallback_img;
|
||
|
|
} else {
|
||
|
|
// Otherwise, use the global default
|
||
|
|
$thumbnail_img = $meta['def_thumbnail'];
|
||
|
|
}
|
||
|
|
// If all else fails (should not), use the default image bundled with the add-on
|
||
|
|
if ( empty( $thumbnail_img ) ) {
|
||
|
|
$thumbnail_img = WPRSS_ET_IMG . 'default-thumbnail.png';
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// Check if using a default or fallback thumbnail
|
||
|
|
$using_default_or_fallback = (
|
||
|
|
empty( $thumbnail_img ) ||
|
||
|
|
$thumbnail_img === $meta['def_thumbnail'] ||
|
||
|
|
$thumbnail_img === WPRSS_ET_IMG . 'default-thumbnail.png' ||
|
||
|
|
$thumbnail_img === $fallback_img
|
||
|
|
);
|
||
|
|
// Check if the default image is allowed to be shown
|
||
|
|
$show_default_img = ( $using_default_or_fallback === TRUE && $meta['use_def_thumbnail'] === FALSE );
|
||
|
|
|
||
|
|
// Prepare the thumbnail using WPThumb
|
||
|
|
$thumbnail = NULL;
|
||
|
|
if ( $meta['thumbnails_enabled'] === true ) {
|
||
|
|
$query_str = wprss_get_query_string( $thumbnail_img );
|
||
|
|
$wpthumb_args = array(
|
||
|
|
'width' => $meta['thumb_width'],
|
||
|
|
'height' => $meta['thumb_height'],
|
||
|
|
'crop' => '1',
|
||
|
|
'background_fill' => 'solid',
|
||
|
|
);
|
||
|
|
$thumbnail = wpthumb( $thumbnail_img, $wpthumb_args ) . $query_str;
|
||
|
|
}
|
||
|
|
// Add the prepared thumbnail and the "use default" indicator to the meta array
|
||
|
|
$meta['show_default_img'] = $show_default_img;
|
||
|
|
$meta['thumbnail'] = $thumbnail;
|
||
|
|
|
||
|
|
//== PREPARE THE EXCERPT ==
|
||
|
|
|
||
|
|
$allowed_tags = apply_filters(
|
||
|
|
'wprss_et_allowed_tags_in_excerpts',
|
||
|
|
array( 'a','span', 'em', 'i', 'b', 'strong', 'u' )
|
||
|
|
);
|
||
|
|
// Trim the content using the settings word limit and ending
|
||
|
|
remove_filter( 'the_content', 'wprss_render_feed_item_view' );
|
||
|
|
$trimmed_content = trim(
|
||
|
|
wprss_et_trim_words(
|
||
|
|
get_the_content( $item_id ),
|
||
|
|
$meta['word_limit'],
|
||
|
|
$allowed_tags
|
||
|
|
)
|
||
|
|
);
|
||
|
|
add_filter( 'the_content', 'wprss_render_feed_item_view' );
|
||
|
|
|
||
|
|
// Check if the content contains 'Read more' texts at the end of the excerpt
|
||
|
|
// Known endings:
|
||
|
|
// ' … Read more →'
|
||
|
|
$endings = wprss_et_get_endings();
|
||
|
|
foreach ( $endings as $ending ) {
|
||
|
|
// content and ending lengths
|
||
|
|
$contentLen = strlen( $trimmed_content );
|
||
|
|
$endingLen = strlen( $ending );
|
||
|
|
// If the found string is at this index, it is and ending
|
||
|
|
$matchIndex = $contentLen - $endingLen;
|
||
|
|
// the actual ending index found
|
||
|
|
$endingIndex = strripos( $trimmed_content, $ending );
|
||
|
|
// If the found index is at the match index, then it is at the end, and has to be trimmed out
|
||
|
|
if ( $endingIndex === $matchIndex ) {
|
||
|
|
// Trim the content to exclude the ending
|
||
|
|
$trimmed_content = substr( $trimmed_content, 0, $matchIndex );
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// Add the trimmed content (the excerpt) to the meta array
|
||
|
|
$meta['trimmed_content'] = $trimmed_content;
|
||
|
|
|
||
|
|
// Return the meta array
|
||
|
|
return $meta;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
if ( defined( 'WPRSS_VERSION' ) && version_compare( WPRSS_VERSION, '4.5.2', '>=' ) ) {
|
||
|
|
add_action( 'wprss_after_feed_item_title', 'wprss_et_display_excerpt_and_thumbnail', 10, 3 );
|
||
|
|
}
|
||
|
|
function wprss_et_display_excerpt_and_thumbnail( $meta, $display_settings, $item_id ) {
|
||
|
|
// Get the item permalink
|
||
|
|
$permalink = get_post_meta( $item_id, 'wprss_item_permalink', TRUE );
|
||
|
|
// Extract the meta fields and options
|
||
|
|
extract($meta);
|
||
|
|
extract($display_settings);
|
||
|
|
|
||
|
|
echo '<div class="thumbnail-excerpt wprss-feed-thumbnail">';
|
||
|
|
// Thumbnails enabled
|
||
|
|
if ( ($thumbnails_enabled === true) && $thumbnail !== NULL && ($show_default_img === false) && (function_exists( 'wpthumb' )) ) {
|
||
|
|
// Print the section <div>
|
||
|
|
// Prepare the <img> tag
|
||
|
|
$img_output = "<img src='{$thumbnail}' width='{$thumb_width}' height='{$thumb_height}' />";
|
||
|
|
// If linking is enabled, wrap the img around an <a> tag
|
||
|
|
if ( $link_thumbnail === 'true' ) {
|
||
|
|
$img_output = "<a {$open} {$follow} href='$permalink'>{$img_output}</a>";
|
||
|
|
}
|
||
|
|
// Print the image
|
||
|
|
echo $img_output;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Excerpts enabled
|
||
|
|
if ( $excerpts_enabled === true ) {
|
||
|
|
echo '<div class="thumbnail-excerpt wprss-feed-excerpt">';
|
||
|
|
echo trim( $trimmed_content ) . ' ' . $excerpts_ending . ' ';
|
||
|
|
if ( $excerpts_more_link_enabled == 1 ) {
|
||
|
|
echo "<a {$open} {$follow} href='$permalink'>{$excerpts_read_more}</a>";
|
||
|
|
}
|
||
|
|
echo '</div>';
|
||
|
|
}
|
||
|
|
echo '</div>';
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
if ( defined( 'WPRSS_VERSION' ) && version_compare( WPRSS_VERSION, '4.5.2', '<' ) ) {
|
||
|
|
add_action( 'wprss_display_template', 'wprss_et_display_template', '', 9 );
|
||
|
|
}
|
||
|
|
/**
|
||
|
|
* Default template for feed items display
|
||
|
|
*
|
||
|
|
* @since 1.0
|
||
|
|
*/
|
||
|
|
function wprss_et_display_template( $display_settings, $args, $feed_items ) {
|
||
|
|
global $wp_query;
|
||
|
|
global $paged;
|
||
|
|
$old_wp_query = $wp_query;
|
||
|
|
$wp_query = $feed_items;
|
||
|
|
|
||
|
|
$general_settings = get_option( 'wprss_settings_general' );
|
||
|
|
$excerpts_settings = get_option( 'wprss_settings_excerpts' );
|
||
|
|
$thumbnails_settings = get_option( 'wprss_settings_thumbnails' );
|
||
|
|
|
||
|
|
$source_link = isset( $general_settings['source_link'] )? $general_settings['source_link'] : 0;
|
||
|
|
// Declare each item in $args as its own variable
|
||
|
|
extract( $args, EXTR_SKIP );
|
||
|
|
|
||
|
|
$thumbnails_enabled = ( isset( $thumbnails ) )? $thumbnails : $thumbnails_settings['thumbnails_enable'];
|
||
|
|
$thumbnails_enabled = strcasecmp( $thumbnails_enabled, 'true' ) == 0
|
||
|
|
|| strcasecmp( $thumbnails_enabled, '1' ) == 0
|
||
|
|
|| strcasecmp( $thumbnails_enabled, 'on' ) == 0
|
||
|
|
|| strcasecmp( $thumbnails_enabled, 'yes' ) == 0;
|
||
|
|
|
||
|
|
|
||
|
|
$excerpts_enabled = ( isset( $excerpts ) )? $excerpts : $excerpts_settings['excerpts_enable'];
|
||
|
|
$excerpts_enabled = strcasecmp( $excerpts_enabled, 'true' ) == 0
|
||
|
|
|| strcasecmp( $excerpts_enabled, '1' ) == 0
|
||
|
|
|| strcasecmp( $excerpts_enabled, 'on' ) == 0
|
||
|
|
|| strcasecmp( $excerpts_enabled, 'yes' ) == 0;
|
||
|
|
|
||
|
|
$use_def_thumbnail_str = ( isset( $thumbnails_settings['use_def_thumbnail'] ) )? $thumbnails_settings['use_def_thumbnail'] : 'true';
|
||
|
|
$use_def_thumbnail = ( strtolower( $use_def_thumbnail_str ) == 'false' )? false : true;
|
||
|
|
|
||
|
|
$link_thumbnail = ( isset( $thumbnails_settings['link_thumbnail'] ) )? $thumbnails_settings['link_thumbnail'] : 'false';
|
||
|
|
|
||
|
|
$final_output = '';
|
||
|
|
|
||
|
|
if( $feed_items->have_posts() ) {
|
||
|
|
|
||
|
|
$final_output .= "$links_before";
|
||
|
|
|
||
|
|
while ( $feed_items->have_posts() ) {
|
||
|
|
$output = '';
|
||
|
|
$feed_items->the_post();
|
||
|
|
$permalink = get_post_meta( get_the_ID(), 'wprss_item_permalink', true );
|
||
|
|
$content = get_the_content();
|
||
|
|
$feed_source_id = get_post_meta( get_the_ID(), 'wprss_feed_id', true );
|
||
|
|
$source_name = get_the_title( $feed_source_id );
|
||
|
|
$source_url = get_post_meta( $feed_source_id, 'wprss_url', true );
|
||
|
|
|
||
|
|
do_action( 'wprss_get_post_data' );
|
||
|
|
$thumbnail_img = get_post_meta( get_the_ID(), 'wprss_item_thumbnail', true );
|
||
|
|
if ( empty( $thumbnail_img ) || $thumbnail_img == '' ) {
|
||
|
|
$thumbnail_img = NULL;
|
||
|
|
}
|
||
|
|
// Thumbnail Image URL is correct at this point
|
||
|
|
|
||
|
|
$allowed_tags = apply_filters(
|
||
|
|
'wprss_et_allowed_tags_in_excerpts',
|
||
|
|
array( 'a','span', 'em', 'i', 'b', 'strong', 'u' )
|
||
|
|
);
|
||
|
|
// Trim the content using the settings word limit and ending
|
||
|
|
$trimmed_content = trim(
|
||
|
|
wprss_et_trim_words(
|
||
|
|
$content,
|
||
|
|
$excerpts_settings['excerpts_word_limit'],
|
||
|
|
$allowed_tags
|
||
|
|
)
|
||
|
|
);
|
||
|
|
|
||
|
|
// Check if the content contains 'Read more' texts at the end of the excerpt
|
||
|
|
// Known endings:
|
||
|
|
// ' … Read more →'
|
||
|
|
$endings = array(
|
||
|
|
' ',
|
||
|
|
'...',
|
||
|
|
'…',
|
||
|
|
'→',
|
||
|
|
'[...]',
|
||
|
|
'[…]',
|
||
|
|
' ',
|
||
|
|
'read more',
|
||
|
|
'Continue reading',
|
||
|
|
);
|
||
|
|
|
||
|
|
foreach ( $endings as $ending ) {
|
||
|
|
// content and ending lengths
|
||
|
|
$contentLen = strlen( $trimmed_content );
|
||
|
|
$endingLen = strlen( $ending );
|
||
|
|
// If the found string is at this index, it is and ending
|
||
|
|
$matchIndex = $contentLen - $endingLen;
|
||
|
|
// the actual ending index found
|
||
|
|
$endingIndex = strripos( $trimmed_content, $ending );
|
||
|
|
// If the found index is at the match index, then it is at the end, and has to be trimmed out
|
||
|
|
if ( $endingIndex === $matchIndex ) {
|
||
|
|
// Trim the content to exclude the ending
|
||
|
|
$trimmed_content = substr( $trimmed_content, 0, $matchIndex );
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
$fallback_img = NULL;
|
||
|
|
if ( $thumbnail_img == NULL && $use_def_thumbnail == true ) {
|
||
|
|
// Get feed source fallback
|
||
|
|
$fallback = get_post_thumbnail_id( $feed_source_id );
|
||
|
|
if ( $fallback !== '' ) {
|
||
|
|
$fallback_img_info = wp_get_attachment_image_src( $fallback );
|
||
|
|
$fallback_img = $fallback_img_info[0];
|
||
|
|
$thumbnail_img = $fallback_img;
|
||
|
|
} else {
|
||
|
|
$thumbnail_img = $thumbnails_settings['default_thumbnail'];
|
||
|
|
}
|
||
|
|
// Use the placeholder thumbnail that comes with the plugin
|
||
|
|
if ( empty( $thumbnail_img ) ) {
|
||
|
|
$thumbnail_img = WPRSS_ET_IMG . 'default-thumbnail.png';
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
if ( $thumbnails_enabled === true ) {
|
||
|
|
$query_str = wprss_get_query_string( $thumbnail_img );
|
||
|
|
$wpthumb_args = array(
|
||
|
|
'width' => $thumbnails_settings['thumbnail_width'],
|
||
|
|
'height' => $thumbnails_settings['thumbnail_height'],
|
||
|
|
'crop' => '1',
|
||
|
|
'background_fill' => 'solid',
|
||
|
|
);
|
||
|
|
$thumbnail = wpthumb( $thumbnail_img, $wpthumb_args ) . $query_str;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
if ( $general_settings['title_link'] == 1 ) {
|
||
|
|
$output .= "$link_before" . '<a ' . $display_settings['open'] . ' ' . $display_settings['follow'] . ' href="'. $permalink . '">'. get_the_title(). '</a>';
|
||
|
|
}
|
||
|
|
else {
|
||
|
|
$output .= "$link_before" . get_the_title();
|
||
|
|
}
|
||
|
|
|
||
|
|
// Check if using a default or fallback thumbnail
|
||
|
|
$using_default_or_fallback = (
|
||
|
|
empty( $thumbnail_img ) ||
|
||
|
|
$thumbnail_img === $thumbnails_settings['default_thumbnail'] ||
|
||
|
|
$thumbnail_img === WPRSS_ET_IMG . 'default-thumbnail.png' ||
|
||
|
|
$thumbnail_img === $fallback_img
|
||
|
|
);
|
||
|
|
|
||
|
|
$show_default_img = ( $using_default_or_fallback === TRUE && $use_def_thumbnail === FALSE );
|
||
|
|
|
||
|
|
$output .= '<div class="thumbnail-excerpt wprss-feed-thumbnail">';
|
||
|
|
// Thumbnails enabled
|
||
|
|
if ( ( $thumbnails_enabled === true ) && ( $show_default_img === false ) && ( function_exists( 'wpthumb' ) ) ) {
|
||
|
|
$img_output = '<img src="' . $thumbnail . '" height="'. $thumbnails_settings['thumbnail_height'] .'" width="'. $thumbnails_settings['thumbnail_width'] .'" />';
|
||
|
|
if ( $link_thumbnail === 'true' )
|
||
|
|
$img_output = "<a {$display_settings['open']} {$display_settings['follow']} href='$permalink'>{$img_output}</a>";
|
||
|
|
$output .= $img_output;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Excerpts enabled
|
||
|
|
if ( $excerpts_enabled === true ) {
|
||
|
|
$output .= '<div class="thumbnail-excerpt wprss-feed-excerpt">';
|
||
|
|
$output .= $trimmed_content . $excerpts_settings['excerpts_ending'];
|
||
|
|
if ( $excerpts_settings['morelink_enable'] == 1 ) {
|
||
|
|
$output .= " <a " . $display_settings['open'] . ' ' . $display_settings['follow'] . " href='$permalink'>" . $excerpts_settings['excerpts_read_more']. "</a>";
|
||
|
|
}
|
||
|
|
$output .= '</div>';
|
||
|
|
}
|
||
|
|
$output .= '</div>';
|
||
|
|
|
||
|
|
|
||
|
|
// convert from Unix timestamp
|
||
|
|
$timestamp = intval( get_post_meta( get_the_ID(), 'wprss_item_date', true ) );
|
||
|
|
$date = wprss_date_i18n( $timestamp, $general_settings['date_format'] );
|
||
|
|
// Prepare the date
|
||
|
|
// Get the preceding text
|
||
|
|
$text_preceding_date = $general_settings['text_preceding_date'];
|
||
|
|
// If not empty add append a space
|
||
|
|
$text_preceding_date .= ( empty($text_preceding_date) )? '' : ' ';
|
||
|
|
// The date, or the time ago date if enabled
|
||
|
|
$date_string = $text_preceding_date;
|
||
|
|
if ( isset($general_settings['time_ago_format_enable']) && $general_settings['time_ago_format_enable'] == 1 ) {
|
||
|
|
$date_string .= human_time_diff( $timestamp, time() ) . ' ago';
|
||
|
|
} else {
|
||
|
|
$date_string .= $date;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Source enabled, Date enabled
|
||
|
|
if ( ( $general_settings['source_enable'] == 1 ) && ( $general_settings['date_enable'] == 1 ) ) {
|
||
|
|
$output .= '<div class="source-date"><span class="feed-source">' .
|
||
|
|
( !empty( $general_settings['text_preceding_source'] ) ? $general_settings['text_preceding_source'] . ' ' : '' );
|
||
|
|
|
||
|
|
if ( $source_link == 1 ) {
|
||
|
|
$output .= '<a href="' . $source_url . '">' . $source_name . "</a>";
|
||
|
|
}
|
||
|
|
else $output .= $source_name;
|
||
|
|
|
||
|
|
//$output .= ' | ' . ( !empty( $general_settings['text_preceding_date'] ) ? $general_settings['text_preceding_date'] . ' ' : '' ) . $date .
|
||
|
|
//'</span></div>';
|
||
|
|
$output .= " | $date_string";
|
||
|
|
$output .= '</span></div>';
|
||
|
|
}
|
||
|
|
|
||
|
|
// Source enabled, Date disabled
|
||
|
|
else if ( ( $general_settings['source_enable'] == 1 ) && ( $general_settings['date_enable'] == 0 ) ) {
|
||
|
|
$output .= '<div class="source-date"><span class="feed-source">' .
|
||
|
|
( !empty( $general_settings['text_preceding_source'] ) ? $general_settings['text_preceding_source'] . ' ' : '' );
|
||
|
|
|
||
|
|
if ( $source_link == 1 ) {
|
||
|
|
$output .= '<a href="' . $source_url . '">' . $source_name . "</a>";
|
||
|
|
}
|
||
|
|
else $output .= $source_name;
|
||
|
|
|
||
|
|
$output .= '</span></div>';
|
||
|
|
}
|
||
|
|
|
||
|
|
// Source disabled, Date enabled
|
||
|
|
else if ( ( $general_settings['source_enable'] == 0 ) && ( $general_settings['date_enable'] == 1 ) ) {
|
||
|
|
$output .= '<div class="source-date"><span class="feed-source">';
|
||
|
|
$output .= $date_string;
|
||
|
|
$output .= '</span></div>';
|
||
|
|
//( !empty( $general_settings['text_preceding_date'] ) ? $general_settings['text_preceding_date'] . ' ' : '' ) . $date .
|
||
|
|
//'</span></div>';
|
||
|
|
}
|
||
|
|
|
||
|
|
$output = apply_filters( 'wprss_single_feed_output', $output , $permalink );
|
||
|
|
$output .= "$link_after";
|
||
|
|
|
||
|
|
$final_output .= $output;
|
||
|
|
}
|
||
|
|
$final_output .= "$links_after";
|
||
|
|
|
||
|
|
$final_output = apply_filters( 'wprss_pagination', $final_output );
|
||
|
|
|
||
|
|
$final_output = apply_filters( 'feed_output', $final_output );
|
||
|
|
|
||
|
|
echo $final_output;
|
||
|
|
|
||
|
|
|
||
|
|
} else {
|
||
|
|
$output = apply_filters( 'no_feed_items_found', __( 'No feed items found.', 'wprss' ) );
|
||
|
|
echo $output;
|
||
|
|
}
|
||
|
|
|
||
|
|
$wp_query = $old_wp_query;
|
||
|
|
wp_reset_postdata();
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Returns all possible known excerpt endings.
|
||
|
|
*
|
||
|
|
* @since 1.8
|
||
|
|
* @return array Known excerpt endings
|
||
|
|
*/
|
||
|
|
function wprss_et_get_endings() {
|
||
|
|
return array(
|
||
|
|
' ',
|
||
|
|
'...',
|
||
|
|
'…',
|
||
|
|
'→',
|
||
|
|
'[...]',
|
||
|
|
'[…]',
|
||
|
|
' ',
|
||
|
|
'read more',
|
||
|
|
'Continue reading',
|
||
|
|
);
|
||
|
|
}
|