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

Twitter Timeline: fix Undefined index notice #6

Merged
merged 4 commits into from
Dec 21, 2013
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
19 changes: 10 additions & 9 deletions modules/widgets/twitter-timeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ public function widget( $args, $instance ) {
* @return array Updated safe values to be saved.
*/
public function update( $new_instance, $old_instance ) {
$non_hex_regex = '/[^a-f0-9]/';
$instance = array();
$instance['title'] = sanitize_text_field( $new_instance['title'] );
$instance['width'] = (int) $new_instance['width'];
$instance['height'] = (int) $new_instance['height'];
$instance['width'] = ( 0 !== (int) $new_instance['width'] ) ? (int) $new_instance['width'] : 225;
$instance['height'] = ( 0 !== (int) $new_instance['height'] ) ? (int) $new_instance['height'] : 400;
$instance['tweet-limit'] = (int) $new_instance['tweet-limit'];
$non_hex_regex = '/[^a-f0-9]/';
$instance = array();
$instance['title'] = sanitize_text_field( $new_instance['title'] );
$instance['width'] = (int) $new_instance['width'];
$instance['height'] = (int) $new_instance['height'];
$instance['width'] = ( 0 !== (int) $new_instance['width'] ) ? (int) $new_instance['width'] : 225;
$instance['height'] = ( 0 !== (int) $new_instance['height'] ) ? (int) $new_instance['height'] : 400;
$instance['tweet-limit'] = ( 0 !== (int) $new_instance['tweet-limit'] ) ? (int) $new_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 @@ -151,6 +151,7 @@ public function form( $instance ) {
'border-color' => '#e8e8e8',
'theme' => 'light',
'chrome' => array(),
'tweet-limit' => null,
);

$instance = wp_parse_args( (array) $instance, $defaults );
Expand All @@ -173,7 +174,7 @@ public function form( $instance ) {

<p>
<label for="<?php echo $this->get_field_id( 'tweet-limit' ); ?>"><?php esc_html_e( '# of Tweets Shown:', 'jetpack' ); ?></label>
<input class="widefat" id="<?php echo $this->get_field_id( 'tweet-limit' ); ?>" name="<?php echo $this->get_field_name( 'tweet-limit' ); ?>" type="text" value="<?php echo esc_attr( $instance['tweet-limit'] ); ?>" />
<input class="widefat" id="<?php echo $this->get_field_id( 'tweet-limit' ); ?>" name="<?php echo $this->get_field_name( 'tweet-limit' ); ?>" type="number" min="1" max="20" value="<?php echo esc_attr( $instance['tweet-limit'] ); ?>" />
</p>

<p><small>
Expand Down