• Resolved DJABHipHop

    (@pressthemes1)


    add post thumbnail to rss, & add user avatar comment to rss

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter DJABHipHop

    (@pressthemes1)

    I made the plugin back in 2017 to make the rss feed look nicer feel free to use parts of the code in ASE to make the rss feed look better.

    <?php
    /*
    Plugin Name: Pro Rss
    Plugin URI:
    Description: This plugin adds post thumb search Tag & Related Post to RSS Feed 1&2 .
    Version: 1.2
    Author: Press Themes & BAProdoction
    Author URI: Press Themes & BAProdoction
    License: GPL3
    */
    ?>
    <?php
    /*
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, orss code. A hook is a PHP function call that occurs sizeen a specific event occurs.

    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program. If not, see <https://www.gnu.org/licenses/>.
    */
    ?>

    <?php
    //----------Extract Post Thumbnail For Manul Sizing----------//
    function wpgym_extract_post_thumb( $str ){
    $matches = array();
    $pattern = '/src=[\'"]?([^\'" >]+)[\'" >]/';
    $match = preg_match( $pattern, $str, $matches );
    return($matches[1]);
    }
    //----------Display The Relted Posts----------//
    function related_post() {

    global $wpdb, $post, $table_prefix;

    if ($post->ID) {

    $retval = '
    <br clear="all"/><hr/>Related Post: ';

    // Get tags
    $tags = wp_get_post_tags($post->ID);
    $tagsarray = array();
    foreach ($tags as $tag) {
    $tagsarray[] = $tag->term_id;
    }
    $tagslist = implode(',', $tagsarray);

    // Do the query
    $q = "
    SELECT p.*, count(tr.object_id) as count
    FROM $wpdb->term_taxonomy AS tt, $wpdb->term_relationships AS tr, $wpdb->posts AS p
    WHERE tt.taxonomy ='post_tag'
    AND tt.term_taxonomy_id = tr.term_taxonomy_id
    AND tr.object_id = p.ID
    AND tt.term_id IN ($tagslist)
    AND p.ID != $post->ID
    AND p.post_status = 'publish'
    AND p.post_date_gmt < NOW()
    GROUP BY tr.object_id
    ORDER BY count DESC, p.post_date_gmt DESC
    LIMIT 5;";

    $related = $wpdb->get_results($q);

    if ( $related ) {
    foreach($related as $r) {
    $retval .= '
    <span><a title="'.wptexturize($r->post_title).'" href="'.get_permalink($r->ID).'">'.wptexturize($r->post_title).'</a></span> |
    ';
    }
    } else {
    $retval .= '
    <span>No related posts found</span>
    ';
    }
    $retval .= '<hr/>
    ';
    return $retval;
    }
    return;
    }
    //----------Display Mp3----------//
    function PostAudio(){
    if (function_exists("insert_audio_player")) {
    $audiofile = get_post_meta($post->ID, audio, true);
    $author = get_the_author();
    $podcasttitle = get_the_title($post->ID);
    // do we have one?
    if($audiofile) {
    return''.insert_audio_player('[audio:'.$audiofile.'|titles='.$podcasttitle.'|artists='.$author.'|width=100%]').'
    <a href="' . get_bloginfo ( 'url' ).'/audio/'.$audiofile.'">Click to Download the Audio File</a>' . get_bloginfo ( 'audio' ).'';
    }
    }
    }
    //----------Display The Modify Rss Feed----------//
    function postTitle($title) {
    return $title;
    }
    function PostThumb($content) {
    if($content){ $content = $content; $brake = ''; }else{ $content = '<br/>'; $brake = '<br/>';}//Check if the post has content .
    if(current_theme_supports('post-thumbnails')){//Check if the theme has Post Thumbnail Support.
    if(has_post_thumbnail()) { //Check if the post has a Post Thumbnail assigned to it.
    $body ='<img width="100" height="100" alt="Post Thumnale" src="'.wpgym_extract_post_thumb(get_the_post_thumbnail()).'" class="wp-post-image alignleft" align="left"><div align="justify">'.$content.'</div>'.$brake.''.related_post().''.PostAudio().'Tags: '.get_the_tag_list('',', ','<br/>').'<hr/>';
    }else{
    $body ='<img width="100" height="100" alt="Placer Hoilder IMG" src="'.plugins_url('images/place-Holder.png' , __FILE__).'" class="wp-post-image alignleft" align="left"><div align="justify">'.$content.'</div>'.$brake.''.related_post().''.PostAudio().'Tags: '.get_the_tag_list('',', ','<br/>').'<hr/>';
    }
    }else{
    $body ='<div align="justify">'.$content.'</div>'.$brake.''.related_post().''.PostAudio().'Tags: '.get_the_tag_list('',', ','<br/>').'<hr/>';
    }
    return $body;
    }
    add_filter('the_title_rss', 'postTitle');
    add_filter('the_excerpt_rss', 'PostThumb');
    add_filter('the_content_rss', 'PostThumb');
    //----------Display The Modify Rss Feed----------//
    function excerpt_ellipse($text) {
    return'<script>
    function removeElement(id) {
    var element = document.getElementById(id);
    element.parentNode.removeChild(element);
    }
    window.onload = function() {
    removeElement("more")
    };
    </script>'.$text.'';
    }
    add_action('do_feed', 'excerpt_ellipse', 1);
    add_action('do_feed_rdf', 'excerpt_ellipse', 1);
    add_action('do_feed_rss', 'excerpt_ellipse', 1);
    add_action('do_feed_rss2', 'excerpt_ellipse', 1);
    add_action('do_feed_atom', 'excerpt_ellipse', 1);
    add_filter('the_excerpt_rss', 'excerpt_ellipse',1);
    add_filter('the_content_rss', 'excerpt_ellipse',1);
    ?>
    Plugin Author Bowo

    (@qriouslad)

    @pressthemes1 thank you for the suggestion and code. This is well noted for now.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.