[ hide ]

    The SyndicatedPost class is a class that FeedWordPress uses to manage the conversion of incoming items from the feed parser into posts for the WordPress database. It contains several internal management methods primarily of interest to someone working on the FeedWordPress source, as well as some utility methods for extracting useful data from many different feed formats, which may be useful to FeedWordPress users who make use of feed data in PHP add-ons and filters.

    Sample Usage

    This sample filter, based on the syndicated_item_content filter, will add information about the source of an article to the content of articles syndicated from that source, if the articles were authored by someone other a defined author. In order to get the author’s name, it makes use of the SyndicatedPost object passed to the filter — in particular, by retrieving author data through the :author() method.

    Plugin Name: FWP+: Add source to other people's content
    Plugin URI:
    Description: alters the content of incoming syndicated posts to include the name of the syndication source, when the author is not "radgeek"
    Version: 2010.0208
    Author: Charles Johnson
    Author URI:
    License: GPL
    • /

    // Change the value to look for different author names. define('FWPASTOPC_AUTHOR_NAME', 'radgeek');

    add_filter( /*hook=*/ 'syndicated_item_content', /*function=*/ 'fwp_add_source_to_content', /*order=*/ 10, /*arguments=*/ 2 );

    /** * fwp_add_source_to_content: Gets the content of the syndication source and * includes it in the content of all syndicated posts * that are not by the defined author (presumably, you). * * @param string $content The current content of the syndicated item. * @param SyndicatedPost $post An object representing the syndicated post. * The syndicated item data is contained in $post->item * The syndication feed channel data is contained in $post->feed * The subscription data is contained in $post->link * @return string The new content to give the syndicated item. */ function fwp_add_source_to_content ($content, $post) { // Use SyndicatedPost::author() to get author // data in a convenient array $author = $post->author();

    // Authored by someone else if (!preg_match('/^'.FWPASTOPC_AUTHOR_NAME.'$/', $author[1])) : // Use SyndicatedLink::homepage() and // SyndicatedLink::name() to get source // data. Append to $content. $content .= '<p>This is a syndicated post, which originally appeared at <a href="'.$post->link->homepage().'">'. $post->link->name().'</a>. Reprinted with permission.</p>'; endif;

    // Send it back return $content; } /* fwp_add_source_to_content() */


    Class SyndicatedPost is declared in the syndicatedpost.class.php file in your FeedWordPress installation.

    class SyndicatedPost {
        var $item = null;

    var $link = null; var $feed = null; var $feedmeta = null;

    var $post = array ();

    #### CONSTRUCTOR METHOD #### function SyndicatedPost ($item, $source); // $item is a MagpieRSS array // $source is a SyndicatedLink object


    // Return date/time post was created at source function created ();

    // Return date/time post was published at source function published ($fallback = true);

    // Return date/time post was last updated at source function updated ($fallback = true, $default = -1);

    function update_hash (); function guid (); function author (); function isTaggedAs ($tag);

    #### POST STATUS #### function filtered (); function freshness ();

    #### BUILT-IN CONTENT FILTERS #### function resolve_single_relative_uri ($refs); function resolve_relative_uris ($content, $obj); function strip_attribute_from_tag ($refs); function sanitize_content ($content, $obj);

    #### INTERNAL MANAGEMENT METHODS #### function wp_id (); function store (); function insert_new (); function update_existing (); function normalize_post ($new = true); function validate_post_id ($dbpost, $ns); function fix_revision_meta ($revision_id); function avoid_kses_munge ($content); function add_rss_meta (); function author_id ($unfamiliar_author = 'create'); function category_ids ($cats, $unfamiliar_category = 'create', $tags_too = false); function use_api ($tag); } // class SyndicatedPost
    This page is a Wiki! Log in or register an account to edit.

    2 thoughts on “SyndicatedPost

    1. Hi Charles, the all your work just perfect. Thank you!
      I can say that i’m lame in filters and scripts, that’s why i’m going to ask you.
      I’m crawling some posts that only have Title and an Image.
      When the plugin gets all the info on my index page it place Feautured Image / Title/ Image form the post.
      The problem is that i want to remove this second image, i want to skip this Image.
      Thank you for your time and help.

    Leave a Reply

    Your email address will not be published. Required fields are marked *