=' ) ) { 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 '