diff --git a/bridges/TwitterBridge.php b/bridges/TwitterBridge.php index 8f546c6f..c62a6595 100644 --- a/bridges/TwitterBridge.php +++ b/bridges/TwitterBridge.php @@ -75,6 +75,12 @@ EOD 'required' => false, 'type' => 'checkbox', 'title' => 'Hide retweets' + ), + 'nopinned' => array( + 'name' => 'Without pinned tweet', + 'required' => false, + 'type' => 'checkbox', + 'title' => 'Hide pinned tweet' ) ), 'By list' => array( @@ -246,6 +252,14 @@ EOD return $carry; }, array()); + $hidePinned = $this->getInput('nopinned'); + if ($hidePinned) { + $pinnedTweetId = null; + if (isset($data->timeline->instructions[1]) && isset($data->timeline->instructions[1]->pinEntry)) { + $pinnedTweetId = $data->timeline->instructions[1]->pinEntry->entry->content->item->content->tweet->id; + } + } + foreach($data->globalObjects->tweets as $tweet) { /* Debug::log('>>> ' . json_encode($tweet)); */ @@ -259,6 +273,11 @@ EOD continue; } + // Skip pinned tweet + if ($hidePinned && $tweet->id_str === $pinnedTweetId) { + continue; + } + $item = array(); // extract username and sanitize $user_info = $this->getUserInformation($tweet->user_id_str, $data->globalObjects);