Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.