Skip to content

Instantly share code, notes, and snippets.

@alexkingorg
Last active December 19, 2015 17:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexkingorg/5991550 to your computer and use it in GitHub Desktop.
Save alexkingorg/5991550 to your computer and use it in GitHub Desktop.
Pull GitHub activity feed into WordPress and output the items of interest.
<?php
$feed = fetch_feed('https://github.com/alexkingorg.atom');
// some activity isn't interesting enough to output
$ignore_types = array(
'issue_comment',
'watch',
);
$i = 0;
foreach ($feed->get_items() as $item) {
if ($i == 5) {
break;
}
$content = $item->data['child']['http://www.w3.org/2005/Atom']['content'][0]['data'];
$skip = false;
foreach ($ignore_types as $type) {
if (strpos($content, '<!-- '.$type.' -->') !== false) {
$skip = true;
break;
}
}
if (!$skip) {
// we're trusting GitHub's content here
echo '<div class="activity-item">'.$content.'</div>';
$i++;
}
}
unset($feed);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment