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

Extra Sidebar Widgets: update Twitter Timeline for sane limit #6021

Merged
merged 2 commits into from
Jan 27, 2017
Merged
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
15 changes: 13 additions & 2 deletions modules/widgets/twitter-timeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,18 @@ public function update( $new_instance, $old_instance ) {
}

$tweet_limit = (int) $new_instance['tweet-limit'];
$instance['tweet-limit'] = ( $tweet_limit ? $tweet_limit : null );
if ( $tweet_limit ) {
$instance['tweet-limit'] = min( max( $tweet_limit, 1 ), 20 );
/**
* A timeline with a specified limit is expanded to the height of those Tweets.
* The specified height value no longer applies, so reject the height value
* when a valid limit is set: a widget attempting to save both limit 5 and
* height 400 would be saved with just limit 5.
*/
$instance['height'] = '';
} else {
$instance['tweet-limit'] = null;
}

// If they entered something that might be a full URL, try to parse it out
if ( is_string( $new_instance['widget-id'] ) ) {
Expand Down Expand Up @@ -323,7 +334,7 @@ class="widefat"

<p>
<label for="<?php echo $this->get_field_id( 'tweet-limit' ); ?>">
<?php esc_html_e( '# of Tweets Shown:', 'jetpack' ); ?>
<?php esc_html_e( '# of Tweets Shown (1 to 20):', 'jetpack' ); ?>
</label>
<input
class="widefat"
Expand Down