Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filters to the output of "In reply to" and time displayed after tweets #13

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions wp-twitter-widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -957,26 +957,41 @@ public function display( $args ) {
$widgetContent .= '<li>';
$widgetContent .= "<span class='entry-content'>{$entryContent}</span>";
$widgetContent .= " <span class='entry-meta'>";
$widgetContent .= "<span class='time-meta'>";
$linkAttrs = array(
'href' => "http://twitter.com/{$tweet->user->screen_name}/statuses/{$tweet->id_str}"
);
$widgetContent .= $this->_buildLink( $tweet->ago, $linkAttrs );
$widgetContent .= '</span>';
$timeLink = $this->_buildLink( $tweet->ago, $linkAttrs );
$timeContent = '<span class="time-meta">' . $timeLink . '</span>';
/**
* The content of the Time displayed after the tweet content
*
* @param string $timeContent The content of Time display.
* @param object $tweet The current tweet object.
* @param $timeLink The formatted time to link and default text.
* @param $tweet->ago The time string converted to "# ___(s) ago"
*/
$widgetContent .= apply_filters( 'tweet_time_content', $timeContent, $tweet, $timeLink, $tweet->ago );

if ( 'true' != $args['hidefrom'] ) {
$from = sprintf( __( 'from %s', $this->_slug ), str_replace( '&', '&amp;', $tweet->source ) );
$widgetContent .= " <span class='from-meta'>{$from}</span>";
}
if ( !empty( $tweet->in_reply_to_screen_name ) ) {
$rtLinkText = sprintf( __( 'in reply to %s', $this->_slug ), $tweet->in_reply_to_screen_name );
$widgetContent .= ' <span class="in-reply-to-meta">';
$linkAttrs = array(
'href' => "http://twitter.com/{$tweet->in_reply_to_screen_name}/statuses/{$tweet->in_reply_to_status_id_str}",
'class' => 'reply-to'
);
$widgetContent .= $this->_buildLink( $rtLinkText, $linkAttrs );
$widgetContent .= '</span>';
$replyToLink = $this->_buildLink( $rtLinkText, $linkAttrs );
$replyToContent = ' <span class="in-reply-to-meta">' . $replyToLink . '</span>';
/**
* The content of the "In Reply To" text after the tweet content.
*
* @param string $replyToContent The content of "In Reply To".
* @param object $tweet The current tweet object.
* @param $replyToLink The formatted reply to link and default text.
*/
$widgetContent .= apply_filters( 'in_reply_to_content', $replyToContent, $tweet, $replyToLink );
}
$widgetContent .= '</span>';

Expand Down