syndicated_item_updated

Contents

[ hide ]

    The syndicated_item_updated hook allows you to write filters that alter or act on the date and time that FeedWordPress will treat as the time a syndicated post was most recently updated. By default, FeedWordPress will use the last-updated timestamp provided by the feed; note that this indicates the time that a post was last updated at its original source, not the time that FeedWordPress most recently updated it on your aggregator website.

    The timestamp being filtered is a Unix-epoch timestamp — a long integer measuring the number of seconds elapsed since midnight on 1 January 1970 (UTC). If you try to return a date in any other format (such as text date/time formats) it will produce incorrect results. To convert dates and times in other formats, you may be able to make use of FeedWordPress’s included FeedTime class, or PHP functions such as [1].

    The hook passes two parameters to any registered filter functions: (1) an long integer representing the date and time that a post first appeared at its original source, and (2) an object of class SyndicatedPost, representing the syndicated item as a whole. The function should return a long integer representing the revised date and time to use as the publication time of the imported post.

    Sample

     <?php
     /*
     Plugin Name: FWP+: Use Google Calendar Event Times
     Plugin URI: http://feedwordpress.radgeek.com/wiki/syndicateditemupdated
     Description: alters the last-modified timestamp on incoming syndicated posts to match the start time for GCal events
     Version: 2010.1205
     Author: Charles Johnson
     Author URI: http://radgeek.com/
     License: GPL
     */
    

    add_filter( /*hook=*/ 'syndicated_item_updated', /*function=*/ 'use_gcalendar_event_times', /*order=*/ 10, /*arguments=*/ 2 );

    function use_gcalendar_event_times ($updated, $post) { // Google Calendar events use a custom gd:when element to indicate the // time of the event. Use :query to retrieve it. $startTimes = $obj->query('/gd:when/@startTime'); if (count($startTimes) > 0) :

    // query() always returns an array foreach ($startTimes as $time) : $t = new FeedTime($time); $published = $t->timestamp(); endforeach;

    endif;

    return $updated; } /* use_gcalendar_event_times() */
    This page is a Wiki! Log in or register an account to edit.

    Leave a Reply

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