Skip to content

Commit

Permalink
Merge pull request #6012 from Automattic/update/facebook-likebox-widget
Browse files Browse the repository at this point in the history
Extra Sidebar Widgets: Facebook Page Plugin: better UX for min/max height and width
  • Loading branch information
dereksmart authored Jan 3, 2017
2 parents 7eacaa7 + be66ce4 commit 7cdebd1
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions modules/widgets/facebook-likebox.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function jetpack_facebook_likebox_init() {
}

/**
* Facebook Page Plugin (formely known as the Like Box)
* Facebook Page Plugin (formerly known as the Like Box)
* Display a Facebook Page Plugin as a widget (replaces the old like box plugin)
* https://developers.facebook.com/docs/plugins/page-plugin
*/
Expand Down Expand Up @@ -165,15 +165,17 @@ function form( $instance ) {

<p>
<label for="<?php echo $this->get_field_id( 'width' ); ?>">
<?php _e( 'Width', 'jetpack' ); ?>
<input type="number" class="smalltext" min="1" max="999" maxlength="3" name="<?php echo $this->get_field_name( 'width' ); ?>" id="<?php echo $this->get_field_id( 'width' ); ?>" value="<?php echo esc_attr( $like_args['width'] ); ?>" style="text-align: center;" />px
<?php _e( 'Width in pixels', 'jetpack' ); ?>
<input type="number" class="smalltext" min="<?php echo esc_attr( $this->min_width ); ?>" max="<?php echo esc_attr( $this->max_width ); ?>" maxlength="3" name="<?php echo $this->get_field_name( 'width' ); ?>" id="<?php echo $this->get_field_id( 'width' ); ?>" value="<?php echo esc_attr( $like_args['width'] ); ?>" style="text-align: center;" />
<small><?php echo sprintf( __( 'Minimum: %s', 'jetpack' ), $this->min_width ); ?> / <?php echo sprintf( __( 'Maximum: %s', 'jetpack' ), $this->max_width ); ?></small>
</label>
</p>

<p>
<label for="<?php echo $this->get_field_id( 'height' ); ?>">
<?php _e( 'Height', 'jetpack' ); ?>
<input type="number" class="smalltext" min="1" max="999" maxlength="3" name="<?php echo $this->get_field_name( 'height' ); ?>" id="<?php echo $this->get_field_id( 'height' ); ?>" value="<?php echo esc_attr( $like_args['height'] ); ?>" style="text-align: center;" />px
<?php _e( 'Height in pixels', 'jetpack' ); ?>
<input type="number" class="smalltext" min="<?php echo esc_attr( $this->min_height ); ?>" max="<?php echo esc_attr( $this->max_height ); ?>" maxlength="3" name="<?php echo $this->get_field_name( 'height' ); ?>" id="<?php echo $this->get_field_id( 'height' ); ?>" value="<?php echo esc_attr( $like_args['height'] ); ?>" style="text-align: center;" />
<small><?php echo sprintf( __( 'Minimum: %s', 'jetpack' ), $this->min_height ); ?> / <?php echo sprintf( __( 'Maximum: %s', 'jetpack' ), $this->max_height ); ?></small>
</label>
</p>

Expand Down Expand Up @@ -262,14 +264,17 @@ function normalize_facebook_args( $args ) {
}

function is_valid_facebook_url( $url ) {
return ( FALSE !== strpos( $url, 'facebook.com' ) ) ? TRUE : FALSE;
return ( false !== strpos( $url, 'facebook.com' ) ) ? true : false;
}

function normalize_int_value( $value, $default = 0, $max = 0, $min = 0 ) {
$value = (int) $value;

if ( $max < $value || $min > $value )
$value = $default;
if ( $value > $max ) {
$value = $max;
} else if ( $value < $min ) {
$value = $min;
}

return (int) $value;
}
Expand Down

0 comments on commit 7cdebd1

Please sign in to comment.