syndicated_item_link

Contents

[ hide ]

    The syndicated_item_link hook allows you to write filters which alter or act on the permalink URL for posts that are syndicated by FeedWordPress. The hook passes two parameters to any registered filter functions: a string containing the URL of the item (which is usually a permalink to the item on the original source website), and an object of class SyndicatedPost representing the syndicated item as a whole.

    Sample

    This example rewrites permalinks to point to their record in the Internet Archive Wayback Machine. Probably not tremendously useful in practice, since items in the Wayback machine are usually embargoed for about half a year before they appear publicly.

    <?php
    /*
    Plugin Name: FWP+: Wayback Permalinks
    Plugin URI: http://feedwordpress.radgeek.com/wiki/syndicated_item_link/
    Description: alters the permalinks titles of incoming syndicated posts to point to their record in the Internet Archive Wayback machine
    Version: 2012.0511 
    Author: Charles Johnson
    Author URI: http://radgeek.com/
    License: GPL
    
    
    • /


    add_filter( /*hook=*/ 'syndicated_item_link', /*function=*/ 'fwp_wayback_link', /*order=*/ 10, /*arguments=*/ 2 );

    /** * fwp_wayback_link: Gets the permalink of the syndication source and * rewrites it to point to the Wayback Machine URL for that link. * * @param string $url The permalink 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 permalink to use for the syndicated item. */

    function fwp_wayback_link ($url, $post) { // Wayback links are easy to make. /*/${url} points to a list of all archived // versions publicly available. /YYYYMMDDHHmmSS/${url} points to the // snapshot of the site taken most recently before or at that timestamp. $url = 'http://web.archive.org/web/*/' . $url;

    // Send it back return $url; } /* fwp_wayback_link() */
    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 *