summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2019-01-01 22:18:11 -0500
committerAnthony G. Basile <blueness@gentoo.org>2019-01-01 22:18:11 -0500
commit018bd442ec1e04ba78a6628763414eb60b359398 (patch)
tree448cde462397af33e5a964ba5d0803b73c65040e /plugins/jetpack/modules/widgets
parentUpdate easy-table 1.8 (diff)
downloadblogs-gentoo-018bd442ec1e04ba78a6628763414eb60b359398.tar.gz
blogs-gentoo-018bd442ec1e04ba78a6628763414eb60b359398.tar.bz2
blogs-gentoo-018bd442ec1e04ba78a6628763414eb60b359398.zip
Update jetpack 6.8.1
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'plugins/jetpack/modules/widgets')
-rw-r--r--plugins/jetpack/modules/widgets/authors.php74
-rw-r--r--plugins/jetpack/modules/widgets/blog-stats.php4
-rw-r--r--plugins/jetpack/modules/widgets/contact-info.php44
-rw-r--r--plugins/jetpack/modules/widgets/eu-cookie-law.php6
-rw-r--r--plugins/jetpack/modules/widgets/facebook-likebox.php73
-rw-r--r--plugins/jetpack/modules/widgets/flickr.php4
-rw-r--r--plugins/jetpack/modules/widgets/gallery.php131
-rw-r--r--plugins/jetpack/modules/widgets/goodreads.php46
-rw-r--r--plugins/jetpack/modules/widgets/google-translate.php20
-rw-r--r--plugins/jetpack/modules/widgets/googleplus-badge.php65
-rw-r--r--plugins/jetpack/modules/widgets/gravatar-profile.php132
-rw-r--r--plugins/jetpack/modules/widgets/image-widget.php82
-rw-r--r--plugins/jetpack/modules/widgets/internet-defense-league.php16
-rw-r--r--plugins/jetpack/modules/widgets/mailchimp.php2
-rw-r--r--plugins/jetpack/modules/widgets/my-community.php44
-rw-r--r--plugins/jetpack/modules/widgets/rsslinks-widget.php91
-rw-r--r--plugins/jetpack/modules/widgets/search.php123
-rw-r--r--plugins/jetpack/modules/widgets/simple-payments.php241
-rw-r--r--plugins/jetpack/modules/widgets/simple-payments/admin-warning.php16
-rw-r--r--plugins/jetpack/modules/widgets/simple-payments/customizer.css8
-rw-r--r--plugins/jetpack/modules/widgets/simple-payments/customizer.js19
-rw-r--r--plugins/jetpack/modules/widgets/simple-payments/form.php118
-rw-r--r--plugins/jetpack/modules/widgets/simple-payments/widget.php16
-rw-r--r--plugins/jetpack/modules/widgets/social-icons.php61
-rw-r--r--plugins/jetpack/modules/widgets/social-media-icons.php15
-rw-r--r--plugins/jetpack/modules/widgets/top-posts.php199
-rw-r--r--plugins/jetpack/modules/widgets/twitter-timeline.php20
-rw-r--r--plugins/jetpack/modules/widgets/upcoming-events.php28
-rw-r--r--plugins/jetpack/modules/widgets/wordpress-post-widget.php2
29 files changed, 1021 insertions, 679 deletions
diff --git a/plugins/jetpack/modules/widgets/authors.php b/plugins/jetpack/modules/widgets/authors.php
index 3cbd835a..dfc78652 100644
--- a/plugins/jetpack/modules/widgets/authors.php
+++ b/plugins/jetpack/modules/widgets/authors.php
@@ -23,8 +23,8 @@ class Jetpack_Widget_Authors extends WP_Widget {
/** This filter is documented in modules/widgets/facebook-likebox.php */
apply_filters( 'jetpack_widget_name', __( 'Authors', 'jetpack' ) ),
array(
- 'classname' => 'widget_authors',
- 'description' => __( 'Display blogs authors with avatars and recent posts.', 'jetpack' ),
+ 'classname' => 'widget_authors',
+ 'description' => __( 'Display blogs authors with avatars and recent posts.', 'jetpack' ),
'customize_selective_refresh' => true,
)
);
@@ -57,7 +57,7 @@ class Jetpack_Widget_Authors extends WP_Widget {
$cache_bucket = is_ssl() ? 'widget_authors_ssl' : 'widget_authors';
if ( '%BEG_OF_TITLE%' != $args['before_title'] ) {
- if ( $output = wp_cache_get( $cache_bucket, 'widget') ) {
+ if ( $output = wp_cache_get( $cache_bucket, 'widget' ) ) {
echo $output;
return;
}
@@ -65,7 +65,14 @@ class Jetpack_Widget_Authors extends WP_Widget {
ob_start();
}
- $instance = wp_parse_args( $instance, array( 'title' => __( 'Authors', 'jetpack' ), 'all' => false, 'number' => 5, 'avatar_size' => 48 ) );
+ $instance = wp_parse_args(
+ $instance, array(
+ 'title' => __( 'Authors', 'jetpack' ),
+ 'all' => false,
+ 'number' => 5,
+ 'avatar_size' => 48,
+ )
+ );
$instance['number'] = min( 10, max( 0, (int) $instance['number'] ) );
// We need to query at least one post to determine whether an author has written any posts or not
@@ -83,11 +90,13 @@ class Jetpack_Widget_Authors extends WP_Widget {
*/
$excluded_authors = apply_filters( 'jetpack_widget_authors_exclude', $default_excluded_authors );
- $authors = get_users( array(
- 'fields' => 'all',
- 'who' => 'authors',
- 'exclude' => (array) $excluded_authors,
- ) );
+ $authors = get_users(
+ array(
+ 'fields' => 'all',
+ 'who' => 'authors',
+ 'exclude' => (array) $excluded_authors,
+ )
+ );
echo $args['before_widget'];
/** This filter is documented in core/src/wp-includes/default-widgets.php */
@@ -108,14 +117,16 @@ class Jetpack_Widget_Authors extends WP_Widget {
$post_types = apply_filters( 'jetpack_widget_authors_post_types', $default_post_type );
foreach ( $authors as $author ) {
- $r = new WP_Query( array(
- 'author' => $author->ID,
- 'posts_per_page' => $query_number,
- 'post_type' => $post_types,
- 'post_status' => 'publish',
- 'no_found_rows' => true,
- 'has_password' => false,
- ) );
+ $r = new WP_Query(
+ array(
+ 'author' => $author->ID,
+ 'posts_per_page' => $query_number,
+ 'post_type' => $post_types,
+ 'post_status' => 'publish',
+ 'no_found_rows' => true,
+ 'has_password' => false,
+ )
+ );
if ( ! $r->have_posts() && ! $instance['all'] ) {
continue;
@@ -133,8 +144,7 @@ class Jetpack_Widget_Authors extends WP_Widget {
echo '<strong>' . esc_html( $author->display_name ) . '</strong>';
echo '</a>';
- }
- else if ( $instance['all'] ) {
+ } elseif ( $instance['all'] ) {
if ( $instance['avatar_size'] > 1 ) {
echo get_avatar( $author->ID, $instance['avatar_size'], '', true ) . ' ';
}
@@ -185,7 +195,14 @@ class Jetpack_Widget_Authors extends WP_Widget {
}
public function form( $instance ) {
- $instance = wp_parse_args( $instance, array( 'title' => '', 'all' => false, 'avatar_size' => 48, 'number' => 5 ) );
+ $instance = wp_parse_args(
+ $instance, array(
+ 'title' => '',
+ 'all' => false,
+ 'avatar_size' => 48,
+ 'number' => 5,
+ )
+ );
?>
<p>
@@ -211,7 +228,16 @@ class Jetpack_Widget_Authors extends WP_Widget {
<label>
<?php _e( 'Avatar Size (px):', 'jetpack' ); ?>
<select name="<?php echo $this->get_field_name( 'avatar_size' ); ?>">
- <?php foreach( array( '1' => __( 'No Avatars', 'jetpack' ), '16' => '16x16', '32' => '32x32', '48' => '48x48', '96' => '96x96', '128' => '128x128' ) as $value => $label ) { ?>
+ <?php
+ foreach ( array(
+ '1' => __( 'No Avatars', 'jetpack' ),
+ '16' => '16x16',
+ '32' => '32x32',
+ '48' => '48x48',
+ '96' => '96x96',
+ '128' => '128x128',
+ ) as $value => $label ) {
+?>
<option value="<?php echo esc_attr( $value ); ?>" <?php selected( $value, $instance['avatar_size'] ); ?>><?php echo esc_html( $label ); ?></option>
<?php } ?>
</select>
@@ -228,9 +254,9 @@ class Jetpack_Widget_Authors extends WP_Widget {
* @return array
*/
public function update( $new_instance, $old_instance ) {
- $new_instance['title'] = strip_tags( $new_instance['title'] );
- $new_instance['all'] = isset( $new_instance['all'] );
- $new_instance['number'] = (int) $new_instance['number'];
+ $new_instance['title'] = strip_tags( $new_instance['title'] );
+ $new_instance['all'] = isset( $new_instance['all'] );
+ $new_instance['number'] = (int) $new_instance['number'];
$new_instance['avatar_size'] = (int) $new_instance['avatar_size'];
Jetpack_Widget_Authors::flush_cache();
diff --git a/plugins/jetpack/modules/widgets/blog-stats.php b/plugins/jetpack/modules/widgets/blog-stats.php
index 8d3f4788..8f8f0f33 100644
--- a/plugins/jetpack/modules/widgets/blog-stats.php
+++ b/plugins/jetpack/modules/widgets/blog-stats.php
@@ -28,8 +28,8 @@ class Jetpack_Blog_Stats_Widget extends WP_Widget {
*/
function __construct() {
$widget_ops = array(
- 'classname' => 'blog-stats',
- 'description' => esc_html__( 'Show a hit counter for your blog.', 'jetpack' ),
+ 'classname' => 'blog-stats',
+ 'description' => esc_html__( 'Show a hit counter for your blog.', 'jetpack' ),
'customize_selective_refresh' => true,
);
parent::__construct(
diff --git a/plugins/jetpack/modules/widgets/contact-info.php b/plugins/jetpack/modules/widgets/contact-info.php
index 3705e975..292f96d7 100644
--- a/plugins/jetpack/modules/widgets/contact-info.php
+++ b/plugins/jetpack/modules/widgets/contact-info.php
@@ -21,8 +21,8 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) {
*/
function __construct() {
$widget_ops = array(
- 'classname' => 'widget_contact_info',
- 'description' => __( 'Display a map with your location, hours, and contact information.', 'jetpack' ),
+ 'classname' => 'widget_contact_info',
+ 'description' => __( 'Display a map with your location, hours, and contact information.', 'jetpack' ),
'customize_selective_refresh' => true,
);
parent::__construct(
@@ -63,7 +63,7 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) {
'showmap' => 0,
'apikey' => null,
'lat' => null,
- 'lon' => null
+ 'lon' => null,
);
}
@@ -114,14 +114,13 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) {
$map_link = $this->build_map_link( $instance['address'] );
- echo '<div class="confit-address" itemscope itemtype="http://schema.org/PostalAddress" itemprop="address"><a href="' . esc_url( $map_link ) . '" target="_blank">' . str_replace( "\n", "<br/>", esc_html( $instance['address'] ) ) . "</a></div>";
+ echo '<div class="confit-address" itemscope itemtype="http://schema.org/PostalAddress" itemprop="address"><a href="' . esc_url( $map_link ) . '" target="_blank">' . str_replace( "\n", '<br/>', esc_html( $instance['address'] ) ) . '</a></div>';
}
if ( '' != $instance['phone'] ) {
if ( wp_is_mobile() ) {
- echo '<div class="confit-phone"><span itemprop="telephone"><a href="' . esc_url( 'tel:' . $instance['phone'] ) . '">' . esc_html( $instance['phone'] ) . "</a></span></div>";
- }
- else {
+ echo '<div class="confit-phone"><span itemprop="telephone"><a href="' . esc_url( 'tel:' . $instance['phone'] ) . '">' . esc_html( $instance['phone'] ) . '</a></span></div>';
+ } else {
echo '<div class="confit-phone"><span itemprop="telephone">' . esc_html( $instance['phone'] ) . '</span></div>';
}
}
@@ -134,7 +133,7 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) {
}
if ( '' != $instance['hours'] ) {
- echo '<div class="confit-hours" itemprop="openingHours">' . str_replace( "\n", "<br/>", esc_html( $instance['hours'] ) ) . "</div>";
+ echo '<div class="confit-hours" itemprop="openingHours">' . str_replace( "\n", '<br/>', esc_html( $instance['hours'] ) ) . '</div>';
}
echo '</div>';
@@ -191,30 +190,29 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) {
// Get the lat/lon of the user specified address.
$address = $this->urlencode_address( $instance['address'] );
- $path = "https://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=" . $address;
+ $path = 'https://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=' . $address;
/** This action is documented in modules/widgets/contact-info.php */
$key = apply_filters( 'jetpack_google_maps_api_key', $instance['apikey'] );
if ( ! empty( $key ) ) {
$path = add_query_arg( 'key', $key, $path );
}
- $json = wp_remote_retrieve_body( wp_remote_get( esc_url( $path, null, null ) ) );
+ $json = wp_remote_retrieve_body( wp_remote_get( esc_url( $path, null, null ) ) );
if ( ! $json ) {
// The read failed :(
- esc_html_e( "There was a problem getting the data to display this address on a map. Please refresh your browser and try again.", 'jetpack' );
+ esc_html_e( 'There was a problem getting the data to display this address on a map. Please refresh your browser and try again.', 'jetpack' );
die();
}
$json_obj = json_decode( $json );
- if ( "ZERO_RESULTS" == $json_obj->status ) {
+ if ( 'ZERO_RESULTS' == $json_obj->status ) {
// The address supplied does not have a matching lat / lon.
// No map is available.
- $instance['lat'] = "0";
- $instance['lon'] = "0";
- }
- else {
+ $instance['lat'] = '0';
+ $instance['lon'] = '0';
+ } else {
$loc = $json_obj->results[0]->geometry->location;
@@ -228,8 +226,7 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) {
if ( ! isset( $new_instance['showmap'] ) ) {
$instance['showmap'] = 0;
- }
- else {
+ } else {
$instance['showmap'] = intval( $new_instance['showmap'] );
}
@@ -271,8 +268,7 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) {
<input class="jp-contact-info-showmap" id="<?php echo esc_attr( $this->get_field_id( 'showmap' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'showmap' ) ); ?>" value="1" type="checkbox" <?php checked( $instance['showmap'], 1 ); ?> />
<label for="<?php echo esc_attr( $this->get_field_id( 'showmap' ) ); ?>"><?php esc_html_e( 'Show map', 'jetpack' ); ?></label>
<?php
- }
- else {
+ } else {
?>
<span class="error-message"><?php _e( 'Sorry. We can not plot this address. A map will not be displayed. Is the address formatted correctly?', 'jetpack' ); ?></span>
<input id="<?php echo esc_attr( $this->get_field_id( 'showmap' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'showmap' ) ); ?>" value="<?php echo( intval( $instance['showmap'] ) ); ?>" type="hidden" />
@@ -318,7 +314,7 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) {
*/
function build_map_link( $address ) {
// Google map urls have lots of available params but zoom (z) and query (q) are enough.
- return "https://maps.google.com/maps?z=16&q=" . $this->urlencode_address( $address );
+ return 'https://maps.google.com/maps?z=16&q=' . $this->urlencode_address( $address );
}
@@ -350,8 +346,8 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) {
function urlencode_address( $address ) {
$address = strtolower( $address );
- $address = preg_replace( "/\s+/", " ", trim( $address ) ); // Get rid of any unwanted whitespace
- $address = str_ireplace( " ", "+", $address ); // Use + not %20
+ $address = preg_replace( '/\s+/', ' ', trim( $address ) ); // Get rid of any unwanted whitespace
+ $address = str_ireplace( ' ', '+', $address ); // Use + not %20
urlencode( $address );
return $address;
@@ -366,7 +362,7 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) {
*/
function has_good_map( $instance ) {
// The lat and lon of an address that could not be plotted will have values of 0 and 0.
- return ! ( "0" == $instance['lat'] && "0" == $instance['lon'] );
+ return ! ( '0' == $instance['lat'] && '0' == $instance['lon'] );
}
}
diff --git a/plugins/jetpack/modules/widgets/eu-cookie-law.php b/plugins/jetpack/modules/widgets/eu-cookie-law.php
index f12b84fb..62acda4a 100644
--- a/plugins/jetpack/modules/widgets/eu-cookie-law.php
+++ b/plugins/jetpack/modules/widgets/eu-cookie-law.php
@@ -81,7 +81,7 @@ if ( ! class_exists( 'Jetpack_EU_Cookie_Law_Widget' ) ) {
/** This filter is documented in modules/widgets/facebook-likebox.php */
apply_filters( 'jetpack_widget_name', esc_html__( 'Cookies & Consents Banner', 'jetpack' ) ),
array(
- 'description' => esc_html__( 'Display a banner for EU Cookie Law and GDPR compliance.', 'jetpack' ),
+ 'description' => esc_html__( 'Display a banner for EU Cookie Law and GDPR compliance.', 'jetpack' ),
'customize_selective_refresh' => true,
),
array()
@@ -154,7 +154,7 @@ if ( ! class_exists( 'Jetpack_EU_Cookie_Law_Widget' ) ) {
$instance = wp_parse_args( $instance, $this->defaults() );
- $classes = array();
+ $classes = array();
$classes['hide'] = 'hide-on-' . esc_attr( $instance['hide'] );
if ( 'negative' === $instance['color-scheme'] ) {
$classes['negative'] = 'negative';
@@ -165,7 +165,7 @@ if ( ! class_exists( 'Jetpack_EU_Cookie_Law_Widget' ) ) {
}
if ( Jetpack::is_module_active( 'wordads' ) ) {
- $classes['ads'] = 'ads-active';
+ $classes['ads'] = 'ads-active';
$classes['hide'] = 'hide-on-button';
}
diff --git a/plugins/jetpack/modules/widgets/facebook-likebox.php b/plugins/jetpack/modules/widgets/facebook-likebox.php
index 5a68c8a0..5fbc23e0 100644
--- a/plugins/jetpack/modules/widgets/facebook-likebox.php
+++ b/plugins/jetpack/modules/widgets/facebook-likebox.php
@@ -16,12 +16,12 @@ function jetpack_facebook_likebox_init() {
*/
class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
- private $default_height = 580;
- private $default_width = 340;
- private $max_width = 500;
- private $min_width = 180;
- private $max_height = 9999;
- private $min_height = 130;
+ private $default_height = 580;
+ private $default_width = 340;
+ private $max_width = 500;
+ private $min_width = 180;
+ private $max_height = 9999;
+ private $min_height = 130;
function __construct() {
parent::__construct(
@@ -37,8 +37,8 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
*/
apply_filters( 'jetpack_widget_name', __( 'Facebook Page Plugin', 'jetpack' ) ),
array(
- 'classname' => 'widget_facebook_likebox',
- 'description' => __( 'Use the Facebook Page Plugin to connect visitors to your Facebook Page', 'jetpack' ),
+ 'classname' => 'widget_facebook_likebox',
+ 'description' => __( 'Use the Facebook Page Plugin to connect visitors to your Facebook Page', 'jetpack' ),
'customize_selective_refresh' => true,
)
);
@@ -63,7 +63,7 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
$like_args = $this->normalize_facebook_args( $instance['like_args'] );
if ( empty( $like_args['href'] ) || ! $this->is_valid_facebook_url( $like_args['href'] ) ) {
- if ( current_user_can('edit_theme_options') ) {
+ if ( current_user_can( 'edit_theme_options' ) ) {
echo $before_widget;
echo '<p>' . sprintf( __( 'It looks like your Facebook URL is incorrectly configured. Please check it in your <a href="%s">widget settings</a>.', 'jetpack' ), admin_url( 'widgets.php' ) ) . '</p>';
echo $after_widget;
@@ -76,9 +76,9 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
$title = apply_filters( 'widget_title', $instance['title'] );
$page_url = set_url_scheme( $like_args['href'], 'https' );
- $like_args['show_faces'] = (bool) $like_args['show_faces'] ? 'true' : 'false';
- $like_args['stream'] = (bool) $like_args['stream'] ? 'true' : 'false';
- $like_args['cover'] = (bool) $like_args['cover'] ? 'false' : 'true';
+ $like_args['show_faces'] = (bool) $like_args['show_faces'] ? 'true' : 'false';
+ $like_args['stream'] = (bool) $like_args['stream'] ? 'true' : 'false';
+ $like_args['cover'] = (bool) $like_args['cover'] ? 'false' : 'true';
echo $before_widget;
@@ -118,7 +118,7 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
function update( $new_instance, $old_instance ) {
$instance = array(
- 'title' => '',
+ 'title' => '',
'like_args' => $this->get_default_args(),
);
@@ -126,12 +126,12 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
// Set up widget values
$instance['like_args'] = array(
- 'href' => trim( strip_tags( stripslashes( $new_instance['href'] ) ) ),
- 'width' => (int) $new_instance['width'],
- 'height' => (int) $new_instance['height'],
- 'show_faces' => isset( $new_instance['show_faces'] ),
- 'stream' => isset( $new_instance['stream'] ),
- 'cover' => isset( $new_instance['cover'] ),
+ 'href' => trim( strip_tags( stripslashes( $new_instance['href'] ) ) ),
+ 'width' => (int) $new_instance['width'],
+ 'height' => (int) $new_instance['height'],
+ 'show_faces' => isset( $new_instance['show_faces'] ),
+ 'stream' => isset( $new_instance['stream'] ),
+ 'cover' => isset( $new_instance['cover'] ),
);
$instance['like_args'] = $this->normalize_facebook_args( $instance['like_args'] );
@@ -140,10 +140,12 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
}
function form( $instance ) {
- $instance = wp_parse_args( (array) $instance, array(
- 'title' => '',
- 'like_args' => $this->get_default_args()
- ) );
+ $instance = wp_parse_args(
+ (array) $instance, array(
+ 'title' => '',
+ 'like_args' => $this->get_default_args(),
+ )
+ );
$like_args = $this->normalize_facebook_args( $instance['like_args'] );
?>
@@ -210,12 +212,12 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
function get_default_args() {
$defaults = array(
- 'href' => '',
- 'width' => $this->default_width,
- 'height' => $this->default_height,
- 'show_faces' => 'true',
- 'stream' => '',
- 'cover' => 'true',
+ 'href' => '',
+ 'width' => $this->default_width,
+ 'height' => $this->default_height,
+ 'show_faces' => 'true',
+ 'stream' => '',
+ 'cover' => 'true',
);
/**
@@ -235,14 +237,14 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
// Validate the Facebook Page URL
if ( $this->is_valid_facebook_url( $args['href'] ) ) {
- $temp = explode( '?', $args['href'] );
+ $temp = explode( '?', $args['href'] );
$args['href'] = str_replace( array( 'http://facebook.com', 'https://facebook.com' ), array( 'http://www.facebook.com', 'https://www.facebook.com' ), $temp[0] );
} else {
$args['href'] = '';
}
- $args['width'] = $this->normalize_int_value( (int) $args['width'], $this->default_width, $this->max_width, $this->min_width );
- $args['height'] = $this->normalize_int_value( (int) $args['height'], $this->default_height, $this->max_height, $this->min_height );
+ $args['width'] = $this->normalize_int_value( (int) $args['width'], $this->default_width, $this->max_width, $this->min_width );
+ $args['height'] = $this->normalize_int_value( (int) $args['height'], $this->default_height, $this->max_height, $this->min_height );
$args['show_faces'] = (bool) $args['show_faces'];
$args['stream'] = (bool) $args['stream'];
$args['cover'] = (bool) $args['cover'];
@@ -253,7 +255,7 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
if ( in_array( $args['height'], array( 580, 110, 432 ) ) ) {
if ( $args['show_faces'] && $args['stream'] ) {
$args['height'] = 580;
- } else if ( ! $args['show_faces'] && ! $args['stream'] ) {
+ } elseif ( ! $args['show_faces'] && ! $args['stream'] ) {
$args['height'] = 130;
} else {
$args['height'] = 432;
@@ -272,7 +274,7 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
if ( $value > $max ) {
$value = $max;
- } else if ( $value < $min ) {
+ } elseif ( $value < $min ) {
$value = $min;
}
@@ -282,8 +284,9 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
function normalize_text_value( $value, $default = '', $allowed = array() ) {
$allowed = (array) $allowed;
- if ( empty( $value ) || ( ! empty( $allowed ) && ! in_array( $value, $allowed ) ) )
+ if ( empty( $value ) || ( ! empty( $allowed ) && ! in_array( $value, $allowed ) ) ) {
$value = $default;
+ }
return $value;
}
diff --git a/plugins/jetpack/modules/widgets/flickr.php b/plugins/jetpack/modules/widgets/flickr.php
index c07e307b..a7867612 100644
--- a/plugins/jetpack/modules/widgets/flickr.php
+++ b/plugins/jetpack/modules/widgets/flickr.php
@@ -22,7 +22,7 @@ if ( ! class_exists( 'Jetpack_Flickr_Widget' ) ) {
/** This filter is documented in modules/widgets/facebook-likebox.php */
apply_filters( 'jetpack_widget_name', esc_html__( 'Flickr', 'jetpack' ) ),
array(
- 'description' => esc_html__( 'Display your recent Flickr photos.', 'jetpack' ),
+ 'description' => esc_html__( 'Display your recent Flickr photos.', 'jetpack' ),
'customize_selective_refresh' => true,
),
array()
@@ -52,7 +52,7 @@ if ( ! class_exists( 'Jetpack_Flickr_Widget' ) ) {
'title' => esc_html__( 'Flickr Photos', 'jetpack' ),
'items' => 4,
'flickr_image_size' => 'thumbnail',
- 'flickr_rss_url' => ''
+ 'flickr_rss_url' => '',
);
}
diff --git a/plugins/jetpack/modules/widgets/gallery.php b/plugins/jetpack/modules/widgets/gallery.php
index 83b73845..8cb24d01 100644
--- a/plugins/jetpack/modules/widgets/gallery.php
+++ b/plugins/jetpack/modules/widgets/gallery.php
@@ -9,15 +9,15 @@ Author URI: http://automattic.com
*/
class Jetpack_Gallery_Widget extends WP_Widget {
- const THUMB_SIZE = 45;
- const DEFAULT_WIDTH = 265;
+ const THUMB_SIZE = 45;
+ const DEFAULT_WIDTH = 265;
- protected $_instance_width ;
+ protected $_instance_width;
public function __construct() {
- $widget_ops = array(
- 'classname' => 'widget-gallery',
- 'description' => __( 'Display a photo gallery or slideshow', 'jetpack' ),
+ $widget_ops = array(
+ 'classname' => 'widget-gallery',
+ 'description' => __( 'Display a photo gallery or slideshow', 'jetpack' ),
'customize_selective_refresh' => true,
);
@@ -70,10 +70,11 @@ class Jetpack_Gallery_Widget extends WP_Widget {
// with other tiled galleries, regardless of whether or not the widget was set to Carousel mode. The onClick selector
// is simply too broad, since it was not written with widgets in mind. This special class prevents that behavior, via
// an override handler in gallery.js
- if( 'carousel' != $instance['link'] && 'slideshow' != $instance['type'] )
+ if ( 'carousel' != $instance['link'] && 'slideshow' != $instance['type'] ) {
$classes[] = 'no-carousel';
- else
+ } else {
$classes[] = 'carousel';
+ }
$classes = implode( ' ', $classes );
@@ -95,8 +96,9 @@ class Jetpack_Gallery_Widget extends WP_Widget {
/** This filter is documented in core/src/wp-includes/default-widgets.php */
$title = apply_filters( 'widget_title', $instance['title'] );
- if ( $title )
+ if ( $title ) {
echo $before_title . esc_html( $title ) . $after_title . "\n";
+ }
echo '<div class="' . esc_attr( $classes ) . '">' . "\n";
@@ -119,8 +121,9 @@ class Jetpack_Gallery_Widget extends WP_Widget {
// can appropriately size the tiles.
add_filter( 'tiled_gallery_content_width', array( $this, 'tiled_gallery_content_width' ) );
- if ( method_exists( $this, $method ) )
+ if ( method_exists( $this, $method ) ) {
echo $this->$method( $args, $instance );
+ }
// Remove the stored $_instance_width, as it is no longer needed
$this->_instance_width = null;
@@ -142,21 +145,23 @@ class Jetpack_Gallery_Widget extends WP_Widget {
* @param array $instance The Widget instance for which you'd like attachments
* @return array Array of attachment objects for the Widget in $instance
*/
- public function get_attachments( $instance ){
+ public function get_attachments( $instance ) {
$ids = explode( ',', $instance['ids'] );
if ( isset( $instance['random'] ) && 'on' == $instance['random'] ) {
shuffle( $ids );
}
- $attachments_query = new WP_Query( array(
- 'post__in' => $ids,
- 'post_status' => 'inherit',
- 'post_type' => 'attachment',
- 'post_mime_type' => 'image',
- 'posts_per_page' => -1,
- 'orderby' => 'post__in',
- ) );
+ $attachments_query = new WP_Query(
+ array(
+ 'post__in' => $ids,
+ 'post_status' => 'inherit',
+ 'post_type' => 'attachment',
+ 'post_mime_type' => 'image',
+ 'posts_per_page' => -1,
+ 'orderby' => 'post__in',
+ )
+ );
$attachments = $attachments_query->get_posts();
@@ -174,7 +179,7 @@ class Jetpack_Gallery_Widget extends WP_Widget {
*/
public function rectangular_widget( $args, $instance ) {
if ( ! class_exists( 'Jetpack_Tiled_Gallery' )
- && ! class_exists( 'Jetpack_Tiled_Gallery_Layout_Rectangular') ) {
+ && ! class_exists( 'Jetpack_Tiled_Gallery_Layout_Rectangular' ) ) {
return;
}
@@ -193,7 +198,7 @@ class Jetpack_Gallery_Widget extends WP_Widget {
*/
public function square_widget( $args, $instance ) {
if ( ! class_exists( 'Jetpack_Tiled_Gallery' )
- && ! class_exists( 'Jetpack_Tiled_Gallery_Layout_Square') ) {
+ && ! class_exists( 'Jetpack_Tiled_Gallery_Layout_Square' ) ) {
return;
}
@@ -212,7 +217,7 @@ class Jetpack_Gallery_Widget extends WP_Widget {
*/
public function circle_widget( $args, $instance ) {
if ( ! class_exists( 'Jetpack_Tiled_Gallery' )
- && ! class_exists( 'Jetpack_Tiled_Gallery_Layout_Circle') ) {
+ && ! class_exists( 'Jetpack_Tiled_Gallery_Layout_Circle' ) ) {
return;
}
@@ -234,17 +239,19 @@ class Jetpack_Gallery_Widget extends WP_Widget {
require_once plugin_dir_path( realpath( dirname( __FILE__ ) . '/../shortcodes/slideshow.php' ) ) . 'slideshow.php';
- if ( ! class_exists( 'Jetpack_Slideshow_Shortcode' ) )
+ if ( ! class_exists( 'Jetpack_Slideshow_Shortcode' ) ) {
return;
+ }
- if ( count( $instance['attachments'] ) < 1 )
+ if ( count( $instance['attachments'] ) < 1 ) {
return;
+ }
$slideshow = new Jetpack_Slideshow_Shortcode();
$slideshow->enqueue_scripts();
- $gallery_instance = "widget-" . $args['widget_id'];
+ $gallery_instance = 'widget-' . $args['widget_id'];
$gallery = array();
@@ -252,33 +259,34 @@ class Jetpack_Gallery_Widget extends WP_Widget {
$attachment_image_src = wp_get_attachment_image_src( $attachment->ID, 'full' );
$attachment_image_src = jetpack_photon_url( $attachment_image_src[0], array( 'w' => $this->_instance_width ) ); // [url, width, height]
- $caption = wptexturize( strip_tags( $attachment->post_excerpt ) );
+ $caption = wptexturize( strip_tags( $attachment->post_excerpt ) );
- $gallery[] = (object) array(
+ $gallery[] = (object) array(
'src' => (string) esc_url_raw( $attachment_image_src ),
'id' => (string) $attachment->ID,
'caption' => (string) $caption,
);
}
- $max_width = intval( get_option( 'large_size_w' ) );
+ $max_width = intval( get_option( 'large_size_w' ) );
$max_height = 175;
- if ( intval( $content_width ) > 0 )
+ if ( intval( $content_width ) > 0 ) {
$max_width = min( intval( $content_width ), $max_width );
+ }
- $color = Jetpack_Options::get_option( 'slideshow_background_color', 'black' );
+ $color = Jetpack_Options::get_option( 'slideshow_background_color', 'black' );
$autostart = isset( $attr['autostart'] ) ? $attr['autostart'] : true;
$js_attr = array(
- 'gallery' => $gallery,
- 'selector' => $gallery_instance,
- 'width' => $max_width,
- 'height' => $max_height,
- 'trans' => 'fade',
- 'color' => $color,
+ 'gallery' => $gallery,
+ 'selector' => $gallery_instance,
+ 'width' => $max_width,
+ 'height' => $max_height,
+ 'trans' => 'fade',
+ 'color' => $color,
'autostart' => $autostart,
- );
+ );
$html = $slideshow->slideshow_js( $js_attr );
@@ -300,10 +308,10 @@ class Jetpack_Gallery_Widget extends WP_Widget {
}
public function form( $instance ) {
- $defaults = $this->defaults();
- $allowed_values = $this->allowed_values();
+ $defaults = $this->defaults();
+ $allowed_values = $this->allowed_values();
- $instance = wp_parse_args( (array) $instance, $defaults );
+ $instance = wp_parse_args( (array) $instance, $defaults );
include dirname( __FILE__ ) . '/gallery/templates/form.php';
}
@@ -325,7 +333,7 @@ class Jetpack_Gallery_Widget extends WP_Widget {
*/
public function sanitize( $instance ) {
$allowed_values = $this->allowed_values();
- $defaults = $this->defaults();
+ $defaults = $this->defaults();
foreach ( $instance as $key => $value ) {
$value = trim( $value );
@@ -356,18 +364,18 @@ class Jetpack_Gallery_Widget extends WP_Widget {
$allowed_columns = array_combine( range( 1, $max_columns ), range( 1, $max_columns ) );
return array(
- 'type' => array(
- 'rectangular' => __( 'Tiles', 'jetpack' ),
- 'square' => __( 'Square Tiles', 'jetpack' ),
- 'circle' => __( 'Circles', 'jetpack' ),
- 'slideshow' => __( 'Slideshow', 'jetpack' ),
+ 'type' => array(
+ 'rectangular' => __( 'Tiles', 'jetpack' ),
+ 'square' => __( 'Square Tiles', 'jetpack' ),
+ 'circle' => __( 'Circles', 'jetpack' ),
+ 'slideshow' => __( 'Slideshow', 'jetpack' ),
+ ),
+ 'columns' => $allowed_columns,
+ 'link' => array(
+ 'carousel' => __( 'Carousel', 'jetpack' ),
+ 'post' => __( 'Attachment Page', 'jetpack' ),
+ 'file' => __( 'Media File', 'jetpack' ),
),
- 'columns' => $allowed_columns,
- 'link' => array(
- 'carousel' => __( 'Carousel', 'jetpack' ),
- 'post' => __( 'Attachment Page', 'jetpack' ),
- 'file' => __( 'Media File', 'jetpack' ),
- )
);
}
@@ -381,11 +389,11 @@ class Jetpack_Gallery_Widget extends WP_Widget {
*/
public function defaults() {
return array(
- 'title' => '',
- 'type' => 'rectangular',
- 'ids' => '',
- 'columns' => 3,
- 'link' => 'carousel'
+ 'title' => '',
+ 'type' => 'rectangular',
+ 'ids' => '',
+ 'columns' => 3,
+ 'link' => 'carousel',
);
}
@@ -415,13 +423,13 @@ class Jetpack_Gallery_Widget extends WP_Widget {
),
array(
'media-models',
- 'media-views'
+ 'media-views',
),
'20150501'
);
$js_settings = array(
- 'thumbSize' => self::THUMB_SIZE
+ 'thumbSize' => self::THUMB_SIZE,
);
wp_localize_script( 'gallery-widget-admin', '_wpGalleryWidgetAdminSettings', $js_settings );
@@ -449,7 +457,8 @@ function jetpack_gallery_widget_init() {
&& Jetpack_Options::get_option( 'gallery_widget_migration' )
) {
return;
- }
- if ( ! method_exists( 'Jetpack', 'is_module_active' ) || Jetpack::is_module_active( 'tiled-gallery' ) )
+ }
+ if ( ! method_exists( 'Jetpack', 'is_module_active' ) || Jetpack::is_module_active( 'tiled-gallery' ) ) {
register_widget( 'Jetpack_Gallery_Widget' );
+ }
}
diff --git a/plugins/jetpack/modules/widgets/goodreads.php b/plugins/jetpack/modules/widgets/goodreads.php
index e8b04136..4160c868 100644
--- a/plugins/jetpack/modules/widgets/goodreads.php
+++ b/plugins/jetpack/modules/widgets/goodreads.php
@@ -24,8 +24,8 @@ class WPCOM_Widget_Goodreads extends WP_Widget {
/** This filter is documented in modules/widgets/facebook-likebox.php */
apply_filters( 'jetpack_widget_name', __( 'Goodreads', 'jetpack' ) ),
array(
- 'classname' => 'widget_goodreads',
- 'description' => __( 'Display your books from Goodreads', 'jetpack' ),
+ 'classname' => 'widget_goodreads',
+ 'description' => __( 'Display your books from Goodreads', 'jetpack' ),
'customize_selective_refresh' => true,
)
);
@@ -33,7 +33,7 @@ class WPCOM_Widget_Goodreads extends WP_Widget {
$this->shelves = array(
'read' => _x( 'Read', 'past participle: books I have read', 'jetpack' ),
'currently-reading' => __( 'Currently Reading', 'jetpack' ),
- 'to-read' => _x( 'To Read', 'my list of books to read', 'jetpack' )
+ 'to-read' => _x( 'To Read', 'my list of books to read', 'jetpack' ),
);
if ( is_active_widget( '', '', 'wpcom-goodreads' ) || is_customize_preview() ) {
@@ -54,7 +54,7 @@ class WPCOM_Widget_Goodreads extends WP_Widget {
$title = apply_filters( 'widget_title', isset( $instance['title'] ) ? $instance['title'] : '' );
if ( empty( $instance['user_id'] ) || 'invalid' === $instance['user_id'] ) {
- if ( current_user_can('edit_theme_options') ) {
+ if ( current_user_can( 'edit_theme_options' ) ) {
echo $args['before_widget'];
echo '<p>' . sprintf(
__( 'You need to enter your numeric user ID for the <a href="%1$s">Goodreads Widget</a> to work correctly. <a href="%2$s" target="_blank">Full instructions</a>.', 'jetpack' ),
@@ -66,30 +66,39 @@ class WPCOM_Widget_Goodreads extends WP_Widget {
return;
}
- if ( !array_key_exists( $instance['shelf'], $this->shelves ) )
+ if ( ! array_key_exists( $instance['shelf'], $this->shelves ) ) {
return;
+ }
$instance['user_id'] = absint( $instance['user_id'] );
// Set widget ID based on shelf.
$this->goodreads_widget_id = $instance['user_id'] . '_' . $instance['shelf'];
- if ( empty( $title ) ) $title = esc_html__( 'Goodreads', 'jetpack' );
+ if ( empty( $title ) ) {
+ $title = esc_html__( 'Goodreads', 'jetpack' );
+ }
echo $args['before_widget'];
echo $args['before_title'] . $title . $args['after_title'];
- $goodreads_url = 'https://www.goodreads.com/review/custom_widget/' . urlencode( $instance['user_id'] ) . '.' . urlencode( $instance['title'] ) . ':%20' . urlencode( $instance['shelf'] ) . '?cover_position=&cover_size=small&num_books=5&order=d&shelf=' . urlencode( $instance['shelf'] ) . '&sort=date_added&widget_bg_transparent=&widget_id=' . esc_attr( $this->goodreads_widget_id ) ;
+ $goodreads_url = 'https://www.goodreads.com/review/custom_widget/' . urlencode( $instance['user_id'] ) . '.' . urlencode( $instance['title'] ) . ':%20' . urlencode( $instance['shelf'] ) . '?cover_position=&cover_size=small&num_books=5&order=d&shelf=' . urlencode( $instance['shelf'] ) . '&sort=date_added&widget_bg_transparent=&widget_id=' . esc_attr( $this->goodreads_widget_id );
- echo '<div class="gr_custom_widget" id="gr_custom_widget_' . esc_attr( $this->goodreads_widget_id ). '"></div>' . "\n";
+ echo '<div class="gr_custom_widget" id="gr_custom_widget_' . esc_attr( $this->goodreads_widget_id ) . '"></div>' . "\n";
echo '<script src="' . esc_url( $goodreads_url ) . '"></script>' . "\n";
echo $args['after_widget'];
}
function goodreads_user_id_exists( $user_id ) {
- $url = "https://www.goodreads.com/user/show/$user_id/";
- $response = wp_remote_head( $url, array( 'httpversion' => '1.1', 'timeout' => 3, 'redirection' => 2 ) );
+ $url = "https://www.goodreads.com/user/show/$user_id/";
+ $response = wp_remote_head(
+ $url, array(
+ 'httpversion' => '1.1',
+ 'timeout' => 3,
+ 'redirection' => 2,
+ )
+ );
if ( 200 === wp_remote_retrieve_response_code( $response ) ) {
return true;
} else {
@@ -107,16 +116,23 @@ class WPCOM_Widget_Goodreads extends WP_Widget {
}
}
$instance['title'] = wp_kses( stripslashes( $new_instance['title'] ), array() );
- $shelf = wp_kses( stripslashes( $new_instance['shelf'] ), array() );
- if ( array_key_exists( $shelf, $this->shelves ) )
+ $shelf = wp_kses( stripslashes( $new_instance['shelf'] ), array() );
+ if ( array_key_exists( $shelf, $this->shelves ) ) {
$instance['shelf'] = $shelf;
+ }
return $instance;
}
function form( $instance ) {
//Defaults
- $instance = wp_parse_args( (array) $instance, array( 'user_id' => '', 'title' => 'Goodreads', 'shelf' => 'read' ) );
+ $instance = wp_parse_args(
+ (array) $instance, array(
+ 'user_id' => '',
+ 'title' => 'Goodreads',
+ 'shelf' => 'read',
+ )
+ );
echo '<p><label for="' . esc_attr( $this->get_field_id( 'title' ) ) . '">' . esc_html__( 'Title:', 'jetpack' ) . '
<input class="widefat" id="' . esc_attr( $this->get_field_id( 'title' ) ) . '" name="' . esc_attr( $this->get_field_name( 'title' ) ) . '" type="text" value="' . esc_attr( $instance['title'] ) . '" />
@@ -131,8 +147,8 @@ class WPCOM_Widget_Goodreads extends WP_Widget {
</label></p>
<p><label for="' . esc_attr( $this->get_field_id( 'shelf' ) ) . '">' . esc_html__( 'Shelf:', 'jetpack' ) . '
<select class="widefat" id="' . esc_attr( $this->get_field_id( 'shelf' ) ) . '" name="' . esc_attr( $this->get_field_name( 'shelf' ) ) . '" >';
- foreach( $this->shelves as $_shelf_value => $_shelf_display ) {
- echo "\t<option value='" . esc_attr( $_shelf_value ) . "'" . selected( $_shelf_value, $instance['shelf'] ) . ">" . $_shelf_display . "</option>\n";
+ foreach ( $this->shelves as $_shelf_value => $_shelf_display ) {
+ echo "\t<option value='" . esc_attr( $_shelf_value ) . "'" . selected( $_shelf_value, $instance['shelf'] ) . '>' . $_shelf_display . "</option>\n";
}
echo '</select>
</label></p>
diff --git a/plugins/jetpack/modules/widgets/google-translate.php b/plugins/jetpack/modules/widgets/google-translate.php
index dee475b8..241fb8ed 100644
--- a/plugins/jetpack/modules/widgets/google-translate.php
+++ b/plugins/jetpack/modules/widgets/google-translate.php
@@ -31,8 +31,8 @@ class Jetpack_Google_Translate_Widget extends WP_Widget {
/** This filter is documented in modules/widgets/facebook-likebox.php */
apply_filters( 'jetpack_widget_name', __( 'Google Translate', 'jetpack' ) ),
array(
- 'description' => __( 'Provide your readers with the option to translate your site into their preferred language.', 'jetpack' ),
- 'customize_selective_refresh' => true
+ 'description' => __( 'Provide your readers with the option to translate your site into their preferred language.', 'jetpack' ),
+ 'customize_selective_refresh' => true,
)
);
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
@@ -89,17 +89,19 @@ class Jetpack_Google_Translate_Widget extends WP_Widget {
public function widget( $args, $instance ) {
// We never should show more than 1 instance of this.
if ( null === self::$instance ) {
- $instance = wp_parse_args( $instance, array(
- 'title' => $this->default_title,
- ) );
+ $instance = wp_parse_args(
+ $instance, array(
+ 'title' => $this->default_title,
+ )
+ );
/**
* Filter the layout of the Google Translate Widget.
*
* 3 different integers are accepted.
- * 0 for the vertical layout.
- * 1 for the horizontal layout.
- * 2 for the dropdown only.
+ * 0 for the vertical layout.
+ * 1 for the horizontal layout.
+ * 2 for the dropdown only.
*
* @see https://translate.google.com/manager/website/
*
@@ -182,7 +184,7 @@ class Jetpack_Google_Translate_Widget extends WP_Widget {
* @return array $instance Updated safe values to be saved.
*/
public function update( $new_instance, $old_instance ) {
- $instance = array();
+ $instance = array();
$instance['title'] = wp_kses( $new_instance['title'], array() );
if ( $instance['title'] === $this->default_title ) {
$instance['title'] = false; // Store as false in case of language change
diff --git a/plugins/jetpack/modules/widgets/googleplus-badge.php b/plugins/jetpack/modules/widgets/googleplus-badge.php
index 7f1f7693..8e42aac9 100644
--- a/plugins/jetpack/modules/widgets/googleplus-badge.php
+++ b/plugins/jetpack/modules/widgets/googleplus-badge.php
@@ -21,15 +21,15 @@ class WPCOM_Widget_GooglePlus_Badge extends WP_Widget {
private $min_width_portrait = 180;
private $min_width_landscape = 273;
private $min_width;
- private $default_theme = 'light';
- private $allowed_themes = array( 'light', 'dark' );
- private $default_layout = 'portrait';
- private $allowed_layouts = array( 'landscape', 'portrait' );
- private $default_type = 'person';
- private $allowed_types = array();
+ private $default_theme = 'light';
+ private $allowed_themes = array( 'light', 'dark' );
+ private $default_layout = 'portrait';
+ private $allowed_layouts = array( 'landscape', 'portrait' );
+ private $default_type = 'person';
+ private $allowed_types = array();
function __construct() {
- $this->min_width = min( $this->min_width_portrait, $this->min_width_landscape );
+ $this->min_width = min( $this->min_width_portrait, $this->min_width_landscape );
$this->allowed_types = array(
'person' => __( 'Person Widget', 'jetpack' ),
'page' => __( 'Page Widget', 'jetpack' ),
@@ -41,8 +41,8 @@ class WPCOM_Widget_GooglePlus_Badge extends WP_Widget {
/** This filter is documented in modules/widgets/facebook-likebox.php */
apply_filters( 'jetpack_widget_name', __( 'Google+ Badge', 'jetpack' ) ),
array(
- 'classname' => 'widget_googleplus_badge',
- 'description' => __( 'Display a Google+ Badge to connect visitors to your Google+', 'jetpack' ),
+ 'classname' => 'widget_googleplus_badge',
+ 'description' => __( 'Display a Google+ Badge to connect visitors to your Google+', 'jetpack' ),
'customize_selective_refresh' => true,
)
);
@@ -50,7 +50,7 @@ class WPCOM_Widget_GooglePlus_Badge extends WP_Widget {
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_scripts' ) );
if ( is_active_widget( '', '', 'googleplus-badge' ) || is_customize_preview() ) {
- add_action( 'wp_print_styles', array( $this, 'enqueue_script' ) );
+ add_action( 'wp_print_styles', array( $this, 'enqueue_script' ) );
add_filter( 'script_loader_tag', array( $this, 'replace_script_tag' ), 10, 2 );
}
}
@@ -108,7 +108,7 @@ class WPCOM_Widget_GooglePlus_Badge extends WP_Widget {
echo $args['before_title'] . esc_html( $title ) . $args['after_title'];
}
- switch( $instance['type'] ) {
+ switch ( $instance['type'] ) {
case 'person':
case 'page':
printf(
@@ -149,29 +149,37 @@ class WPCOM_Widget_GooglePlus_Badge extends WP_Widget {
$instance['href'] = trim( strip_tags( stripslashes( $new_instance['href'] ) ) );
if ( $this->is_valid_googleplus_url( $instance['href'] ) ) {
- $temp = explode( '?', $instance['href'] );
+ $temp = explode( '?', $instance['href'] );
$instance['href'] = str_replace( array( 'http://plus.google.com', 'https://plus.google.com' ), 'https://plus.google.com', $temp[0] );
} else {
$instance['href'] = '';
}
- $instance['theme'] = $this->filter_text( $new_instance['theme'], $this->default_theme, $this->allowed_themes );
+ $instance['theme'] = $this->filter_text( $new_instance['theme'], $this->default_theme, $this->allowed_themes );
$instance['layout'] = $this->filter_text( $new_instance['layout'], $this->default_layout, $this->allowed_layouts );
- switch( $instance['layout'] ) {
+ switch ( $instance['layout'] ) {
case 'portrait':
- $instance['width'] = filter_var( $new_instance['width'], FILTER_VALIDATE_INT, array( 'options' => array(
- 'min_range' => $this->min_width_portrait,
- 'max_range' => $this->max_width,
- 'default' => $this->default_width,
- ) ) );
+ $instance['width'] = filter_var(
+ $new_instance['width'], FILTER_VALIDATE_INT, array(
+ 'options' => array(
+ 'min_range' => $this->min_width_portrait,
+ 'max_range' => $this->max_width,
+ 'default' => $this->default_width,
+ ),
+ )
+ );
break;
case 'landscape':
- $instance['width'] = filter_var( $new_instance['width'], FILTER_VALIDATE_INT, array( 'options' => array(
- 'min_range' => $this->min_width_landscape,
- 'max_range' => $this->max_width,
- 'default' => $this->default_width,
- ) ) );
+ $instance['width'] = filter_var(
+ $new_instance['width'], FILTER_VALIDATE_INT, array(
+ 'options' => array(
+ 'min_range' => $this->min_width_landscape,
+ 'max_range' => $this->max_width,
+ 'default' => $this->default_width,
+ ),
+ )
+ );
break;
}
@@ -181,7 +189,7 @@ class WPCOM_Widget_GooglePlus_Badge extends WP_Widget {
$instance['type'] = $this->default_type;
}
- switch( $instance['type'] ) {
+ switch ( $instance['type'] ) {
case 'person':
case 'page':
$instance['show_coverphoto'] = isset( $new_instance['show_coverphoto'] );
@@ -226,7 +234,7 @@ class WPCOM_Widget_GooglePlus_Badge extends WP_Widget {
<?php _e( 'Type of Widget', 'jetpack' ); ?>
<select name="<?php echo $this->get_field_name( 'type' ); ?>" id="<?php echo $this->get_field_id( 'type' ); ?>" class="widefat googleplus-badge-choose-type">
<?php
- foreach( $this->allowed_types as $type_value => $type_display ) {
+ foreach ( $this->allowed_types as $type_value => $type_display ) {
printf(
'<option value="%s"%s>%s</option>',
esc_attr( $type_value ),
@@ -305,14 +313,15 @@ class WPCOM_Widget_GooglePlus_Badge extends WP_Widget {
}
function is_valid_googleplus_url( $url ) {
- return ( FALSE !== strpos( $url, 'plus.google.com' ) ) ? TRUE : FALSE;
+ return ( false !== strpos( $url, 'plus.google.com' ) ) ? true : false;
}
function filter_text( $value, $default = '', $allowed = array() ) {
$allowed = (array) $allowed;
- if ( empty( $value ) || ( ! empty( $allowed ) && ! in_array( $value, $allowed ) ) )
+ if ( empty( $value ) || ( ! empty( $allowed ) && ! in_array( $value, $allowed ) ) ) {
$value = $default;
+ }
return $value;
}
diff --git a/plugins/jetpack/modules/widgets/gravatar-profile.php b/plugins/jetpack/modules/widgets/gravatar-profile.php
index 7c64cd22..f5171665 100644
--- a/plugins/jetpack/modules/widgets/gravatar-profile.php
+++ b/plugins/jetpack/modules/widgets/gravatar-profile.php
@@ -21,8 +21,8 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
/** This filter is documented in modules/widgets/facebook-likebox.php */
apply_filters( 'jetpack_widget_name', __( 'Gravatar Profile', 'jetpack' ) ),
array(
- 'classname' => 'widget-grofile grofile',
- 'description' => __( 'Display a mini version of your Gravatar Profile', 'jetpack' ),
+ 'classname' => 'widget-grofile grofile',
+ 'description' => __( 'Display a mini version of your Gravatar Profile', 'jetpack' ),
'customize_selective_refresh' => true,
)
);
@@ -51,19 +51,22 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
*/
do_action( 'jetpack_stats_extra', 'widget_view', 'grofile' );
- $instance = wp_parse_args( $instance, array(
- 'title' => '',
- 'email' => ''
- ) );
+ $instance = wp_parse_args(
+ $instance, array(
+ 'title' => '',
+ 'email' => '',
+ )
+ );
/** This filter is documented in core/src/wp-includes/default-widgets.php */
$title = apply_filters( 'widget_title', $instance['title'] );
- if ( !$instance['email'] ) {
+ if ( ! $instance['email'] ) {
if ( current_user_can( 'edit_theme_options' ) ) {
echo $args['before_widget'];
- if ( ! empty( $title ) )
+ if ( ! empty( $title ) ) {
echo $args['before_title'] . $title . $args['after_title'];
+ }
echo '<p>' . sprintf( __( 'You need to select what to show in this <a href="%s">Gravatar Profile widget</a>.', 'jetpack' ), admin_url( 'widgets.php' ) ) . '</p>';
echo $args['after_widget'];
}
@@ -71,20 +74,23 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
}
echo $args['before_widget'];
- if ( ! empty( $title ) )
+ if ( ! empty( $title ) ) {
echo $args['before_title'] . $title . $args['after_title'];
+ }
$profile = $this->get_profile( $instance['email'] );
- if( ! empty( $profile ) ) {
- $profile = wp_parse_args( $profile, array(
- 'thumbnailUrl' => '',
- 'profileUrl' => '',
- 'displayName' => '',
- 'aboutMe' => '',
- 'urls' => array(),
- 'accounts' => array(),
- ) );
+ if ( ! empty( $profile ) ) {
+ $profile = wp_parse_args(
+ $profile, array(
+ 'thumbnailUrl' => '',
+ 'profileUrl' => '',
+ 'displayName' => '',
+ 'aboutMe' => '',
+ 'urls' => array(),
+ 'accounts' => array(),
+ )
+ );
$gravatar_url = add_query_arg( 's', 320, $profile['thumbnailUrl'] ); // the default grav returned by grofiles is super small
// Enqueue front end assets.
@@ -99,16 +105,19 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
<?php
- if( $instance['show_personal_links'] )
+ if ( $instance['show_personal_links'] ) {
$this->display_personal_links( (array) $profile['urls'] );
+ }
- if( $instance['show_account_links'] )
+ if ( $instance['show_account_links'] ) {
$this->display_accounts( (array) $profile['accounts'] );
+ }
?>
<p><a href="<?php echo esc_url( $profile['profileUrl'] ); ?>" class="grofile-full-link">
- <?php echo esc_html(
+ <?php
+ echo esc_html(
/**
* Filter the Gravatar Profile widget's profile link title.
*
@@ -122,7 +131,8 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
'jetpack_gravatar_full_profile_title',
__( 'View Full Profile &rarr;', 'jetpack' )
)
- ); ?>
+ );
+ ?>
</a></p>
<?php
@@ -136,11 +146,14 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
}
function display_personal_links( $personal_links = array() ) {
- if ( empty( $personal_links ) )
+ if ( empty( $personal_links ) ) {
return;
+ }
?>
- <h4><?php echo esc_html(
+ <h4>
+ <?php
+ echo esc_html(
apply_filters(
/**
* Filter the Gravatar Profile widget's "Personal Links" section title.
@@ -153,11 +166,13 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
*/
'jetpack_gravatar_personal_links_title',
__( 'Personal Links', 'jetpack' )
- )
- ); ?></h4>
+ )
+ );
+ ?>
+ </h4>
<ul class="grofile-urls grofile-links">
- <?php foreach( $personal_links as $personal_link ) : ?>
+ <?php foreach ( $personal_links as $personal_link ) : ?>
<li>
<a href="<?php echo esc_url( $personal_link['value'] ); ?>">
<?php
@@ -173,12 +188,15 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
}
function display_accounts( $accounts = array() ) {
- if ( empty( $accounts ) )
+ if ( empty( $accounts ) ) {
return;
+ }
?>
- <h4><?php echo esc_html(
- /**
+ <h4>
+ <?php
+ echo esc_html(
+ /**
* Filter the Gravatar Profile widget's "Verified Services" section title.
*
* @module widgets
@@ -191,12 +209,16 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
'jetpack_gravatar_verified_services_title',
__( 'Verified Services', 'jetpack' )
)
- ); ?></h4>
+ );
+ ?>
+ </h4>
<ul class="grofile-urls grofile-accounts">
- <?php foreach( $accounts as $account ) :
- if( $account['verified'] != 'true' )
+ <?php
+ foreach ( $accounts as $account ) :
+ if ( $account['verified'] != 'true' ) {
continue;
+ }
$sanitized_service_name = $this->get_sanitized_service_name( $account['shortname'] );
?>
@@ -252,7 +274,7 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
?>
<p>
<label for="<?php echo $this->get_field_id( 'title' ); ?>">
- <?php esc_html_e( 'Title', 'jetpack' ); ?> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
+ <?php esc_html_e( 'Title', 'jetpack' ); ?> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
</label>
</p>
@@ -261,19 +283,23 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
<?php esc_html_e( 'Select a user or pick "custom" and enter a custom email address.', 'jetpack' ); ?>
<br />
- <?php wp_dropdown_users( array(
- 'show_option_none' => __( 'Custom', 'jetpack' ),
- 'selected' => $email_user,
- 'name' => $this->get_field_name( 'email_user' ),
- 'id' => $this->get_field_id( 'email_user' ),
- 'class' => 'gravatar-profile-user-select',
- ) );?>
+ <?php
+ wp_dropdown_users(
+ array(
+ 'show_option_none' => __( 'Custom', 'jetpack' ),
+ 'selected' => $email_user,
+ 'name' => $this->get_field_name( 'email_user' ),
+ 'id' => $this->get_field_id( 'email_user' ),
+ 'class' => 'gravatar-profile-user-select',
+ )
+ );
+ ?>
</label>
</p>
<p class="gprofile-email-container <?php echo empty( $email_user ) || $email_user == -1 ? '' : 'hidden'; ?>">
<label for="<?php echo $this->get_field_id( 'email' ); ?>"><?php esc_html_e( 'Custom Email Address', 'jetpack' ); ?>
- <input class="widefat" id="<?php echo $this->get_field_id('email'); ?>" name="<?php echo $this->get_field_name( 'email' ); ?>" type="text" value="<?php echo esc_attr( $email ); ?>" />
+ <input class="widefat" id="<?php echo $this->get_field_id( 'email' ); ?>" name="<?php echo $this->get_field_name( 'email' ); ?>" type="text" value="<?php echo esc_attr( $email ); ?>" />
</label>
</p>
@@ -295,7 +321,7 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
</label>
</p>
- <p><a href="<?php echo esc_url( $profile_url ); ?>" target="_blank" title="<?php esc_attr_e( 'Opens in new window', 'jetpack' ); ?>"><?php esc_html_e( 'Edit Your Profile', 'jetpack' )?></a> | <a href="https://gravatar.com" target="_blank" title="<?php esc_attr_e( 'Opens in new window', 'jetpack' ); ?>"><?php esc_html_e( "What's a Gravatar?", 'jetpack' ); ?></a></p>
+ <p><a href="<?php echo esc_url( $profile_url ); ?>" target="_blank" title="<?php esc_attr_e( 'Opens in new window', 'jetpack' ); ?>"><?php esc_html_e( 'Edit Your Profile', 'jetpack' ); ?></a> | <a href="https://gravatar.com" target="_blank" title="<?php esc_attr_e( 'Opens in new window', 'jetpack' ); ?>"><?php esc_html_e( "What's a Gravatar?", 'jetpack' ); ?></a></p>
<?php
}
@@ -328,12 +354,12 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
$instance['show_account_links'] = isset( $new_instance['show_account_links'] ) ? (bool) $new_instance['show_account_links'] : false;
if ( $instance['email_user'] > 0 ) {
- $user = get_userdata( $instance['email_user'] );
+ $user = get_userdata( $instance['email_user'] );
$instance['email'] = $user->user_email;
}
$hashed_email = md5( strtolower( trim( $instance['email'] ) ) );
- $cache_key = 'grofile-' . $hashed_email;
+ $cache_key = 'grofile-' . $hashed_email;
delete_transient( $cache_key );
return $instance;
@@ -341,16 +367,16 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
private function get_profile( $email ) {
$hashed_email = md5( strtolower( trim( $email ) ) );
- $cache_key = 'grofile-' . $hashed_email;
+ $cache_key = 'grofile-' . $hashed_email;
- if( ! $profile = get_transient( $cache_key ) ) {
+ if ( ! $profile = get_transient( $cache_key ) ) {
$profile_url = sprintf(
'https://secure.gravatar.com/%s.json',
$hashed_email
);
- $expire = 300;
- $response = wp_remote_get(
+ $expire = 300;
+ $response = wp_remote_get(
esc_url_raw( $profile_url ),
array( 'User-Agent' => 'WordPress.com Gravatar Profile Widget' )
);
@@ -360,15 +386,14 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
$profile = json_decode( $profile, true );
if ( is_array( $profile ) && ! empty( $profile['entry'] ) && is_array( $profile['entry'] ) ) {
- $expire = 900; // cache for 15 minutes
+ $expire = 900; // cache for 15 minutes
$profile = $profile['entry'][0];
} else {
// Something strange happened. Cache for 5 minutes.
$profile = array();
}
-
} else {
- $expire = 900; // cache for 15 minutes
+ $expire = 900; // cache for 15 minutes
$profile = array();
}
@@ -379,7 +404,7 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
private function get_sanitized_service_name( $shortname ) {
// Some services have stylized or mixed cap names *cough* WP *cough*
- switch( $shortname ) {
+ switch ( $shortname ) {
case 'friendfeed':
return 'FriendFeed';
case 'linkedin':
@@ -388,6 +413,7 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
return 'Yahoo!';
case 'youtube':
return 'YouTube';
+ // phpcs:ignore WordPress.WP.CapitalPDangit
case 'wordpress':
return 'WordPress';
case 'tripit':
diff --git a/plugins/jetpack/modules/widgets/image-widget.php b/plugins/jetpack/modules/widgets/image-widget.php
index aabbb43f..37a353c1 100644
--- a/plugins/jetpack/modules/widgets/image-widget.php
+++ b/plugins/jetpack/modules/widgets/image-widget.php
@@ -27,8 +27,8 @@ class Jetpack_Image_Widget extends WP_Widget {
/** This filter is documented in modules/widgets/facebook-likebox.php */
apply_filters( 'jetpack_widget_name', esc_html__( 'Image', 'jetpack' ) ),
array(
- 'classname' => 'widget_image',
- 'description' => __( 'Display an image in your sidebar', 'jetpack' ),
+ 'classname' => 'widget_image',
+ 'description' => __( 'Display an image in your sidebar', 'jetpack' ),
'customize_selective_refresh' => true,
)
);
@@ -58,10 +58,12 @@ class Jetpack_Image_Widget extends WP_Widget {
public function widget( $args, $instance ) {
echo $args['before_widget'];
- $instance = wp_parse_args( $instance, array(
- 'title' => '',
- 'img_url' => ''
- ) );
+ $instance = wp_parse_args(
+ $instance, array(
+ 'title' => '',
+ 'img_url' => '',
+ )
+ );
/** This filter is documented in core/src/wp-includes/default-widgets.php */
$title = apply_filters( 'widget_title', $instance['title'] );
@@ -75,19 +77,19 @@ class Jetpack_Image_Widget extends WP_Widget {
$output = '<img src="' . esc_url( $instance['img_url'] ) . '" ';
if ( '' != $instance['alt_text'] ) {
- $output .= 'alt="' . esc_attr( $instance['alt_text'] ) .'" ';
+ $output .= 'alt="' . esc_attr( $instance['alt_text'] ) . '" ';
}
if ( '' != $instance['img_title'] ) {
- $output .= 'title="' . esc_attr( $instance['img_title'] ) .'" ';
+ $output .= 'title="' . esc_attr( $instance['img_title'] ) . '" ';
}
if ( '' == $instance['caption'] ) {
$output .= 'class="align' . esc_attr( $instance['align'] ) . '" ';
}
if ( '' != $instance['img_width'] ) {
- $output .= 'width="' . esc_attr( $instance['img_width'] ) .'" ';
+ $output .= 'width="' . esc_attr( $instance['img_width'] ) . '" ';
}
if ( '' != $instance['img_height'] ) {
- $output .= 'height="' . esc_attr( $instance['img_height'] ) .'" ';
+ $output .= 'height="' . esc_attr( $instance['img_height'] ) . '" ';
}
$output .= '/>';
@@ -104,8 +106,8 @@ class Jetpack_Image_Widget extends WP_Widget {
if ( '' != $instance['caption'] ) {
/** This filter is documented in core/src/wp-includes/default-widgets.php */
$caption = apply_filters( 'widget_text', $instance['caption'] );
- $img_width = ( ! empty( $instance['img_width'] ) ? 'style="width: ' . esc_attr( $instance['img_width'] ) .'px"' : '' );
- $output = '<figure ' . $img_width .' class="wp-caption align' . esc_attr( $instance['align'] ) . '">
+ $img_width = ( ! empty( $instance['img_width'] ) ? 'style="width: ' . esc_attr( $instance['img_width'] ) . 'px"' : '' );
+ $output = '<figure ' . $img_width . ' class="wp-caption align' . esc_attr( $instance['align'] ) . '">
' . $output . '
<figcaption class="wp-caption-text">' . $caption . '</figcaption>
</figure>'; // wp_kses_post caption on update
@@ -135,16 +137,16 @@ class Jetpack_Image_Widget extends WP_Widget {
*/
public function update( $new_instance, $old_instance ) {
$allowed_caption_html = array(
- 'a' => array(
- 'href' => array(),
- 'title' => array(),
- ),
- 'b' => array(),
- 'em' => array(),
- 'i' => array(),
- 'p' => array(),
- 'strong' => array()
- );
+ 'a' => array(
+ 'href' => array(),
+ 'title' => array(),
+ ),
+ 'b' => array(),
+ 'em' => array(),
+ 'i' => array(),
+ 'p' => array(),
+ 'strong' => array(),
+ );
$instance = $old_instance;
@@ -152,7 +154,7 @@ class Jetpack_Image_Widget extends WP_Widget {
$instance['img_url'] = esc_url( trim( $new_instance['img_url'] ) );
$instance['alt_text'] = strip_tags( $new_instance['alt_text'] );
$instance['img_title'] = strip_tags( $new_instance['img_title'] );
- $instance['caption'] = wp_kses( stripslashes($new_instance['caption'] ), $allowed_caption_html );
+ $instance['caption'] = wp_kses( stripslashes( $new_instance['caption'] ), $allowed_caption_html );
$instance['align'] = $new_instance['align'];
$instance['link'] = esc_url( trim( $new_instance['link'] ) );
$instance['link_target_blank'] = isset( $new_instance['link_target_blank'] ) ? (bool) $new_instance['link_target_blank'] : false;
@@ -166,10 +168,10 @@ class Jetpack_Image_Widget extends WP_Widget {
if ( ! is_wp_error( $tmp_file ) ) {
$size = getimagesize( $tmp_file );
- $width = $size[0];
+ $width = $size[0];
$instance['img_width'] = absint( $width );
- $height = $size[1];
+ $height = $size[1];
$instance['img_height'] = absint( $height );
unlink( $tmp_file );
@@ -194,7 +196,20 @@ class Jetpack_Image_Widget extends WP_Widget {
*/
public function form( $instance ) {
// Defaults
- $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'img_url' => '', 'alt_text' => '', 'img_title' => '', 'caption' => '', 'align' => 'none', 'img_width' => '', 'img_height' => '', 'link' => '', 'link_target_blank' => false ) );
+ $instance = wp_parse_args(
+ (array) $instance, array(
+ 'title' => '',
+ 'img_url' => '',
+ 'alt_text' => '',
+ 'img_title' => '',
+ 'caption' => '',
+ 'align' => 'none',
+ 'img_width' => '',
+ 'img_height' => '',
+ 'link' => '',
+ 'link_target_blank' => false,
+ )
+ );
$title = esc_attr( $instance['title'] );
$img_url = esc_url( $instance['img_url'], null, 'display' );
@@ -217,7 +232,7 @@ class Jetpack_Image_Widget extends WP_Widget {
<p><label for="' . $this->get_field_id( 'alt_text' ) . '">' . esc_html__( 'Alternate text:', 'jetpack' ) . ' <a href="http://support.wordpress.com/widgets/image-widget/#image-widget-alt-text" target="_blank">( ? )</a>
<input class="widefat" id="' . $this->get_field_id( 'alt_text' ) . '" name="' . $this->get_field_name( 'alt_text' ) . '" type="text" value="' . $alt_text . '" />
</label></p>
- <p><label for="' . $this->get_field_id( 'img_title' ) . '">' . esc_html__( 'Image title:', 'jetpack' ) . ' <a href="http://support.wordpress.com/widgets/image-widget/#image-widget-title" target="_blank">( ? )</a>
+ <p><label for="' . $this->get_field_id( 'img_title' ) . '">' . esc_html__( 'Image title:', 'jetpack' ) . ' <a href="http://support.wordpress.com/widgets/image-widget/#image-widget-title" target="_blank">( ? )</a>
<input class="widefat" id="' . $this->get_field_id( 'img_title' ) . '" name="' . $this->get_field_name( 'img_title' ) . '" type="text" value="' . $img_title . '" />
</label></p>
<p><label for="' . $this->get_field_id( 'caption' ) . '">' . esc_html__( 'Caption:', 'jetpack' ) . ' <a href="http://support.wordpress.com/widgets/image-widget/#image-widget-caption" target="_blank">( ? )</a>
@@ -230,23 +245,24 @@ class Jetpack_Image_Widget extends WP_Widget {
'center' => __( 'Center', 'jetpack' ),
'right' => __( 'Right', 'jetpack' ),
);
- echo '<p><label for="' . $this->get_field_id( 'align' ) . '">' . esc_html__( 'Image Alignment:', 'jetpack' ) . '
+ echo '<p><label for="' . $this->get_field_id( 'align' ) . '">' . esc_html__( 'Image Alignment:', 'jetpack' ) . '
<select id="' . $this->get_field_id( 'align' ) . '" name="' . $this->get_field_name( 'align' ) . '">';
foreach ( $alignments as $alignment => $alignment_name ) {
echo '<option value="' . esc_attr( $alignment ) . '" ';
- if ( $alignment == $align )
+ if ( $alignment == $align ) {
echo 'selected="selected" ';
- echo '>' . esc_html($alignment_name) . "</option>\n";
+ }
+ echo '>' . esc_html( $alignment_name ) . "</option>\n";
}
echo '</select></label></p>';
- echo '<p><label for="' . $this->get_field_id( 'img_width' ) . '">' . esc_html__( 'Width in pixels:', 'jetpack' ) . '
- <input size="3" id="' . $this->get_field_id( 'img_width' ) . '" name="' . $this->get_field_name( 'img_width' ) . '" type="text" value="' . $img_width . '" />
+ echo '<p><label for="' . $this->get_field_id( 'img_width' ) . '">' . esc_html__( 'Width in pixels:', 'jetpack' ) . '
+ <input size="3" id="' . $this->get_field_id( 'img_width' ) . '" name="' . $this->get_field_name( 'img_width' ) . '" type="text" value="' . $img_width . '" />
</label>
<label for="' . $this->get_field_id( 'img_height' ) . '">' . esc_html__( 'Height in pixels:', 'jetpack' ) . '
<input size="3" id="' . $this->get_field_id( 'img_height' ) . '" name="' . $this->get_field_name( 'img_height' ) . '" type="text" value="' . $img_height . '" />
</label><br />
- <small>' . esc_html__( "If empty, we will attempt to determine the image size.", 'jetpack' ) . '</small></p>
+ <small>' . esc_html__( 'If empty, we will attempt to determine the image size.', 'jetpack' ) . '</small></p>
<p><label for="' . $this->get_field_id( 'link' ) . '">' . esc_html__( 'Link URL (when the image is clicked):', 'jetpack' ) . '
<input class="widefat" id="' . $this->get_field_id( 'link' ) . '" name="' . $this->get_field_name( 'link' ) . '" type="text" value="' . $link . '" />
</label>
diff --git a/plugins/jetpack/modules/widgets/internet-defense-league.php b/plugins/jetpack/modules/widgets/internet-defense-league.php
index f7336c98..9a69d1ab 100644
--- a/plugins/jetpack/modules/widgets/internet-defense-league.php
+++ b/plugins/jetpack/modules/widgets/internet-defense-league.php
@@ -20,15 +20,15 @@ class Jetpack_Internet_Defense_League_Widget extends WP_Widget {
/** This filter is documented in modules/widgets/facebook-likebox.php */
apply_filters( 'jetpack_widget_name', esc_html__( 'Internet Defense League', 'jetpack' ) ),
array(
- 'description' => esc_html__( 'Show your support for the Internet Defense League.', 'jetpack' ),
+ 'description' => esc_html__( 'Show your support for the Internet Defense League.', 'jetpack' ),
'customize_selective_refresh' => true,
)
);
// When enabling campaigns other than 'none' or empty, change $no_current to false above.
$this->campaigns = array(
- '' => esc_html__( 'All current and future campaigns', 'jetpack' ),
- 'none' => esc_html__( 'None, just display the badge please', 'jetpack' ),
+ '' => esc_html__( 'All current and future campaigns', 'jetpack' ),
+ 'none' => esc_html__( 'None, just display the badge please', 'jetpack' ),
);
$this->variants = array(
@@ -60,11 +60,11 @@ class Jetpack_Internet_Defense_League_Widget extends WP_Widget {
if ( ! isset( $this->badges[ $instance['badge'] ] ) ) {
$instance['badge'] = $this->defaults['badge'];
}
- $badge_url = esc_url( 'https://internetdefenseleague.org/images/badges/final/' . $instance['badge'] . '.png' );
+ $badge_url = esc_url( 'https://internetdefenseleague.org/images/badges/final/' . $instance['badge'] . '.png' );
$photon_badge_url = jetpack_photon_url( $badge_url );
- $alt_text = esc_html__( 'Member of The Internet Defense League', 'jetpack' );
+ $alt_text = esc_html__( 'Member of The Internet Defense League', 'jetpack' );
echo $args['before_widget'];
- echo '<p><a href="https://internetdefenseleague.org/"><img src="' . $photon_badge_url . '" alt="' . $alt_text .'" style="max-width: 100%; height: auto;" /></a></p>';
+ echo '<p><a href="https://internetdefenseleague.org/"><img src="' . $photon_badge_url . '" alt="' . $alt_text . '" style="max-width: 100%; height: auto;" /></a></p>';
echo $args['after_widget'];
}
@@ -139,8 +139,8 @@ class Jetpack_Internet_Defense_League_Widget extends WP_Widget {
$instance = array();
$instance['campaign'] = ( isset( $new_instance['campaign'] ) && isset( $this->campaigns[ $new_instance['campaign'] ] ) ) ? $new_instance['campaign'] : $this->defaults['campaign'];
- $instance['variant'] = ( isset( $new_instance['variant'] ) && isset( $this->variants[ $new_instance['variant'] ] ) ) ? $new_instance['variant'] : $this->defaults['variant'];
- $instance['badge'] = ( isset( $new_instance['badge'] ) && isset( $this->badges[ $new_instance['badge'] ] ) ) ? $new_instance['badge'] : $this->defaults['badge'];
+ $instance['variant'] = ( isset( $new_instance['variant'] ) && isset( $this->variants[ $new_instance['variant'] ] ) ) ? $new_instance['variant'] : $this->defaults['variant'];
+ $instance['badge'] = ( isset( $new_instance['badge'] ) && isset( $this->badges[ $new_instance['badge'] ] ) ) ? $new_instance['badge'] : $this->defaults['badge'];
return $instance;
}
diff --git a/plugins/jetpack/modules/widgets/mailchimp.php b/plugins/jetpack/modules/widgets/mailchimp.php
index 2af57ac8..a2aff1ba 100644
--- a/plugins/jetpack/modules/widgets/mailchimp.php
+++ b/plugins/jetpack/modules/widgets/mailchimp.php
@@ -46,7 +46,7 @@ if ( ! class_exists( 'Jetpack_MailChimp_Subscriber_Popup_Widget' ) ) {
$instance = wp_parse_args( $instance, array( 'code' => '' ) );
// Regular expresion that will match maichimp shortcode.
- $regex = "(\[mailchimp_subscriber_popup[^\]]+\])";
+ $regex = '(\[mailchimp_subscriber_popup[^\]]+\])';
// Check if the shortcode exists.
preg_match( $regex, $instance['code'], $matches );
diff --git a/plugins/jetpack/modules/widgets/my-community.php b/plugins/jetpack/modules/widgets/my-community.php
index 00db0660..a9db5f6b 100644
--- a/plugins/jetpack/modules/widgets/my-community.php
+++ b/plugins/jetpack/modules/widgets/my-community.php
@@ -36,7 +36,7 @@ class Jetpack_My_Community_Widget extends WP_Widget {
/** This filter is documented in modules/widgets/facebook-likebox.php */
apply_filters( 'jetpack_widget_name', esc_html__( 'My Community', 'jetpack' ) ),
array(
- 'description' => esc_html__( "Display members of your site's community.", 'jetpack' ),
+ 'description' => esc_html__( "Display members of your site's community.", 'jetpack' ),
'customize_selective_refresh' => true,
)
);
@@ -66,7 +66,7 @@ class Jetpack_My_Community_Widget extends WP_Widget {
* @return string|void
*/
function form( $instance ) {
- $title = isset( $instance['title' ] ) ? $instance['title'] : false;
+ $title = isset( $instance['title'] ) ? $instance['title'] : false;
if ( false === $title ) {
$title = $this->default_title;
}
@@ -76,8 +76,8 @@ class Jetpack_My_Community_Widget extends WP_Widget {
$number = 10;
}
- $include_likers = isset( $instance['include_likers'] ) ? (bool) $instance['include_likers'] : true;
- $include_followers = isset( $instance['include_followers'] ) ? (bool) $instance['include_followers'] : true;
+ $include_likers = isset( $instance['include_likers'] ) ? (bool) $instance['include_likers'] : true;
+ $include_followers = isset( $instance['include_followers'] ) ? (bool) $instance['include_followers'] : true;
$include_commenters = isset( $instance['include_commenters'] ) ? (bool) $instance['include_commenters'] : true;
?>
@@ -129,14 +129,14 @@ class Jetpack_My_Community_Widget extends WP_Widget {
* @return array Updated safe values to be saved.
*/
function update( $new_instance, $old_instance ) {
- $instance = array();
+ $instance = array();
$instance['title'] = wp_kses( $new_instance['title'], array() );
if ( $instance['title'] === $this->default_title ) {
$instance['title'] = false; // Store as false in case of language change
}
$instance['number'] = (int) $new_instance['number'];
- if ( !in_array( $instance['number'], array( 10, 50 ) ) ) {
+ if ( ! in_array( $instance['number'], array( 10, 50 ) ) ) {
$instance['number'] = 10;
}
@@ -158,13 +158,15 @@ class Jetpack_My_Community_Widget extends WP_Widget {
* @param array $instance Saved values from database.
*/
function widget( $args, $instance ) {
- $instance = wp_parse_args( $instance, array(
- 'title' => false,
- 'number' => true,
- 'include_likers' => true,
- 'include_followers' => true,
- 'include_commenters' => true,
- ) );
+ $instance = wp_parse_args(
+ $instance, array(
+ 'title' => false,
+ 'number' => true,
+ 'include_likers' => true,
+ 'include_followers' => true,
+ 'include_commenters' => true,
+ )
+ );
$title = $instance['title'];
@@ -216,7 +218,8 @@ class Jetpack_My_Community_Widget extends WP_Widget {
$my_community = '<div class="widgets-multi-column-grid"><ul>';
foreach ( $members as $member ) {
- $my_community .= sprintf( '<li><a href="%s" %s><img alt="" src="%s" class="avatar avatar-240" height="48" width="48" originals="240" scale="1" /></a></li>',
+ $my_community .= sprintf(
+ '<li><a href="%s" %s><img alt="" src="%s" class="avatar avatar-240" height="48" width="48" originals="240" scale="1" /></a></li>',
$member->profile_URL,
empty( $member->name ) ? '' : 'title="' . $member->name . '"',
$member->avatar_URL
@@ -227,10 +230,13 @@ class Jetpack_My_Community_Widget extends WP_Widget {
} else {
if ( current_user_can( 'edit_theme_options' ) ) {
- $my_community = '<p>' . wp_kses( sprintf( __( 'There are no users to display in this <a href="%1$s">My Community widget</a>. <a href="%2$s">Want more traffic?</a>', 'jetpack' ),
+ $my_community = '<p>' . wp_kses(
+ sprintf(
+ __( 'There are no users to display in this <a href="%1$s">My Community widget</a>. <a href="%2$s">Want more traffic?</a>', 'jetpack' ),
admin_url( 'widgets.php' ),
'https://jetpack.com/support/getting-more-views-and-traffic/'
- ), array( 'a' => array( 'href' => true ) ) ) . '</p>';
+ ), array( 'a' => array( 'href' => true ) )
+ ) . '</p>';
} else {
$my_community = '<p>' . esc_html__( "I'm just starting out; leave me a comment or a like :)", 'jetpack' ) . '</p>';
}
@@ -250,7 +256,7 @@ class Jetpack_My_Community_Widget extends WP_Widget {
*/
function fetch_remote_community( $query ) {
$jetpack_blog_id = Jetpack_Options::get_option( 'id' );
- $url = add_query_arg(
+ $url = add_query_arg(
array(
'number' => $query['number'],
'likers' => (int) $query['include_likers'],
@@ -259,8 +265,8 @@ class Jetpack_My_Community_Widget extends WP_Widget {
),
"https://public-api.wordpress.com/rest/v1.1/sites/$jetpack_blog_id/community"
);
- $response = wp_remote_get( $url );
- $response_body = wp_remote_retrieve_body( $response );
+ $response = wp_remote_get( $url );
+ $response_body = wp_remote_retrieve_body( $response );
if ( empty( $response_body ) ) {
return array();
diff --git a/plugins/jetpack/modules/widgets/rsslinks-widget.php b/plugins/jetpack/modules/widgets/rsslinks-widget.php
index acdcd099..01d1ee2d 100644
--- a/plugins/jetpack/modules/widgets/rsslinks-widget.php
+++ b/plugins/jetpack/modules/widgets/rsslinks-widget.php
@@ -10,8 +10,8 @@ class Jetpack_RSS_Links_Widget extends WP_Widget {
function __construct() {
$widget_ops = array(
- 'classname' => 'widget_rss_links',
- 'description' => __( "Links to your blog's RSS feeds", 'jetpack' ),
+ 'classname' => 'widget_rss_links',
+ 'description' => __( "Links to your blog's RSS feeds", 'jetpack' ),
'customize_selective_refresh' => true,
);
parent::__construct(
@@ -31,21 +31,26 @@ class Jetpack_RSS_Links_Widget extends WP_Widget {
$title = apply_filters( 'widget_title', $instance['title'] );
echo $before_widget;
- if ( $title )
+ if ( $title ) {
echo $before_title . stripslashes( $title ) . $after_title;
+ }
- if ( 'text' == $instance['format'] ) echo '<ul>';
+ if ( 'text' == $instance['format'] ) {
+ echo '<ul>';
+ }
if ( 'posts' == $instance['display'] ) {
- $this->_rss_link( 'posts', $instance);
+ $this->_rss_link( 'posts', $instance );
} elseif ( 'comments' == $instance['display'] ) {
- $this->_rss_link( 'comments', $instance);
+ $this->_rss_link( 'comments', $instance );
} elseif ( 'posts-comments' == $instance['display'] ) {
$this->_rss_link( 'posts', $instance );
$this->_rss_link( 'comments', $instance );
}
- if ( 'text' == $instance['format'] ) echo '</ul>';
+ if ( 'text' == $instance['format'] ) {
+ echo '</ul>';
+ }
echo "\n" . $after_widget;
@@ -61,19 +66,19 @@ class Jetpack_RSS_Links_Widget extends WP_Widget {
*/
function defaults() {
return array(
- 'title' => '',
+ 'title' => '',
'display' => 'posts-comments',
- 'format' => 'text'
+ 'format' => 'text',
);
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
- $instance['title'] = wp_filter_nohtml_kses( $new_instance['title'] );
- $instance['display'] = $new_instance['display'];
- $instance['format'] = $new_instance['format'];
- $instance['imagesize'] = $new_instance['imagesize'];
+ $instance['title'] = wp_filter_nohtml_kses( $new_instance['title'] );
+ $instance['display'] = $new_instance['display'];
+ $instance['format'] = $new_instance['format'];
+ $instance['imagesize'] = $new_instance['imagesize'];
$instance['imagecolor'] = $new_instance['imagecolor'];
return $instance;
@@ -82,10 +87,10 @@ class Jetpack_RSS_Links_Widget extends WP_Widget {
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, $this->defaults() );
- $title = stripslashes( $instance['title'] );
- $display = $instance['display'];
- $format = $instance['format'];
- $image_size = isset( $instance['imagesize'] ) ? $instance['imagesize'] : 0 ;
+ $title = stripslashes( $instance['title'] );
+ $display = $instance['display'];
+ $format = $instance['format'];
+ $image_size = isset( $instance['imagesize'] ) ? $instance['imagesize'] : 0;
$image_color = isset( $instance['imagecolor'] ) ? $instance['imagecolor'] : 'red';
echo '<p><label for="' . $this->get_field_id( 'title' ) . '">' . esc_html__( 'Title:', 'jetpack' ) . '
@@ -95,13 +100,15 @@ class Jetpack_RSS_Links_Widget extends WP_Widget {
$displays = array(
'posts' => __( 'Posts', 'jetpack' ),
'comments' => __( 'Comments', 'jetpack' ),
- 'posts-comments' => __( 'Posts & Comments', 'jetpack' )
+ 'posts-comments' => __( 'Posts & Comments', 'jetpack' ),
);
echo '<p><label for="' . $this->get_field_id( 'display' ) . '">' . esc_html__( 'Feed(s) to Display:', 'jetpack' ) . '
<select class="widefat" id="' . $this->get_field_id( 'display' ) . '" name="' . $this->get_field_name( 'display' ) . '">';
foreach ( $displays as $display_option => $label ) {
echo '<option value="' . esc_attr( $display_option ) . '"';
- if ( $display_option == $display ) echo ' selected="selected"';
+ if ( $display_option == $display ) {
+ echo ' selected="selected"';
+ }
echo '>' . esc_html( $label ) . '</option>' . "\n";
}
echo '</select></label></p>';
@@ -109,31 +116,37 @@ class Jetpack_RSS_Links_Widget extends WP_Widget {
$formats = array(
'text' => __( 'Text Link', 'jetpack' ),
'image' => __( 'Image Link', 'jetpack' ),
- 'text-image' => __( 'Text & Image Links', 'jetpack' )
+ 'text-image' => __( 'Text & Image Links', 'jetpack' ),
);
echo '<p><label for="' . $this->get_field_id( 'format' ) . '">' . _x( 'Format:', 'Noun', 'jetpack' ) . '
<select class="widefat" id="' . $this->get_field_id( 'format' ) . '" name="' . $this->get_field_name( 'format' ) . '" onchange="if ( this.value == \'text\' ) jQuery( \'#' . $this->get_field_id( 'image-settings' ) . '\' ).fadeOut(); else jQuery( \'#' . $this->get_field_id( 'image-settings' ) . '\' ).fadeIn();">';
foreach ( $formats as $format_option => $label ) {
echo '<option value="' . esc_attr( $format_option ) . '"';
- if ( $format_option == $format ) echo ' selected="selected"';
+ if ( $format_option == $format ) {
+ echo ' selected="selected"';
+ }
echo '>' . esc_html( $label ) . '</option>' . "\n";
}
echo '</select></label></p>';
echo '<div id="' . $this->get_field_id( 'image-settings' ) . '"';
- if ( 'text' == $format ) echo ' style="display: none;"';
+ if ( 'text' == $format ) {
+ echo ' style="display: none;"';
+ }
echo '><h3>' . esc_html__( 'Image Settings:', 'jetpack' ) . '</h3>';
$sizes = array(
'small' => __( 'Small', 'jetpack' ),
'medium' => __( 'Medium', 'jetpack' ),
- 'large' => __( 'Large', 'jetpack' )
+ 'large' => __( 'Large', 'jetpack' ),
);
echo '<p><label for="' . $this->get_field_id( 'imagesize' ) . '">' . esc_html__( 'Image Size:', 'jetpack' ) . '
<select class="widefat" id="' . $this->get_field_id( 'imagesize' ) . '" name="' . $this->get_field_name( 'imagesize' ) . '">';
foreach ( $sizes as $size => $label ) {
- echo '<option value="' . esc_attr( $size) . '"';
- if ( $size == $image_size ) echo ' selected="selected"';
+ echo '<option value="' . esc_attr( $size ) . '"';
+ if ( $size == $image_size ) {
+ echo ' selected="selected"';
+ }
echo '>' . esc_html( $label ) . '</option>' . "\n";
}
echo '</select></label></p>';
@@ -150,8 +163,10 @@ class Jetpack_RSS_Links_Widget extends WP_Widget {
echo '<p><label for="' . $this->get_field_id( 'imagecolor' ) . '">' . esc_html__( 'Image Color:', 'jetpack' ) . '
<select class="widefat" id="' . $this->get_field_id( 'imagecolor' ) . '" name="' . $this->get_field_name( 'imagecolor' ) . '">';
foreach ( $colors as $color => $label ) {
- echo '<option value="' . esc_attr( $color) . '"';
- if ( $color == $image_color ) echo ' selected="selected"';
+ echo '<option value="' . esc_attr( $color ) . '"';
+ if ( $color == $image_color ) {
+ echo ' selected="selected"';
+ }
echo '>' . esc_html( $label ) . '</option>' . "\n";
}
echo '</select></label></p></div>';
@@ -160,16 +175,16 @@ class Jetpack_RSS_Links_Widget extends WP_Widget {
function _rss_link( $type = 'posts', $args ) {
if ( 'posts' == $type ) {
$type_text = __( 'Posts', 'jetpack' );
- $rss_type = 'rss2_url';
+ $rss_type = 'rss2_url';
} elseif ( 'comments' == $type ) {
$type_text = __( 'Comments', 'jetpack' );
- $rss_type = 'comments_rss2_url';
+ $rss_type = 'comments_rss2_url';
}
$subscribe_to = sprintf( __( 'Subscribe to %s', 'jetpack' ), $type_text );
$link_item = '';
- $format = $args['format'];
+ $format = $args['format'];
/**
* Filters the target link attribute for the RSS link in the RSS widget.
@@ -197,24 +212,26 @@ class Jetpack_RSS_Links_Widget extends WP_Widget {
* @param string $var URL of RSS Widget icon.
*/
$link_image = apply_filters( 'jetpack_rss_widget_icon', plugins_url( 'images/rss/' . $args['imagecolor'] . '-' . $args['imagesize'] . '.png', dirname( dirname( __FILE__ ) ) ) );
- $link_item = '<a target="' . $link_target . '" href="' . get_bloginfo( $rss_type ) . '" title="' . esc_attr( $subscribe_to ) . '"><img src="' . esc_url( $link_image ) . '" alt="RSS Feed" /></a>';
+ $link_item = '<a target="' . $link_target . '" href="' . get_bloginfo( $rss_type ) . '" title="' . esc_attr( $subscribe_to ) . '"><img src="' . esc_url( $link_image ) . '" alt="RSS Feed" /></a>';
}
if ( 'text-image' == $format ) {
- $link_item .= '&nbsp;<a target="' . $link_target . '" href="' . get_bloginfo( $rss_type ) . '" title="' . esc_attr( $subscribe_to ) . '">' . esc_html__( 'RSS - ' . $type_text, 'jetpack' ). '</a>';
+ $link_item .= '&nbsp;<a target="' . $link_target . '" href="' . get_bloginfo( $rss_type ) . '" title="' . esc_attr( $subscribe_to ) . '">' . esc_html__( 'RSS - ' . $type_text, 'jetpack' ) . '</a>';
}
if ( 'text' == $format ) {
- $link_item = '<a target="' . $link_target . '" href="' . get_bloginfo( $rss_type ) . '" title="' . esc_attr( $subscribe_to ) . '">' . esc_html__( 'RSS - ' . $type_text, 'jetpack' ). '</a>';
+ $link_item = '<a target="' . $link_target . '" href="' . get_bloginfo( $rss_type ) . '" title="' . esc_attr( $subscribe_to ) . '">' . esc_html__( 'RSS - ' . $type_text, 'jetpack' ) . '</a>';
}
- if ( 'text' == $format )
+ if ( 'text' == $format ) {
echo '<li>';
- else
+ } else {
echo '<p>';
+ }
echo $link_item;
- if ( 'text' == $format )
+ if ( 'text' == $format ) {
echo '</li>';
- else
+ } else {
echo '</p>';
+ }
}
} // Class Jetpack_RSS_Links_Widget
diff --git a/plugins/jetpack/modules/widgets/search.php b/plugins/jetpack/modules/widgets/search.php
index b217f1fe..8e176c8c 100644
--- a/plugins/jetpack/modules/widgets/search.php
+++ b/plugins/jetpack/modules/widgets/search.php
@@ -57,11 +57,14 @@ class Jetpack_Search_Widget extends WP_Widget {
*
* @since 5.0.0
*/
- public function __construct() {
+ public function __construct( $name = null ) {
+ if ( empty( $name ) ) {
+ $name = esc_html__( 'Search', 'jetpack' );
+ }
parent::__construct(
Jetpack_Search_Helpers::FILTER_WIDGET_BASE,
/** This filter is documented in modules/widgets/facebook-likebox.php */
- apply_filters( 'jetpack_widget_name', esc_html__( 'Search', 'jetpack' ) ),
+ apply_filters( 'jetpack_widget_name', $name ),
array(
'classname' => 'jetpack-filters widget_search',
'description' => __( 'Replaces the default search with an Elasticsearch-powered search interface and filters.', 'jetpack' ),
@@ -70,9 +73,9 @@ class Jetpack_Search_Widget extends WP_Widget {
if (
Jetpack_Search_Helpers::is_active_widget( $this->id ) &&
- ! Jetpack::is_module_active( 'search' )
+ ! $this->is_search_active()
) {
- Jetpack::activate_module( 'search', false, false );
+ $this->activate_search();
}
if ( is_admin() ) {
@@ -86,6 +89,25 @@ class Jetpack_Search_Widget extends WP_Widget {
}
/**
+ * Check whether search is currently active
+ *
+ * @since 6.3
+ */
+ public function is_search_active() {
+ return Jetpack::is_module_active( 'search' );
+ }
+
+ /**
+ * Activate search
+ *
+ * @since 6.3
+ */
+ public function activate_search() {
+ Jetpack::activate_module( 'search', false, false );
+ }
+
+
+ /**
* Enqueues the scripts and styles needed for the customizer.
*
* @since 5.7.0
@@ -117,19 +139,21 @@ class Jetpack_Search_Widget extends WP_Widget {
JETPACK__VERSION
);
- wp_localize_script( 'jetpack-search-widget-admin', 'jetpack_search_filter_admin', array(
- 'defaultFilterCount' => self::DEFAULT_FILTER_COUNT,
- 'tracksUserData' => Jetpack_Tracks_Client::get_connected_user_tracks_identity(),
- 'tracksEventData' => array(
- 'is_customizer' => ( function_exists( 'is_customize_preview' ) && is_customize_preview() ) ? 1 : 0,
- ),
- 'i18n' => array(
- 'month' => Jetpack_Search_Helpers::get_date_filter_type_name( 'month', false ),
- 'year' => Jetpack_Search_Helpers::get_date_filter_type_name( 'year', false ),
- 'monthUpdated' => Jetpack_Search_Helpers::get_date_filter_type_name( 'month', true ),
- 'yearUpdated' => Jetpack_Search_Helpers::get_date_filter_type_name( 'year', true ),
- ),
- ) );
+ wp_localize_script(
+ 'jetpack-search-widget-admin', 'jetpack_search_filter_admin', array(
+ 'defaultFilterCount' => self::DEFAULT_FILTER_COUNT,
+ 'tracksUserData' => Jetpack_Tracks_Client::get_connected_user_tracks_identity(),
+ 'tracksEventData' => array(
+ 'is_customizer' => ( function_exists( 'is_customize_preview' ) && is_customize_preview() ) ? 1 : 0,
+ ),
+ 'i18n' => array(
+ 'month' => Jetpack_Search_Helpers::get_date_filter_type_name( 'month', false ),
+ 'year' => Jetpack_Search_Helpers::get_date_filter_type_name( 'year', false ),
+ 'monthUpdated' => Jetpack_Search_Helpers::get_date_filter_type_name( 'month', true ),
+ 'yearUpdated' => Jetpack_Search_Helpers::get_date_filter_type_name( 'year', true ),
+ ),
+ )
+ );
wp_enqueue_script( 'jetpack-search-widget-admin' );
}
@@ -166,7 +190,7 @@ class Jetpack_Search_Widget extends WP_Widget {
return array(
'relevance|DESC' => is_admin() ? esc_html__( 'Relevance (recommended)', 'jetpack' ) : esc_html__( 'Relevance', 'jetpack' ),
'date|DESC' => esc_html__( 'Newest first', 'jetpack' ),
- 'date|ASC' => esc_html__( 'Oldest first', 'jetpack' )
+ 'date|ASC' => esc_html__( 'Oldest first', 'jetpack' ),
);
}
@@ -215,13 +239,16 @@ class Jetpack_Search_Widget extends WP_Widget {
}
public function jetpack_search_populate_defaults( $instance ) {
- $instance = wp_parse_args( (array) $instance, array(
- 'title' => '',
- 'search_box_enabled' => true,
- 'user_sort_enabled' => true,
- 'sort' => self::DEFAULT_SORT,
- 'filters' => array( array() ),
- ) );
+ $instance = wp_parse_args(
+ (array) $instance, array(
+ 'title' => '',
+ 'search_box_enabled' => true,
+ 'user_sort_enabled' => true,
+ 'sort' => self::DEFAULT_SORT,
+ 'filters' => array( array() ),
+ 'post_types' => array(),
+ )
+ );
return $instance;
}
@@ -269,7 +296,8 @@ class Jetpack_Search_Widget extends WP_Widget {
$title = apply_filters( 'widget_title', $title, $instance, $this->id_base );
echo $args['before_widget'];
- ?><div id="<?php echo esc_attr( $this->id ); ?>-wrapper"><?php
+ ?><div id="<?php echo esc_attr( $this->id ); ?>-wrapper">
+ <?php
if ( ! empty( $title ) ) {
/**
@@ -286,9 +314,9 @@ class Jetpack_Search_Widget extends WP_Widget {
do_action( 'jetpack_search_render_filters_widget_title', $title, $args['before_title'], $args['after_title'] );
}
- $default_sort = isset( $instance['sort'] ) ? $instance['sort'] : self::DEFAULT_SORT;
+ $default_sort = isset( $instance['sort'] ) ? $instance['sort'] : self::DEFAULT_SORT;
list( $orderby, $order ) = $this->sorting_to_wp_query_param( $default_sort );
- $current_sort = "{$orderby}|{$order}";
+ $current_sort = "{$orderby}|{$order}";
// we need to dynamically inject the sort field into the search box when the search box is enabled, and display
// it separately when it's not.
@@ -296,8 +324,9 @@ class Jetpack_Search_Widget extends WP_Widget {
Jetpack_Search_Template_Tags::render_widget_search_form( $instance['post_types'], $orderby, $order );
}
- if ( ! empty( $instance['search_box_enabled'] ) && ! empty( $instance['user_sort_enabled'] ) ): ?>
- <div class="jetpack-search-sort-wrapper">
+ if ( ! empty( $instance['search_box_enabled'] ) && ! empty( $instance['user_sort_enabled'] ) ) :
+ ?>
+ <div class="jetpack-search-sort-wrapper">
<label>
<?php esc_html_e( 'Sort by', 'jetpack' ); ?>
<select class="jetpack-search-sort">
@@ -309,7 +338,8 @@ class Jetpack_Search_Widget extends WP_Widget {
</select>
</label>
</div>
- <?php endif;
+ <?php
+ endif;
if ( $display_filters ) {
/**
@@ -331,7 +361,7 @@ class Jetpack_Search_Widget extends WP_Widget {
$this->maybe_render_sort_javascript( $instance, $order, $orderby );
- echo "</div>";
+ echo '</div>';
echo $args['after_widget'];
}
@@ -438,7 +468,7 @@ class Jetpack_Search_Widget extends WP_Widget {
if ( isset( $new_instance['filter_type'] ) ) {
foreach ( (array) $new_instance['filter_type'] as $index => $type ) {
$count = intval( $new_instance['num_filters'][ $index ] );
- $count = min( 50, $count ); // Set max boundary at 20.
+ $count = min( 50, $count ); // Set max boundary at 50.
$count = max( 1, $count ); // Set min boundary at 1.
switch ( $type ) {
@@ -566,7 +596,7 @@ class Jetpack_Search_Widget extends WP_Widget {
</label>
</p>
- <?php if ( ! $hide_filters ): ?>
+ <?php if ( ! $hide_filters ) : ?>
<script class="jetpack-search-filters-widget__filter-template" type="text/template">
<?php echo $this->render_widget_edit_filter( array(), true ); ?>
</script>
@@ -598,7 +628,7 @@ class Jetpack_Search_Widget extends WP_Widget {
}
/**
- * We need to render HTML in two formats: an Underscore template (client-size)
+ * We need to render HTML in two formats: an Underscore template (client-side)
* and native PHP (server-side). This helper function allows for easy rendering
* of attributes in both formats.
*
@@ -640,15 +670,17 @@ class Jetpack_Search_Widget extends WP_Widget {
* @param bool $is_template Whether this is for an Underscore template or not.
*/
public function render_widget_edit_filter( $filter, $is_template = false ) {
- $args = wp_parse_args( $filter, array(
- 'name' => '',
- 'type' => 'taxonomy',
- 'taxonomy' => '',
- 'post_type' => '',
- 'field' => '',
- 'interval' => '',
- 'count' => self::DEFAULT_FILTER_COUNT,
- ) );
+ $args = wp_parse_args(
+ $filter, array(
+ 'name' => '',
+ 'type' => 'taxonomy',
+ 'taxonomy' => '',
+ 'post_type' => '',
+ 'field' => '',
+ 'interval' => '',
+ 'count' => self::DEFAULT_FILTER_COUNT,
+ )
+ );
$args['name_placeholder'] = Jetpack_Search_Helpers::generate_widget_filter_name( $args );
@@ -765,5 +797,6 @@ class Jetpack_Search_Widget extends WP_Widget {
<a href="#" class="delete"><?php esc_html_e( 'Remove', 'jetpack' ); ?></a>
</p>
</div>
- <?php }
+ <?php
+ }
}
diff --git a/plugins/jetpack/modules/widgets/simple-payments.php b/plugins/jetpack/modules/widgets/simple-payments.php
index f31af1b0..4eb60bdb 100644
--- a/plugins/jetpack/modules/widgets/simple-payments.php
+++ b/plugins/jetpack/modules/widgets/simple-payments.php
@@ -10,7 +10,7 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
/**
* Simple Payments Button
*
- * Display a Simple Payment Button as a Widget.
+ * Display a Simple Payments Button as a Widget.
*/
class Jetpack_Simple_Payments_Widget extends WP_Widget {
// https://developer.paypal.com/docs/integration/direct/rest/currency-codes/
@@ -50,14 +50,20 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
/** This filter is documented in modules/widgets/facebook-likebox.php */
apply_filters( 'jetpack_widget_name', __( 'Simple Payments', 'jetpack' ) ),
array(
- 'classname' => 'jetpack-simple-payments',
- 'description' => __( 'Add a Simple Payment Button as a Widget.', 'jetpack' ),
+ 'classname' => 'jetpack-simple-payments',
+ 'description' => __( 'Add a Simple Payments Button as a Widget.', 'jetpack' ),
'customize_selective_refresh' => true,
)
);
- if ( is_customize_preview() ) {
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_styles_and_scripts' ) );
+ global $pagenow;
+ if ( is_customize_preview() || 'widgets.php' === $pagenow ) {
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_styles' ) );
+ }
+
+ $jetpack_simple_payments = Jetpack_Simple_Payments::getInstance();
+ if ( is_customize_preview() && $jetpack_simple_payments->is_enabled_jetpack_simple_payments() ) {
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
add_filter( 'customize_refresh_nonces', array( $this, 'filter_nonces' ) );
add_action( 'wp_ajax_customize-jetpack-simple-payments-buttons-get', array( $this, 'ajax_get_payment_buttons' ) );
@@ -78,22 +84,22 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
* @return array Default values for the widget options.
*/
private function defaults() {
- $current_user = wp_get_current_user();
+ $current_user = wp_get_current_user();
$default_product_id = $this->get_first_product_id();
return array(
- 'title' => '',
- 'product_post_id' => $default_product_id,
- 'form_action' => '',
- 'form_product_id' => 0,
- 'form_product_title' => '',
+ 'title' => '',
+ 'product_post_id' => $default_product_id,
+ 'form_action' => '',
+ 'form_product_id' => 0,
+ 'form_product_title' => '',
'form_product_description' => '',
- 'form_product_image_id' => 0,
- 'form_product_image_src' => '',
- 'form_product_currency' => '',
- 'form_product_price' => '',
- 'form_product_multiple' => '',
- 'form_product_email' => $current_user->user_email,
+ 'form_product_image_id' => 0,
+ 'form_product_image_src' => '',
+ 'form_product_currency' => '',
+ 'form_product_price' => '',
+ 'form_product_multiple' => '',
+ 'form_product_email' => $current_user->user_email,
);
}
@@ -112,14 +118,18 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
wp_enqueue_style( 'jetpack-simple-payments-widget-style', plugins_url( 'simple-payments/style.css', __FILE__ ), array(), '20180518' );
}
- function admin_enqueue_styles_and_scripts(){
- wp_enqueue_style( 'jetpack-simple-payments-widget-customizer', plugins_url( 'simple-payments/customizer.css', __FILE__ ) );
+ function admin_enqueue_styles() {
+ wp_enqueue_style( 'jetpack-simple-payments-widget-customizer', plugins_url( 'simple-payments/customizer.css', __FILE__ ) );
+ }
+ function admin_enqueue_scripts() {
wp_enqueue_media();
wp_enqueue_script( 'jetpack-simple-payments-widget-customizer', plugins_url( '/simple-payments/customizer.js', __FILE__ ), array( 'jquery' ), false, true );
- wp_localize_script( 'jetpack-simple-payments-widget-customizer', 'jpSimplePaymentsStrings', array(
- 'deleteConfirmation' => __( 'Are you sure you want to delete this item? It will be disabled and removed from all locations where it currently appears.', 'jetpack' )
- ) );
+ wp_localize_script(
+ 'jetpack-simple-payments-widget-customizer', 'jpSimplePaymentsStrings', array(
+ 'deleteConfirmation' => __( 'Are you sure you want to delete this item? It will be disabled and removed from all locations where it currently appears.', 'jetpack' ),
+ )
+ );
}
public function ajax_get_payment_buttons() {
@@ -136,12 +146,14 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
wp_send_json_error( 'insufficient_post_permissions', 403 );
}
- $product_posts = get_posts( array(
- 'numberposts' => 100,
- 'orderby' => 'date',
- 'post_type' => Jetpack_Simple_Payments::$post_type_product,
- 'post_status' => 'publish',
- ) );
+ $product_posts = get_posts(
+ array(
+ 'numberposts' => 100,
+ 'orderby' => 'date',
+ 'post_type' => Jetpack_Simple_Payments::$post_type_product,
+ 'post_status' => 'publish',
+ )
+ );
$formatted_products = array_map( array( $this, 'format_product_post_for_ajax_reponse' ), $product_posts );
@@ -150,7 +162,7 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
public function format_product_post_for_ajax_reponse( $product_post ) {
return array(
- 'ID' => $product_post->ID,
+ 'ID' => $product_post->ID,
'post_title' => $product_post->post_title,
);
}
@@ -182,17 +194,17 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
$product_post_id = isset( $params['product_post_id'] ) ? intval( $params['product_post_id'] ) : 0;
$product_post = array(
- 'ID' => $product_post_id,
- 'post_type' => Jetpack_Simple_Payments::$post_type_product,
- 'post_status' => 'publish',
- 'post_title' => $params['post_title'],
- 'post_content' => $params['post_content'],
+ 'ID' => $product_post_id,
+ 'post_type' => Jetpack_Simple_Payments::$post_type_product,
+ 'post_status' => 'publish',
+ 'post_title' => $params['post_title'],
+ 'post_content' => $params['post_content'],
'_thumbnail_id' => ! empty( $params['image_id'] ) ? $params['image_id'] : -1,
- 'meta_input' => array(
+ 'meta_input' => array(
'spay_currency' => $params['currency'],
- 'spay_price' => $params['price'],
+ 'spay_price' => $params['price'],
'spay_multiple' => isset( $params['multiple'] ) ? intval( $params['multiple'] ) : 0,
- 'spay_email' => is_email( $params['email'] ),
+ 'spay_email' => is_email( $params['email'] ),
),
);
@@ -209,7 +221,7 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
$tracks_properties = array(
'id' => $product_post_id,
'currency' => $params['currency'],
- 'price' => $params['price']
+ 'price' => $params['price'],
);
if ( 0 === $product_post['ID'] ) {
$this->record_event( 'created', 'create', $tracks_properties );
@@ -217,10 +229,12 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
$this->record_event( 'updated', 'update', $tracks_properties );
}
- wp_send_json_success( array(
- 'product_post_id' => $product_post_id,
- 'product_post_title' => $params['post_title'],
- ) );
+ wp_send_json_success(
+ array(
+ 'product_post_id' => $product_post_id,
+ 'product_post_title' => $params['post_title'],
+ )
+ );
}
public function ajax_delete_payment_button() {
@@ -236,13 +250,13 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
wp_send_json_error( 'missing_params', 400 );
}
- $params = wp_unslash( $_POST['params'] );
+ $params = wp_unslash( $_POST['params'] );
$illegal_params = array_diff( array_keys( $params ), array( 'product_post_id' ) );
if ( ! empty( $illegal_params ) ) {
wp_send_json_error( 'illegal_params', 400 );
}
- $product_id = ( int ) $params['product_post_id'];
+ $product_id = (int) $params['product_post_id'];
$product_post = get_post( $product_id );
$return = array( 'status' => $product_post->post_status );
@@ -258,36 +272,60 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
wp_send_json_success( $return );
}
+ /**
+ * Returns the number of decimal places on string representing a price.
+ *
+ * @param string $number Price to check.
+ * @return number number of decimal places.
+ */
+ private function get_decimal_places( $number ) {
+ $parts = explode( '.', $number );
+ if ( count( $parts ) > 2 ) {
+ return null;
+ }
+
+ return isset( $parts[1] ) ? strlen( $parts[1] ) : 0;
+ }
+
public function validate_ajax_params( $params ) {
$errors = new WP_Error();
$illegal_params = array_diff( array_keys( $params ), array( 'product_post_id', 'post_title', 'post_content', 'image_id', 'currency', 'price', 'multiple', 'email' ) );
if ( ! empty( $illegal_params ) ) {
- $errors.add( 'illegal_params' );
+ $errors->add( 'illegal_params', __( 'Invalid parameters.', 'jetpack' ) );
}
if ( empty( $params['post_title'] ) ) {
- $errors->add( 'post_title', __( 'People need to know what they\'re paying for! Please add a brief title.' ) );
+ $errors->add( 'post_title', __( "People need to know what they're paying for! Please add a brief title.", 'jetpack' ) );
}
- if ( empty( $params['price'] ) || floatval( $params['price'] ) <= 0 ) {
- $errors->add( 'price', __( 'Everything comes with a price tag these days. Please add a your product price.' ) );
+ if ( empty( $params['price'] ) || ! is_numeric( $params['price'] ) || floatval( $params['price'] ) <= 0 ) {
+ $errors->add( 'price', __( 'Everything comes with a price tag these days. Please add a your product price.', 'jetpack' ) );
+ }
+
+ // Japan's Yen is the only supported currency with a zero decimal precision.
+ $precision = strtoupper( $params['currency'] ) === 'JPY' ? 0 : 2;
+ $price_decimal_places = $this->get_decimal_places( $params['price'] );
+ if ( is_null( $price_decimal_places ) || $price_decimal_places > $precision ) {
+ $errors->add( 'price', __( 'Invalid price', 'jetpack' ) );
}
if ( empty( $params['email'] ) || ! is_email( $params['email'] ) ) {
- $errors->add( 'email', __( 'We want to make sure payments reach you, so please add an email address.' ) );
+ $errors->add( 'email', __( 'We want to make sure payments reach you, so please add an email address.', 'jetpack' ) );
}
return $errors;
}
function get_first_product_id() {
- $product_posts = get_posts( array(
- 'numberposts' => 1,
- 'orderby' => 'date',
- 'post_type' => Jetpack_Simple_Payments::$post_type_product,
- 'post_status' => 'publish',
- ) );
+ $product_posts = get_posts(
+ array(
+ 'numberposts' => 1,
+ 'orderby' => 'date',
+ 'post_type' => Jetpack_Simple_Payments::$post_type_product,
+ 'post_status' => 'publish',
+ )
+ );
return ! empty( $product_posts ) ? $product_posts[0]->ID : null;
}
@@ -316,10 +354,12 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
if ( ! empty( $instance['form_action'] ) && in_array( $instance['form_action'], array( 'add', 'edit' ) ) && is_customize_preview() ) {
require( dirname( __FILE__ ) . '/simple-payments/widget.php' );
} else {
- $jsp = Jetpack_Simple_Payments::getInstance();
- $simple_payments_button = $jsp->parse_shortcode( array(
- 'id' => $instance['product_post_id'],
- ) );
+ $jsp = Jetpack_Simple_Payments::getInstance();
+ $simple_payments_button = $jsp->parse_shortcode(
+ array(
+ 'id' => $instance['product_post_id'],
+ )
+ );
if ( ! is_null( $simple_payments_button ) || is_customize_preview() ) {
echo $simple_payments_button;
@@ -341,7 +381,7 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
* @param array $mixed Array of values for the old form instance.
* @return mixed $mixed Field value.
*/
- private function get_latest_field_value( $new_instance, $old_instance, $field) {
+ private function get_latest_field_value( $new_instance, $old_instance, $field ) {
return ! empty( $new_instance[ $field ] )
? sanitize_text_field( $new_instance[ $field ] )
: $old_instance[ $field ];
@@ -355,21 +395,21 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
* @return array $fields Product Fields from the Product Post.
*/
private function get_product_from_post( $product_post_id ) {
- $product_post = get_post( $product_post_id );
+ $product_post = get_post( $product_post_id );
$form_product_id = $product_post_id;
- if( ! empty( $product_post ) ) {
+ if ( ! empty( $product_post ) ) {
$form_product_image_id = get_post_thumbnail_id( $product_post_id );
return array(
- 'form_product_id' => $form_product_id,
- 'form_product_title' => get_the_title( $product_post ),
+ 'form_product_id' => $form_product_id,
+ 'form_product_title' => get_the_title( $product_post ),
'form_product_description' => $product_post->post_content,
- 'form_product_image_id' => $form_product_image_id,
- 'form_product_image_src' => wp_get_attachment_image_url( $form_product_image_id, 'thumbnail' ),
- 'form_product_currency' => get_post_meta( $product_post_id, 'spay_currency', true ),
- 'form_product_price' => get_post_meta( $product_post_id, 'spay_price', true ),
- 'form_product_multiple' => get_post_meta( $product_post_id, 'spay_multiple', true ) || '0',
- 'form_product_email' => get_post_meta( $product_post_id, 'spay_email', true ),
+ 'form_product_image_id' => $form_product_image_id,
+ 'form_product_image_src' => wp_get_attachment_image_url( $form_product_image_id, 'thumbnail' ),
+ 'form_product_currency' => get_post_meta( $product_post_id, 'spay_currency', true ),
+ 'form_product_price' => get_post_meta( $product_post_id, 'spay_price', true ),
+ 'form_product_multiple' => get_post_meta( $product_post_id, 'spay_multiple', true ) || '0',
+ 'form_product_email' => get_post_meta( $product_post_id, 'spay_email', true ),
);
}
@@ -398,7 +438,7 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
jetpack_tracks_record_event( $current_user, 'jetpack_wpa_simple_payments_button_' . $event_action, $event_properties );
$jetpack = Jetpack::init();
// $jetpack->stat automatically prepends the stat group with 'jetpack-'
- $jetpack->stat( 'simple_payments', $stat_name ) ;
+ $jetpack->stat( 'simple_payments', $stat_name );
$jetpack->do_stats( 'server_side' );
}
@@ -419,14 +459,14 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
$old_instance = wp_parse_args( $old_instance, $defaults );
$required_widget_props = array(
- 'title' => $this->get_latest_field_value( $new_instance, $old_instance, 'title' ),
+ 'title' => $this->get_latest_field_value( $new_instance, $old_instance, 'title' ),
'product_post_id' => $this->get_latest_field_value( $new_instance, $old_instance, 'product_post_id' ),
- 'form_action' => $this->get_latest_field_value( $new_instance, $old_instance, 'form_action' ),
+ 'form_action' => $this->get_latest_field_value( $new_instance, $old_instance, 'form_action' ),
);
if ( strcmp( $new_instance['form_action'], $old_instance['form_action'] ) !== 0 ) {
if ( $new_instance['form_action'] == 'edit' ) {
- return array_merge( $this->get_product_from_post( ( int ) $old_instance['product_post_id'] ), $required_widget_props );
+ return array_merge( $this->get_product_from_post( (int) $old_instance['product_post_id'] ), $required_widget_props );
}
if ( $new_instance['form_action'] == 'clear' ) {
@@ -440,17 +480,19 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
? sanitize_text_field( $new_instance['form_product_email'] )
: $defaults['form_product_email'];
- return array_merge( $required_widget_props, array(
- 'form_product_id' => ( int ) $new_instance['form_product_id'],
- 'form_product_title' => sanitize_text_field( $new_instance['form_product_title'] ),
- 'form_product_description' => sanitize_text_field( $new_instance['form_product_description'] ),
- 'form_product_image_id' => $form_product_image_id,
- 'form_product_image_src' => wp_get_attachment_image_url( $form_product_image_id, 'thumbnail' ),
- 'form_product_currency' => sanitize_text_field( $new_instance['form_product_currency'] ),
- 'form_product_price' => sanitize_text_field( $new_instance['form_product_price'] ),
- 'form_product_multiple' => sanitize_text_field( $new_instance['form_product_multiple'] ),
- 'form_product_email' => $form_product_email,
- ) );
+ return array_merge(
+ $required_widget_props, array(
+ 'form_product_id' => (int) $new_instance['form_product_id'],
+ 'form_product_title' => sanitize_text_field( $new_instance['form_product_title'] ),
+ 'form_product_description' => sanitize_text_field( $new_instance['form_product_description'] ),
+ 'form_product_image_id' => $form_product_image_id,
+ 'form_product_image_src' => wp_get_attachment_image_url( $form_product_image_id, 'thumbnail' ),
+ 'form_product_currency' => sanitize_text_field( $new_instance['form_product_currency'] ),
+ 'form_product_price' => sanitize_text_field( $new_instance['form_product_price'] ),
+ 'form_product_multiple' => sanitize_text_field( $new_instance['form_product_multiple'] ),
+ 'form_product_email' => $form_product_email,
+ )
+ );
}
/**
@@ -461,21 +503,36 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
* @param array $instance Previously saved values from database.
*/
function form( $instance ) {
+ $jetpack_simple_payments = Jetpack_Simple_Payments::getInstance();
+ if ( ! method_exists( $jetpack_simple_payments, 'is_enabled_jetpack_simple_payments' ) ) {
+ return;
+ }
+ if ( ! $jetpack_simple_payments->is_enabled_jetpack_simple_payments() ) {
+ require dirname( __FILE__ ) . '/simple-payments/admin-warning.php';
+ return;
+ }
+
$instance = wp_parse_args( $instance, $this->defaults() );
- $product_posts = get_posts( array(
- 'numberposts' => 100,
- 'orderby' => 'date',
- 'post_type' => Jetpack_Simple_Payments::$post_type_product,
- 'post_status' => 'publish',
- ) );
+ $product_posts = get_posts(
+ array(
+ 'numberposts' => 100,
+ 'orderby' => 'date',
+ 'post_type' => Jetpack_Simple_Payments::$post_type_product,
+ 'post_status' => 'publish',
+ )
+ );
- require( dirname( __FILE__ ) . '/simple-payments/form.php' );
+ require dirname( __FILE__ ) . '/simple-payments/form.php';
}
}
// Register Jetpack_Simple_Payments_Widget widget.
function register_widget_jetpack_simple_payments() {
+ if ( ! class_exists( 'Jetpack_Simple_Payments' ) ) {
+ return;
+ }
+
$jetpack_simple_payments = Jetpack_Simple_Payments::getInstance();
if ( ! $jetpack_simple_payments->is_enabled_jetpack_simple_payments() ) {
return;
diff --git a/plugins/jetpack/modules/widgets/simple-payments/admin-warning.php b/plugins/jetpack/modules/widgets/simple-payments/admin-warning.php
new file mode 100644
index 00000000..f66e4413
--- /dev/null
+++ b/plugins/jetpack/modules/widgets/simple-payments/admin-warning.php
@@ -0,0 +1,16 @@
+<div class='jetpack-simple-payments-disabled-error'>
+ <p>
+ <?php
+ $support_url = ( defined( 'IS_WPCOM' ) && IS_WPCOM )
+ ? 'https://support.wordpress.com/simple-payments/'
+ : 'https://jetpack.com/support/simple-payment-button/';
+ printf(
+ wp_kses(
+ __( 'Your plan doesn\'t include Simple Payments. <a href="%s" rel="noopener noreferrer" target="_blank">Learn more and upgrade</a>.', 'jetpack' ),
+ array( 'a' => array( 'href' => array(), 'rel' => array(), 'target' => array() ) )
+ ),
+ esc_url( $support_url )
+ );
+ ?>
+ </p>
+</div>
diff --git a/plugins/jetpack/modules/widgets/simple-payments/customizer.css b/plugins/jetpack/modules/widgets/simple-payments/customizer.css
index 48733d51..12278a60 100644
--- a/plugins/jetpack/modules/widgets/simple-payments/customizer.css
+++ b/plugins/jetpack/modules/widgets/simple-payments/customizer.css
@@ -3,6 +3,14 @@
clear: both;
}
+.widget-content .jetpack-simple-payments-disabled-error {
+ background: #fff;
+ border-left: 4px solid #dc3232;
+ box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
+ margin: 5px 0 15px;
+ padding: 1px 12px;
+}
+
.widget-content .jetpack-simple-payments-form .invalid {
border: 1px solid #dc3232;
}
diff --git a/plugins/jetpack/modules/widgets/simple-payments/customizer.js b/plugins/jetpack/modules/widgets/simple-payments/customizer.js
index 8930ebba..132ae55d 100644
--- a/plugins/jetpack/modules/widgets/simple-payments/customizer.js
+++ b/plugins/jetpack/modules/widgets/simple-payments/customizer.js
@@ -232,6 +232,15 @@
}
}
+ function decimalPlaces( number ) {
+ var parts = number.split( '.' );
+ if ( parts.length > 2 ) {
+ return null;
+ }
+
+ return parts[ 1 ] ? parts[ 1 ].length : 0;
+ }
+
function isFormValid( widgetForm ) {
widgetForm.find( '.invalid' ).removeClass( 'invalid' );
@@ -244,7 +253,15 @@
}
var productPrice = widgetForm.find( '.jetpack-simple-payments-form-product-price' ).val();
- if ( ! productPrice || isNaN( parseFloat( productPrice ) ) || parseFloat( productPrice ) <= 0 ) {
+ if ( ! productPrice || isNaN( productPrice ) || parseFloat( productPrice ) <= 0 ) {
+ widgetForm.find( '.jetpack-simple-payments-form-product-price' ).addClass( 'invalid' );
+ errors = true;
+ }
+
+ // Japan's Yen is the only supported currency with a zero decimal precision.
+ var precision = widgetForm.find( '.jetpack-simple-payments-form-product-currency' ).val() === 'JPY' ? 0 : 2;
+ var priceDecimalPlaces = decimalPlaces( productPrice );
+ if ( priceDecimalPlaces === null || priceDecimalPlaces > precision ) {
widgetForm.find( '.jetpack-simple-payments-form-product-price' ).addClass( 'invalid' );
errors = true;
}
diff --git a/plugins/jetpack/modules/widgets/simple-payments/form.php b/plugins/jetpack/modules/widgets/simple-payments/form.php
index 483c4661..7732be5d 100644
--- a/plugins/jetpack/modules/widgets/simple-payments/form.php
+++ b/plugins/jetpack/modules/widgets/simple-payments/form.php
@@ -1,5 +1,15 @@
+<?php
+/**
+ * Display the Simple Payments Form.
+ *
+ * @package Jetpack
+ */
+
+?>
<p>
- <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Widget Title', 'jetpack' ); ?></label>
+ <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>">
+ <?php esc_html_e( 'Widget Title', 'jetpack' ); ?>
+ </label>
<input
type="text"
class="widefat jetpack-simple-payments-widget-title"
@@ -8,30 +18,32 @@
value="<?php echo esc_attr( $instance['title'] ); ?>" />
</p>
<p class="jetpack-simple-payments-products-fieldset" <?php if ( empty( $product_posts ) ) { echo 'style="display:none;"'; } ?>>
- <label for="<?php echo $this->get_field_id('product_post_id'); ?>"><?php _e( 'Select a Simple Payment Button:', 'jetpack' ); ?></label>
+ <label for="<?php echo esc_attr( $this->get_field_id( 'product_post_id' ) ); ?>">
+ <?php esc_html_e( 'Select a Simple Payments Button:', 'jetpack' ); ?>
+ </label>
<select
class="widefat jetpack-simple-payments-products"
- id="<?php echo $this->get_field_id('product_post_id'); ?>"
- name="<?php echo $this->get_field_name('product_post_id'); ?>">
+ id="<?php echo esc_attr( $this->get_field_id( 'product_post_id' ) ); ?>"
+ name="<?php echo esc_attr( $this->get_field_name( 'product_post_id' ) ); ?>">
<?php foreach ( $product_posts as $product_post ) { ?>
- <option value="<?php echo esc_attr( $product_post->ID ) ?>" <?php selected( (int) $instance['product_post_id'], $product_post->ID ); ?>>
- <?php echo esc_attr( get_the_title( $product_post ) ) ?>
+ <option value="<?php echo esc_attr( $product_post->ID ); ?>" <?php selected( (int) $instance['product_post_id'], $product_post->ID ); ?>>
+ <?php echo esc_attr( get_the_title( $product_post ) ); ?>
</option>
<?php } ?>
</select>
</p>
<?php if ( is_customize_preview() ) { ?>
<p class="jetpack-simple-payments-products-warning" <?php if ( ! empty( $product_posts ) ) { echo 'style="display:none;"'; } ?>>
- <?php echo __( 'Looks like you don\'t have any products. You can create one using the Add New button below.' ) ?>
+ <?php esc_html_e( "Looks like you don't have any products. You can create one using the Add New button below.", 'jetpack' ); ?>
</p>
<p>
<div class="alignleft">
<button class="button jetpack-simple-payments-edit-product" <?php disabled( empty( $product_posts ), true ); ?>>
- <?php esc_html_e( 'Edit Selected' ); ?>
+ <?php esc_html_e( 'Edit Selected', 'jetpack' ); ?>
</button>
</div>
<div class="alignright">
- <button class="button jetpack-simple-payments-add-product"><?php esc_html_e( 'Add New' ); ?></button>
+ <button class="button jetpack-simple-payments-add-product"><?php esc_html_e( 'Add New', 'jetpack' ); ?></button>
</div>
<br class="clear">
</p>
@@ -39,14 +51,14 @@
<div class="jetpack-simple-payments-form" style="display: none;">
<input
type="hidden"
- id="<?php echo $this->get_field_id('form_action'); ?>"
- name="<?php echo $this->get_field_name('form_action'); ?>"
+ id="<?php echo esc_attr( $this->get_field_id( 'form_action' ) ); ?>"
+ name="<?php echo esc_attr( $this->get_field_name( 'form_action' ) ); ?>"
value="<?php echo esc_attr( $instance['form_action'] ); ?>"
class="jetpack-simple-payments-form-action" />
<input
type="hidden"
- id="<?php echo $this->get_field_id('form_product_id'); ?>"
- name="<?php echo $this->get_field_name('form_product_id'); ?>"
+ id="<?php echo esc_attr( $this->get_field_id( 'form_product_id' ) ); ?>"
+ name="<?php echo esc_attr( $this->get_field_name( 'form_product_id' ) ); ?>"
value="<?php echo esc_attr( $instance['form_product_id'] ); ?>"
class="jetpack-simple-payments-form-product-id" />
<input
@@ -62,7 +74,9 @@
value="<?php echo esc_attr( $instance['form_product_image_src'] ); ?>"
class="jetpack-simple-payments-form-image-src" />
<p>
- <label for="<?php echo esc_attr( $this->get_field_id( 'form_product_title' ) ); ?>"><?php esc_html_e( 'What is this payment for?' ); ?></label>
+ <label for="<?php echo esc_attr( $this->get_field_id( 'form_product_title' ) ); ?>">
+ <?php esc_html_e( 'What is this payment for?', 'jetpack' ); ?>
+ </label>
<input
type="text"
class="widefat field-title jetpack-simple-payments-form-product-title"
@@ -70,33 +84,41 @@
name="<?php echo esc_attr( $this->get_field_name( 'form_product_title' ) ); ?>"
value="<?php echo esc_attr( $instance['form_product_title'] ); ?>" />
<br />
- <small><?php _e( 'For example: event tickets, charitable donations, training courses, coaching fees, etc.' ); ?></small>
+ <small>
+ <?php esc_html_e( 'For example: event tickets, charitable donations, training courses, coaching fees, etc.', 'jetpack' ); ?>
+ </small>
</p>
<div class="jetpack-simple-payments-image-fieldset">
- <label><?php esc_html_e( 'Product image' ); ?></label>
- <div class="placeholder" <?php if ( ! empty( $instance['form_product_image_id'] ) ) echo 'style="display:none;"'; ?>><?php esc_html_e( 'Select an image' ); ?></div>
+ <label><?php esc_html_e( 'Product image', 'jetpack' ); ?></label>
+ <div class="placeholder" <?php if ( ! empty( $instance['form_product_image_id'] ) ) echo 'style="display:none;"'; ?>>
+ <?php esc_html_e( 'Select an image', 'jetpack' ); ?>
+ </div>
<div class="jetpack-simple-payments-image" <?php if ( empty( $instance['form_product_image_id'] ) ) echo 'style="display:none;"'; ?>>
<img src="<?php echo esc_url( $instance['form_product_image_src'] ); ?>" />
- <button class="button jetpack-simple-payments-remove-image"><?php esc_html_e( 'Remove image' ); ?></button>
+ <button class="button jetpack-simple-payments-remove-image"><?php esc_html_e( 'Remove image', 'jetpack' ); ?></button>
</div>
</div>
<p>
- <label for="<?php echo esc_attr( $this->get_field_id( 'form_product_description' ) ); ?>"><?php esc_html_e( 'Description' ); ?></label>
+ <label for="<?php echo esc_attr( $this->get_field_id( 'form_product_description' ) ); ?>">
+ <?php esc_html_e( 'Description', 'jetpack' ); ?>
+ </label>
<textarea
class="field-description widefat jetpack-simple-payments-form-product-description"
rows=5
id="<?php echo esc_attr( $this->get_field_id( 'form_product_description' ) ); ?>"
- name="<?php echo esc_attr( $this->get_field_name( 'form_product_description' ) ); ?>"><?php esc_html_e( $instance['form_product_description'] ); ?></textarea>
+ name="<?php echo esc_attr( $this->get_field_name( 'form_product_description' ) ); ?>"><?php echo esc_textarea( $instance['form_product_description'] ); ?></textarea>
</p>
<p class="cost">
- <label for="<?php echo esc_attr( $this->get_field_id( 'form_product_price' ) ); ?>"><?php esc_html_e( 'Price' ); ?></label>
+ <label for="<?php echo esc_attr( $this->get_field_id( 'form_product_price' ) ); ?>">
+ <?php esc_html_e( 'Price', 'jetpack' ); ?>
+ </label>
<select
class="field-currency widefat jetpack-simple-payments-form-product-currency"
id="<?php echo esc_attr( $this->get_field_id( 'form_product_currency' ) ); ?>"
name="<?php echo esc_attr( $this->get_field_name( 'form_product_currency' ) ); ?>">
- <?php foreach( Jetpack_Simple_Payments_Widget::$supported_currency_list as $code => $currency ) {?>
- <option value="<?php echo esc_attr( $code ) ?>"<?php selected( $instance['form_product_currency'], $code ); ?>>
- <?php esc_html_e( $code . ' ' . $currency ) ?>
+ <?php foreach ( Jetpack_Simple_Payments_Widget::$supported_currency_list as $code => $currency ) { ?>
+ <option value="<?php echo esc_attr( $code ); ?>"<?php selected( $instance['form_product_currency'], $code ); ?>>
+ <?php echo esc_html( "$code $currency" ); ?>
</option>
<?php } ?>
</select>
@@ -116,25 +138,48 @@
type="checkbox"
value="1"
<?php checked( $instance['form_product_multiple'], '1' ); ?> />
- <label for="<?php echo esc_attr( $this->get_field_id( 'form_product_multiple' ) ); ?>"><?php esc_html_e( 'Allow people to buy more than one item at a time.' ); ?></label>
+ <label for="<?php echo esc_attr( $this->get_field_id( 'form_product_multiple' ) ); ?>">
+ <?php esc_html_e( 'Allow people to buy more than one item at a time.', 'jetpack' ); ?>
+ </label>
</p>
<p>
- <label for="<?php echo esc_attr( $this->get_field_id( 'form_product_email' ) ); ?>"><?php esc_html_e( 'Email' ); ?></label>
+ <label for="<?php echo esc_attr( $this->get_field_id( 'form_product_email' ) ); ?>">
+ <?php esc_html_e( 'Email', 'jetpack' ); ?>
+ </label>
<input
class="field-email widefat jetpack-simple-payments-form-product-email"
id="<?php echo esc_attr( $this->get_field_id( 'form_product_email' ) ); ?>"
name="<?php echo esc_attr( $this->get_field_name( 'form_product_email' ) ); ?>"
type="email"
- value="<?php echo esc_attr( $instance['form_product_email'] ); ?>" />
- <small><?php printf( esc_html__( 'This is where PayPal will send your money. To claim a payment, you\'ll need a %1$sPayPal account%2$s connected to a bank account.' ), '<a href="https://paypal.com" target="_blank">', '</a>' ) ?></small>
+ value="<?php echo esc_attr( $instance['form_product_email'] ); ?>" />
+ <small>
+ <?php
+ printf(
+ wp_kses(
+ /* Translators: placeholders are a link to Paypal website and a target attribute. */
+ __( 'This is where PayPal will send your money. To claim a payment, you\'ll need a <a href="%1$s" %2$s>PayPal account</a> connected to a bank account.', 'jetpack' ),
+ array(
+ 'a' => array(
+ 'href' => array(),
+ 'target' => array(),
+ ),
+ )
+ ),
+ 'https://paypal.com',
+ 'target="_blank"'
+ );
+ ?>
+ </small>
</p>
<p>
<div class="alignleft">
- <button type="button" class="button-link button-link-delete jetpack-simple-payments-delete-product"><?php _e( 'Delete Product' ); ?></button>
+ <button type="button" class="button-link button-link-delete jetpack-simple-payments-delete-product">
+ <?php esc_html_e( 'Delete Product', 'jetpack' ); ?>
+ </button>
</div>
<div class="alignright">
- <button name="<?php echo $this->get_field_name('save'); ?>" class="button jetpack-simple-payments-save-product"><?php _e( 'Save' ); ?></button>
- <span> | <button type="button" class="button-link jetpack-simple-payments-cancel-form"><?php _e( 'Cancel' ); ?></button></span>
+ <button name="<?php echo esc_attr( $this->get_field_name( 'save' ) ); ?>" class="button jetpack-simple-payments-save-product"><?php esc_html_e( 'Save', 'jetpack' ); ?></button>
+ <span> | <button type="button" class="button-link jetpack-simple-payments-cancel-form"><?php esc_html_e( 'Cancel', 'jetpack' ); ?></button></span>
</div>
<br class="clear">
</p>
@@ -143,10 +188,15 @@
<?php } else { ?>
<p class="jetpack-simple-payments-products-warning">
<?php
- echo sprintf(
+ printf(
wp_kses(
- __( 'This widget adds a payment button of your choice to your sidebar. To create or edit the payment buttons themselves, <a href="%s">use the Customizer</a>.' ),
- array( 'a' => array( 'href' => array() ) )
+ /* Translators: placeholder is a link to the customizer. */
+ __( 'This widget adds a payment button of your choice to your sidebar. To create or edit the payment buttons themselves, <a href="%s">use the Customizer</a>.', 'jetpack' ),
+ array(
+ 'a' => array(
+ 'href' => array(),
+ ),
+ )
),
esc_url( add_query_arg( array( 'autofocus[panel]' => 'widgets' ), admin_url( 'customize.php' ) ) )
);
diff --git a/plugins/jetpack/modules/widgets/simple-payments/widget.php b/plugins/jetpack/modules/widgets/simple-payments/widget.php
index 740cbd74..001635ba 100644
--- a/plugins/jetpack/modules/widgets/simple-payments/widget.php
+++ b/plugins/jetpack/modules/widgets/simple-payments/widget.php
@@ -1,14 +1,22 @@
+<?php
+/**
+ * Display the Simple Payments Widget.
+ *
+ * @package Jetpack
+ */
+
+?>
<div class='jetpack-simple-payments-wrapper'>
<div class='jetpack-simple-payments-product'>
<div class='jetpack-simple-payments-product-image' <?php if ( empty( $instance['form_product_image_id'] ) ) echo 'style="display:none;"'; ?>>
<div class='jetpack-simple-payments-image'>
- <?php echo wp_get_attachment_image( $instance['form_product_image_id'], 'full' ) ?>
+ <?php echo wp_get_attachment_image( $instance['form_product_image_id'], 'full' ); ?>
</div>
</div>
<div class='jetpack-simple-payments-details'>
- <div class='jetpack-simple-payments-title'><p><?php esc_attr_e( $instance['form_product_title'] ); ?></p></div>
- <div class='jetpack-simple-payments-description'><p><?php esc_html_e( $instance['form_product_description'] ); ?></p></div>
- <div class='jetpack-simple-payments-price'><p><?php esc_attr_e( $instance['form_product_price'] ); ?> <?php esc_attr_e( $instance['form_product_currency'] ); ?></p></div>
+ <div class='jetpack-simple-payments-title'><p><?php echo esc_html( $instance['form_product_title'] ); ?></p></div>
+ <div class='jetpack-simple-payments-description'><p><?php echo esc_html( $instance['form_product_description'] ); ?></p></div>
+ <div class='jetpack-simple-payments-price'><p><?php echo esc_html( $instance['form_product_price'] ); ?> <?php echo esc_html( $instance['form_product_currency'] ); ?></p></div>
<div class='jetpack-simple-payments-purchase-box'>
<?php if ( $instance['form_product_multiple'] ) { ?>
<div class='jetpack-simple-payments-items'>
diff --git a/plugins/jetpack/modules/widgets/social-icons.php b/plugins/jetpack/modules/widgets/social-icons.php
index a2e02645..d70fb28e 100644
--- a/plugins/jetpack/modules/widgets/social-icons.php
+++ b/plugins/jetpack/modules/widgets/social-icons.php
@@ -116,14 +116,14 @@ class Jetpack_Widget_Social_Icons extends WP_Widget {
if ( ! empty( $instance['icons'] ) ) :
// Get supported social icons.
- $social_icons = $this->get_supported_icons();
- $default_icon = $this->get_svg_icon( array( 'icon' => 'chain' ) );
+ $social_icons = $this->get_supported_icons();
+ $default_icon = $this->get_svg_icon( array( 'icon' => 'chain' ) );
// Set target attribute for the link
if ( true === $instance['new-tab'] ) {
$target = '_blank';
} else {
- $target = '_self';
+ $target = '_self';
}
?>
@@ -137,18 +137,18 @@ class Jetpack_Widget_Social_Icons extends WP_Widget {
<?php
$found_icon = false;
- foreach( $social_icons as $social_icon ) {
- if ( false !== stripos( $icon['url'], $social_icon['url'] ) ) {
- echo '<span class="screen-reader-text">' . esc_attr( $social_icon['label'] ) . '</span>';
- echo $this->get_svg_icon( array( 'icon' => esc_attr( $social_icon['icon'] ) ) );
- $found_icon = true;
- break;
- }
+ foreach ( $social_icons as $social_icon ) {
+ if ( false !== stripos( $icon['url'], $social_icon['url'] ) ) {
+ echo '<span class="screen-reader-text">' . esc_attr( $social_icon['label'] ) . '</span>';
+ echo $this->get_svg_icon( array( 'icon' => esc_attr( $social_icon['icon'] ) ) );
+ $found_icon = true;
+ break;
}
+ }
- if ( ! $found_icon ) {
- echo $default_icon;
- }
+ if ( ! $found_icon ) {
+ echo $default_icon;
+ }
?>
</a>
</li>
@@ -189,7 +189,7 @@ class Jetpack_Widget_Social_Icons extends WP_Widget {
$icon_count = count( $new_instance['url-icons'] );
$instance['icons'] = array();
- foreach( $new_instance['url-icons'] as $url ) {
+ foreach ( $new_instance['url-icons'] as $url ) {
$url = filter_var( $url, FILTER_SANITIZE_URL );
if ( ! empty( $url ) ) {
@@ -242,13 +242,15 @@ class Jetpack_Widget_Social_Icons extends WP_Widget {
>
<?php
- foreach ( $instance['icons'] as $icon ) {
- self::render_icons_template( array(
+ foreach ( $instance['icons'] as $icon ) {
+ self::render_icons_template(
+ array(
'url-icon-id' => $this->get_field_id( 'url-icons' ),
'url-icon-name' => $this->get_field_name( 'url-icons' ),
'url-value' => $icon['url'],
- ) );
- }
+ )
+ );
+ }
?>
</div>
@@ -260,18 +262,18 @@ class Jetpack_Widget_Social_Icons extends WP_Widget {
</p>
<?php
- switch ( get_locale() ) {
- case 'es':
- $support = 'https://es.support.wordpress.com/social-media-icons-widget/#iconos-disponibles';
- break;
+ switch ( get_locale() ) {
+ case 'es':
+ $support = 'https://es.support.wordpress.com/social-media-icons-widget/#iconos-disponibles';
+ break;
- case 'pt-br':
- $support = 'https://br.support.wordpress.com/widgets/widget-de-icones-sociais/#ícones-disponíveis';
- break;
+ case 'pt-br':
+ $support = 'https://br.support.wordpress.com/widgets/widget-de-icones-sociais/#ícones-disponíveis';
+ break;
- default:
- $support = 'https://en.support.wordpress.com/widgets/social-media-icons-widget/#available-icons';
- }
+ default:
+ $support = 'https://en.support.wordpress.com/widgets/social-media-icons-widget/#available-icons';
+ }
?>
<p>
@@ -309,7 +311,8 @@ class Jetpack_Widget_Social_Icons extends WP_Widget {
<p class="jetpack-widget-social-icons-url">
<?php
- printf( '<input class="widefat id="%1$s" name="%2$s[]" type="text" placeholder="%3$s" value="%4$s"/>',
+ printf(
+ '<input class="widefat id="%1$s" name="%2$s[]" type="text" placeholder="%3$s" value="%4$s"/>',
esc_attr( $args['url-icon-id'] ),
esc_attr( $args['url-icon-name'] ),
esc_attr__( 'Account URL', 'jetpack' ),
diff --git a/plugins/jetpack/modules/widgets/social-media-icons.php b/plugins/jetpack/modules/widgets/social-media-icons.php
index a2f3cbd4..0e8028ef 100644
--- a/plugins/jetpack/modules/widgets/social-media-icons.php
+++ b/plugins/jetpack/modules/widgets/social-media-icons.php
@@ -47,7 +47,7 @@ class WPCOM_social_media_icons_widget extends WP_Widget {
/** This filter is documented in modules/widgets/facebook-likebox.php */
apply_filters( 'jetpack_widget_name', esc_html__( 'Social Media Icons (Deprecated)', 'jetpack' ) ),
array(
- 'description' => __( 'A simple widget that displays social media icons.', 'jetpack' ),
+ 'description' => __( 'A simple widget that displays social media icons.', 'jetpack' ),
'customize_selective_refresh' => true,
)
);
@@ -129,8 +129,8 @@ class WPCOM_social_media_icons_widget extends WP_Widget {
if ( ! $this->check_genericons() ) {
wp_enqueue_style( 'genericons' );
}
- $index = 10;
- $html = array();
+ $index = 10;
+ $html = array();
$alt_text = esc_attr__( 'View %1$s&#8217;s profile on %2$s', 'jetpack' );
foreach ( $this->services as $service => $data ) {
list( $service_name, $url ) = $data;
@@ -141,7 +141,7 @@ class WPCOM_social_media_icons_widget extends WP_Widget {
if ( empty( $username ) ) {
continue;
}
- $index += 10;
+ $index += 10;
$predefined_url = false;
/** Check if full URL entered in configuration, use it instead of tinkering **/
@@ -158,7 +158,6 @@ class WPCOM_social_media_icons_widget extends WP_Widget {
$alt_text = '%2$s';
}
-
if ( 'googleplus' === $service
&& ! is_numeric( $username )
&& substr( $username, 0, 1 ) !== '+'
@@ -167,7 +166,7 @@ class WPCOM_social_media_icons_widget extends WP_Widget {
}
if ( 'youtube' === $service && 'UC' === substr( $username, 0, 2 ) ) {
$link_username = 'channel/' . $username;
- } else if ( 'youtube' === $service ) {
+ } elseif ( 'youtube' === $service ) {
$link_username = 'user/' . $username;
}
@@ -186,7 +185,7 @@ class WPCOM_social_media_icons_widget extends WP_Widget {
* @param string $url the currently processed URL
* @param string $service the lowercase service slug, e.g. 'facebook', 'youtube', etc.
*/
- $link = apply_filters(
+ $link = apply_filters(
'jetpack_social_media_icons_widget_profile_link',
$predefined_url,
$service
@@ -330,7 +329,7 @@ class WPCOM_social_media_icons_widget extends WP_Widget {
* @return void
*/
function wpcom_social_media_icons_widget_load_widget() {
- $transient = 'wpcom_social_media_icons_widget::is_active';
+ $transient = 'wpcom_social_media_icons_widget::is_active';
$has_widget = get_transient( $transient );
if ( false === $has_widget ) {
diff --git a/plugins/jetpack/modules/widgets/top-posts.php b/plugins/jetpack/modules/widgets/top-posts.php
index f581741c..ab2ffd2e 100644
--- a/plugins/jetpack/modules/widgets/top-posts.php
+++ b/plugins/jetpack/modules/widgets/top-posts.php
@@ -27,7 +27,7 @@ function jetpack_top_posts_widget_init() {
class Jetpack_Top_Posts_Widget extends WP_Widget {
public $alt_option_name = 'widget_stats_topposts';
- public $default_title = '';
+ public $default_title = '';
function __construct() {
parent::__construct(
@@ -35,12 +35,12 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
/** This filter is documented in modules/widgets/facebook-likebox.php */
apply_filters( 'jetpack_widget_name', __( 'Top Posts &amp; Pages', 'jetpack' ) ),
array(
- 'description' => __( 'Shows your most viewed posts and pages.', 'jetpack' ),
+ 'description' => __( 'Shows your most viewed posts and pages.', 'jetpack' ),
'customize_selective_refresh' => true,
)
);
- $this->default_title = __( 'Top Posts &amp; Pages', 'jetpack' );
+ $this->default_title = __( 'Top Posts &amp; Pages', 'jetpack' );
if ( is_active_widget( false, false, $this->id_base ) || is_customize_preview() ) {
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ) );
@@ -75,12 +75,12 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
}
$allowed_post_types = array_values( get_post_types( array( 'public' => true ) ) );
- $types = isset( $instance['types'] ) ? (array) $instance['types'] : array( 'post', 'page' );
+ $types = isset( $instance['types'] ) ? (array) $instance['types'] : array( 'post', 'page' );
// 'likes' are not available in Jetpack
$ordering = isset( $instance['ordering'] ) && 'likes' === $instance['ordering'] ? 'likes' : 'views';
- if ( isset( $instance['display'] ) && in_array( $instance['display'], array( 'grid', 'list', 'text' ) ) ) {
+ if ( isset( $instance['display'] ) && in_array( $instance['display'], array( 'grid', 'list', 'text' ) ) ) {
$display = $instance['display'];
} else {
$display = 'text';
@@ -111,15 +111,17 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
<p>
<label for="<?php echo $this->get_field_id( 'types' ); ?>"><?php esc_html_e( 'Types of pages to display:', 'jetpack' ); ?></label>
<ul>
- <?php foreach( $allowed_post_types as $type ) {
+ <?php
+ foreach ( $allowed_post_types as $type ) {
// Get the Post Type name to display next to the checkbox
$post_type_object = get_post_type_object( $type );
- $label = $post_type_object->labels->name;
+ $label = $post_type_object->labels->name;
$checked = '';
if ( in_array( $type, $types ) ) {
$checked = 'checked="checked" ';
- } ?>
+ }
+ ?>
<li><label>
<input value="<?php echo esc_attr( $type ); ?>" name="<?php echo $this->get_field_name( 'types' ); ?>[]" id="<?php echo $this->get_field_id( 'types' ); ?>-<?php echo $type; ?>" type="checkbox" <?php echo $checked; ?>>
@@ -137,7 +139,8 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
<li><label><input id="<?php echo $this->get_field_id( 'display' ); ?>-list" name="<?php echo $this->get_field_name( 'display' ); ?>" type="radio" value="list" <?php checked( 'list', $display ); ?> /> <?php esc_html_e( 'Image List', 'jetpack' ); ?></label></li>
<li><label><input id="<?php echo $this->get_field_id( 'display' ); ?>-grid" name="<?php echo $this->get_field_name( 'display' ); ?>" type="radio" value="grid" <?php checked( 'grid', $display ); ?> /> <?php esc_html_e( 'Image Grid', 'jetpack' ); ?></label></li>
</ul>
- </p><?php
+ </p>
+ <?php
/**
* Fires after the fields are displayed in the Top Posts Widget settings in wp-admin.
@@ -162,11 +165,12 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
function stats_explanation() {
?>
- <p><?php esc_html_e( 'Top Posts &amp; Pages by views are calculated from 24-48 hours of stats. They take a while to change.', 'jetpack' ); ?></p><?php
+ <p><?php esc_html_e( 'Top Posts &amp; Pages by views are calculated from 24-48 hours of stats. They take a while to change.', 'jetpack' ); ?></p>
+ <?php
}
function update( $new_instance, $old_instance ) {
- $instance = array();
+ $instance = array();
$instance['title'] = wp_kses( $new_instance['title'], array() );
if ( $instance['title'] === $this->default_title ) {
$instance['title'] = false; // Store as false in case of language change
@@ -181,14 +185,14 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
$instance['ordering'] = isset( $new_instance['ordering'] ) && 'likes' == $new_instance['ordering'] ? 'likes' : 'views';
$allowed_post_types = array_values( get_post_types( array( 'public' => true ) ) );
- $instance['types'] = $new_instance['types'];
- foreach( $new_instance['types'] as $key => $type ) {
+ $instance['types'] = $new_instance['types'];
+ foreach ( $new_instance['types'] as $key => $type ) {
if ( ! in_array( $type, $allowed_post_types ) ) {
unset( $new_instance['types'][ $key ] );
}
}
- if ( isset( $new_instance['display'] ) && in_array( $new_instance['display'], array( 'grid', 'list', 'text' ) ) ) {
+ if ( isset( $new_instance['display'] ) && in_array( $new_instance['display'], array( 'grid', 'list', 'text' ) ) ) {
$instance['display'] = $new_instance['display'];
} else {
$instance['display'] = 'text';
@@ -215,7 +219,7 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
$instance = wp_parse_args( (array) $instance, $this->defaults() );
- $title = isset( $instance['title' ] ) ? $instance['title'] : false;
+ $title = isset( $instance['title'] ) ? $instance['title'] : false;
if ( false === $title ) {
$title = $this->default_title;
}
@@ -242,7 +246,7 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
// 'likes' are not available in Jetpack
$ordering = isset( $instance['ordering'] ) && 'likes' == $instance['ordering'] ? 'likes' : 'views';
- if ( isset( $instance['display'] ) && in_array( $instance['display'], array( 'grid', 'list', 'text' ) ) ) {
+ if ( isset( $instance['display'] ) && in_array( $instance['display'], array( 'grid', 'list', 'text' ) ) ) {
$display = $instance['display'];
} else {
$display = 'text';
@@ -252,10 +256,10 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
$get_image_options = array(
'fallback_to_avatars' => true,
/** This filter is documented in modules/stats.php */
- 'gravatar_default' => apply_filters( 'jetpack_static_url', set_url_scheme( 'https://en.wordpress.com/i/logo/white-gray-80.png' ) ),
- 'avatar_size' => 40,
- 'width' => null,
- 'height' => null,
+ 'gravatar_default' => apply_filters( 'jetpack_static_url', set_url_scheme( 'https://en.wordpress.com/i/logo/white-gray-80.png' ) ),
+ 'avatar_size' => 40,
+ 'width' => null,
+ 'height' => null,
);
if ( 'grid' == $display ) {
$get_image_options['avatar_size'] = 200;
@@ -289,7 +293,7 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
if ( isset( $types ) ) {
foreach ( $posts as $k => $post ) {
if ( ! in_array( $post['post_type'], $types ) ) {
- unset( $posts[$k] );
+ unset( $posts[ $k ] );
}
}
}
@@ -299,8 +303,9 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
}
echo $args['before_widget'];
- if ( ! empty( $title ) )
+ if ( ! empty( $title ) ) {
echo $args['before_title'] . $title . $args['after_title'];
+ }
if ( ! $posts ) {
$link = 'https://jetpack.com/support/getting-more-views-and-traffic/';
@@ -319,45 +324,63 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
return;
}
+ /**
+ * Filter the layout of the Top Posts Widget
+ *
+ * @module widgets
+ *
+ * @since 6.4.0
+ *
+ * @param string $layout layout of the Top Posts Widget (empty string)
+ * @param array $posts IDs of the posts to be displayed
+ * @param array $display Display option from widget form
+ */
+ $layout = apply_filters( 'jetpack_top_posts_widget_layout', '', $posts, $display );
+ if ( ! empty( $layout ) ) {
+ echo $layout;
+ echo $args['after_widget'];
+ return;
+ }
+
switch ( $display ) {
- case 'list' :
- case 'grid' :
- // Keep the avatar_size as default dimensions for backward compatibility.
- $width = (int) $get_image_options['avatar_size'];
- $height = (int) $get_image_options['avatar_size'];
-
- // Check if the user has changed the width.
- if ( ! empty( $get_image_options['width'] ) ) {
- $width = (int) $get_image_options['width'];
- }
+ case 'list':
+ case 'grid':
+ // Keep the avatar_size as default dimensions for backward compatibility.
+ $width = (int) $get_image_options['avatar_size'];
+ $height = (int) $get_image_options['avatar_size'];
+
+ // Check if the user has changed the width.
+ if ( ! empty( $get_image_options['width'] ) ) {
+ $width = (int) $get_image_options['width'];
+ }
- // Check if the user has changed the height.
- if ( ! empty( $get_image_options['height'] ) ) {
- $height = (int) $get_image_options['height'];
- }
+ // Check if the user has changed the height.
+ if ( ! empty( $get_image_options['height'] ) ) {
+ $height = (int) $get_image_options['height'];
+ }
- foreach ( $posts as &$post ) {
- $image = Jetpack_PostImages::get_image(
- $post['post_id'],
- array(
- 'fallback_to_avatars' => true,
- 'width' => (int) $width,
- 'height' => (int) $height,
- 'avatar_size' => (int) $get_image_options['avatar_size'],
- )
- );
- $post['image'] = $image['src'];
- if ( 'blavatar' != $image['from'] && 'gravatar' != $image['from'] ) {
- $post['image'] = jetpack_photon_url( $post['image'], array( 'resize' => "$width,$height" ) );
+ foreach ( $posts as &$post ) {
+ $image = Jetpack_PostImages::get_image(
+ $post['post_id'],
+ array(
+ 'fallback_to_avatars' => true,
+ 'width' => (int) $width,
+ 'height' => (int) $height,
+ 'avatar_size' => (int) $get_image_options['avatar_size'],
+ )
+ );
+ $post['image'] = $image['src'];
+ if ( 'blavatar' != $image['from'] && 'gravatar' != $image['from'] ) {
+ $post['image'] = jetpack_photon_url( $post['image'], array( 'resize' => "$width,$height" ) );
+ }
}
- }
- unset( $post );
+ unset( $post );
- if ( 'grid' == $display ) {
- echo "<div class='widgets-grid-layout no-grav'>\n";
- foreach ( $posts as $post ) :
- ?>
+ if ( 'grid' == $display ) {
+ echo "<div class='widgets-grid-layout no-grav'>\n";
+ foreach ( $posts as $post ) :
+ ?>
<div class="widget-grid-view-image">
<?php
/**
@@ -399,14 +422,14 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
*/
do_action( 'jetpack_widget_top_posts_after_post', $post['post_id'] );
?>
- </div>
- <?php
- endforeach;
- echo "</div>\n";
- } else {
- echo "<ul class='widgets-list-layout no-grav'>\n";
- foreach ( $posts as $post ) :
- ?>
+ </div>
+ <?php
+ endforeach;
+ echo "</div>\n";
+ } else {
+ echo "<ul class='widgets-list-layout no-grav'>\n";
+ foreach ( $posts as $post ) :
+ ?>
<li>
<?php
/** This action is documented in modules/widgets/top-posts.php */
@@ -427,16 +450,16 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
/** This action is documented in modules/widgets/top-posts.php */
do_action( 'jetpack_widget_top_posts_after_post', $post['post_id'] );
?>
- </li>
- <?php
- endforeach;
- echo "</ul>\n";
- }
- break;
- default :
- echo '<ul>';
- foreach ( $posts as $post ) :
- ?>
+ </li>
+ <?php
+ endforeach;
+ echo "</ul>\n";
+ }
+ break;
+ default:
+ echo '<ul>';
+ foreach ( $posts as $post ) :
+ ?>
<li>
<?php
/** This action is documented in modules/widgets/top-posts.php */
@@ -452,10 +475,10 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
/** This action is documented in modules/widgets/top-posts.php */
do_action( 'jetpack_widget_top_posts_after_post', $post['post_id'] );
?>
- </li>
- <?php
- endforeach;
- echo '</ul>';
+ </li>
+ <?php
+ endforeach;
+ echo '</ul>';
}
echo $args['after_widget'];
@@ -478,7 +501,7 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
*/
function get_by_likes( $count ) {
$post_likes = wpl_get_blogs_most_liked_posts();
- if ( !$post_likes ) {
+ if ( ! $post_likes ) {
return array();
}
@@ -493,7 +516,7 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
if ( false === $post_views ) {
$post_views = array_shift( stats_get_daily_history( false, get_current_blog_id(), 'postviews', 'post_id', false, 2, '', $count * 2 + 10, true ) );
unset( $post_views[0] );
- wp_cache_add( "get_top_posts_$count", $post_views, 'stats', 1200);
+ wp_cache_add( "get_top_posts_$count", $post_views, 'stats', 1200 );
}
return $this->get_posts( array_keys( $post_views ), $count );
@@ -541,12 +564,14 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
$post_query = new WP_Query;
- $posts = $post_query->query( array(
- 'posts_per_page' => 1,
- 'post_status' => 'publish',
- 'post_type' => array( 'post', 'page' ),
- 'no_found_rows' => true,
- ) );
+ $posts = $post_query->query(
+ array(
+ 'posts_per_page' => 1,
+ 'post_status' => 'publish',
+ 'post_type' => array( 'post', 'page' ),
+ 'no_found_rows' => true,
+ )
+ );
if ( ! $posts ) {
return array();
@@ -585,8 +610,8 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
// Both get HTML stripped etc on display
if ( empty( $post->post_title ) ) {
$title_source = $post->post_content;
- $title = wp_html_excerpt( $title_source, 50 );
- $title .= '&hellip;';
+ $title = wp_html_excerpt( $title_source, 50 );
+ $title .= '&hellip;';
} else {
$title = $post->post_title;
}
diff --git a/plugins/jetpack/modules/widgets/twitter-timeline.php b/plugins/jetpack/modules/widgets/twitter-timeline.php
index 60500676..d9c8c947 100644
--- a/plugins/jetpack/modules/widgets/twitter-timeline.php
+++ b/plugins/jetpack/modules/widgets/twitter-timeline.php
@@ -27,8 +27,8 @@ class Jetpack_Twitter_Timeline_Widget extends WP_Widget {
/** This filter is documented in modules/widgets/facebook-likebox.php */
apply_filters( 'jetpack_widget_name', esc_html__( 'Twitter Timeline', 'jetpack' ) ),
array(
- 'classname' => 'widget_twitter_timeline',
- 'description' => __( 'Display an official Twitter Embedded Timeline widget.', 'jetpack' ),
+ 'classname' => 'widget_twitter_timeline',
+ 'description' => __( 'Display an official Twitter Embedded Timeline widget.', 'jetpack' ),
'customize_selective_refresh' => true,
)
);
@@ -84,8 +84,7 @@ class Jetpack_Twitter_Timeline_Widget extends WP_Widget {
public function widget( $args, $instance ) {
// Twitter deprecated `data-widget-id` on 2018-05-25,
// with cease support deadline on 2018-07-27.
- // 1532563200 is 2018-07-26, one day early.
- if ( 'widget-id' === $instance['type'] && time() > 1532563200 ) {
+ if ( isset( $instance['type'] ) && 'widget-id' === $instance['type'] ) {
if ( current_user_can( 'edit_theme_options' ) ) {
echo $args['before_widget'];
echo $args['before_title'] . esc_html__( 'Twitter Timeline', 'jetpack' ) . $args['after_title'];
@@ -108,7 +107,7 @@ class Jetpack_Twitter_Timeline_Widget extends WP_Widget {
echo $args['before_title'] . $title . $args['after_title'];
}
- if ( 'widget-id' === $instance['type'] && current_user_can( 'edit_theme_options' ) ) {
+ if ( isset( $instance['type'] ) && 'widget-id' === $instance['type'] && current_user_can( 'edit_theme_options' ) ) {
echo '<p>' . esc_html__( 'As of July 27, 2018, the Twitter Timeline widget will no longer display tweets based on searches or hashtags. To display a simple list of tweets instead, change the Widget ID to a Twitter username.', 'jetpack' ) . '</p>';
echo '<p>' . esc_html__( '(Only administrators will see this message.)', 'jetpack' ) . '</p>';
}
@@ -125,7 +124,7 @@ class Jetpack_Twitter_Timeline_Widget extends WP_Widget {
'link-color',
'border-color',
'tweet-limit',
- 'lang'
+ 'lang',
);
foreach ( $data_attribs as $att ) {
if ( ! empty( $instance[ $att ] ) && ! is_array( $instance[ $att ] ) ) {
@@ -247,7 +246,6 @@ class Jetpack_Twitter_Timeline_Widget extends WP_Widget {
if ( preg_match( $hex_regex, $new_color ) ) {
$instance[ $color ] = $new_color;
}
-
}
$instance['type'] = 'profile';
@@ -258,7 +256,7 @@ class Jetpack_Twitter_Timeline_Widget extends WP_Widget {
}
$instance['chrome'] = array();
- $chrome_settings = array(
+ $chrome_settings = array(
'noheader',
'nofooter',
'noborders',
@@ -277,9 +275,9 @@ class Jetpack_Twitter_Timeline_Widget extends WP_Widget {
}
/**
- * Returns a link to the documentation for a feature of this widget on
- * Jetpack or WordPress.com.
- */
+ * Returns a link to the documentation for a feature of this widget on
+ * Jetpack or WordPress.com.
+ */
public function get_docs_link( $hash = '' ) {
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
$base_url = 'https://support.wordpress.com/widgets/twitter-timeline-widget/';
diff --git a/plugins/jetpack/modules/widgets/upcoming-events.php b/plugins/jetpack/modules/widgets/upcoming-events.php
index c3b671be..36a0257e 100644
--- a/plugins/jetpack/modules/widgets/upcoming-events.php
+++ b/plugins/jetpack/modules/widgets/upcoming-events.php
@@ -7,7 +7,7 @@ class Jetpack_Upcoming_Events_Widget extends WP_Widget {
/** This filter is documented in modules/widgets/facebook-likebox.php */
apply_filters( 'jetpack_widget_name', __( 'Upcoming Events', 'jetpack' ) ),
array(
- 'description' => __( 'Display upcoming events from an iCalendar feed.', 'jetpack' ),
+ 'description' => __( 'Display upcoming events from an iCalendar feed.', 'jetpack' ),
'customize_selective_refresh' => true,
)
);
@@ -31,9 +31,9 @@ class Jetpack_Upcoming_Events_Widget extends WP_Widget {
function form( $instance ) {
$defaults = array(
- 'title' => __( 'Upcoming Events', 'jetpack' ),
+ 'title' => __( 'Upcoming Events', 'jetpack' ),
'feed-url' => '',
- 'count' => 3
+ 'count' => 3,
);
$instance = array_merge( $defaults, (array) $instance );
?>
@@ -51,29 +51,31 @@ class Jetpack_Upcoming_Events_Widget extends WP_Widget {
<p>
<label for="<?php echo $this->get_field_id( 'count' ); ?>"><?php _e( 'Items to show:', 'jetpack' ); ?></label>
<select id="<?php echo $this->get_field_id( 'count' ); ?>" name="<?php echo $this->get_field_name( 'count' ); ?>">
- <?php $i = 1;
- while ( $i <= 10 ) { ?>
- <option <?php selected( $instance['count'], $i ) ?>><?php echo $i; ?></option>
+ <?php
+ $i = 1;
+ while ( $i <= 10 ) {
+ ?>
+ <option <?php selected( $instance['count'], $i ); ?>><?php echo $i; ?></option>
<?php $i++; } ?>
- <option value="0" <?php selected( $instance['count'], 0 ) ?>><?php _e( 'All' , 'jetpack' ) ?></option>
+ <option value="0" <?php selected( $instance['count'], 0 ); ?>><?php _e( 'All', 'jetpack' ); ?></option>
</select>
</p>
<?php
}
function update( $new_instance, $old_instance ) {
- $instance['title'] = strip_tags( $new_instance['title'] );
+ $instance['title'] = strip_tags( $new_instance['title'] );
$instance['feed-url'] = strip_tags( $new_instance['feed-url'] );
- $instance['count'] = min( absint( $new_instance['count'] ), 10 ); // 10 or less
+ $instance['count'] = min( absint( $new_instance['count'] ), 10 ); // 10 or less
return $instance;
}
function widget( $args, $instance ) {
jetpack_require_lib( 'icalendar-reader' );
- $ical = new iCalendarReader();
- $events = $ical->get_events( $instance['feed-url'], $instance['count'] );
- $events = $this->apply_timezone_offset( $events );
+ $ical = new iCalendarReader();
+ $events = $ical->get_events( $instance['feed-url'], $instance['count'] );
+ $events = $this->apply_timezone_offset( $events );
$ical->timezone = null;
echo $args['before_widget'];
@@ -85,7 +87,7 @@ class Jetpack_Upcoming_Events_Widget extends WP_Widget {
if ( ! $events ) : // nothing to display?
?>
- <p><?php echo __( 'No upcoming events', 'jetpack' ) ?></p>
+ <p><?php echo __( 'No upcoming events', 'jetpack' ); ?></p>
<?php
else :
?>
diff --git a/plugins/jetpack/modules/widgets/wordpress-post-widget.php b/plugins/jetpack/modules/widgets/wordpress-post-widget.php
index bb465285..f518ad61 100644
--- a/plugins/jetpack/modules/widgets/wordpress-post-widget.php
+++ b/plugins/jetpack/modules/widgets/wordpress-post-widget.php
@@ -45,7 +45,7 @@ function jetpack_display_posts_widget_cron_intervals( $current_schedules ) {
if ( ! isset( $current_schedules['minutes_10'] ) ) {
$current_schedules['minutes_10'] = array(
'interval' => 10 * MINUTE_IN_SECONDS,
- 'display' => 'Every 10 minutes'
+ 'display' => 'Every 10 minutes',
);
}