summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/modules/widgets')
-rw-r--r--plugins/jetpack/modules/widgets/authors.php41
-rw-r--r--plugins/jetpack/modules/widgets/contact-info.php298
-rw-r--r--plugins/jetpack/modules/widgets/contact-info/contact-info-admin.js48
-rw-r--r--plugins/jetpack/modules/widgets/contact-info/contact-info-map.css9
-rw-r--r--plugins/jetpack/modules/widgets/eu-cookie-law.php6
-rw-r--r--plugins/jetpack/modules/widgets/facebook-likebox.php6
-rw-r--r--plugins/jetpack/modules/widgets/flickr.php14
-rw-r--r--plugins/jetpack/modules/widgets/flickr/form.php12
-rw-r--r--plugins/jetpack/modules/widgets/gallery.php8
-rw-r--r--plugins/jetpack/modules/widgets/gallery/js/admin.js1
-rw-r--r--plugins/jetpack/modules/widgets/goodreads.php2
-rw-r--r--plugins/jetpack/modules/widgets/google-translate.php9
-rw-r--r--plugins/jetpack/modules/widgets/gravatar-profile.php2
-rw-r--r--plugins/jetpack/modules/widgets/image-widget.php6
-rw-r--r--plugins/jetpack/modules/widgets/milestone/milestone.php10
-rw-r--r--plugins/jetpack/modules/widgets/search.php14
-rw-r--r--plugins/jetpack/modules/widgets/simple-payments.php19
-rw-r--r--plugins/jetpack/modules/widgets/social-icons.php279
-rw-r--r--plugins/jetpack/modules/widgets/social-media-icons.php2
-rw-r--r--plugins/jetpack/modules/widgets/top-posts.php58
-rw-r--r--plugins/jetpack/modules/widgets/twitter-timeline.php4
-rw-r--r--plugins/jetpack/modules/widgets/wordpress-post-widget.php2
-rw-r--r--plugins/jetpack/modules/widgets/wordpress-post-widget/class.jetpack-display-posts-widget.php4
-rw-r--r--plugins/jetpack/modules/widgets/wordpress-post-widget/style.css9
24 files changed, 542 insertions, 321 deletions
diff --git a/plugins/jetpack/modules/widgets/authors.php b/plugins/jetpack/modules/widgets/authors.php
index dfc78652..741856d8 100644
--- a/plugins/jetpack/modules/widgets/authors.php
+++ b/plugins/jetpack/modules/widgets/authors.php
@@ -78,26 +78,41 @@ class Jetpack_Widget_Authors extends WP_Widget {
// We need to query at least one post to determine whether an author has written any posts or not
$query_number = max( $instance['number'], 1 );
- $default_excluded_authors = array();
/**
* Filter authors from the Widget Authors widget.
*
* @module widgets
*
+ * @deprecated 7.7.0 Use jetpack_widget_authors_params instead.
+ *
* @since 4.5.0
*
* @param array $default_excluded_authors Array of user ID's that will be excluded
*/
- $excluded_authors = apply_filters( 'jetpack_widget_authors_exclude', $default_excluded_authors );
+ $excluded_authors = apply_filters( 'jetpack_widget_authors_exclude', array() );
- $authors = get_users(
+ /**
+ * Filter the parameters of `get_users` call in the Widget Authors widget.
+ *
+ * See the following for `get_users` default arguments:
+ * https://codex.wordpress.org/Function_Reference/get_users
+ *
+ * @module widgets
+ *
+ * @since 7.7.0
+ *
+ * @param array $get_author_params Array of params used in `get_user`
+ */
+ $get_author_params = apply_filters(
+ 'jetpack_widget_authors_params',
array(
- 'fields' => 'all',
'who' => 'authors',
'exclude' => (array) $excluded_authors,
)
);
+ $authors = get_users( $get_author_params );
+
echo $args['before_widget'];
/** This filter is documented in core/src/wp-includes/default-widgets.php */
$title = apply_filters( 'widget_title', $instance['title'] );
@@ -157,22 +172,20 @@ class Jetpack_Widget_Authors extends WP_Widget {
continue;
}
- // Display a short list of recent posts for this author
-
+ // Display a short list of recent posts for this author.
if ( $r->have_posts() ) {
echo '<ul>';
while ( $r->have_posts() ) {
$r->the_post();
- echo '<li><a href="' . get_permalink() . '">';
-
- if ( get_the_title() ) {
- echo get_the_title();
- } else {
- echo get_the_ID();
- }
- echo '</a></li>';
+ printf(
+ '<li><a href="%1$s" title="%2$s"%3$s>%4$s</a></li>',
+ esc_url( get_permalink() ),
+ esc_attr( wp_kses( get_the_title(), array() ) ),
+ ( get_queried_object_id() === get_the_ID() ? ' aria-current="page"' : '' ),
+ esc_html( wp_kses( get_the_title(), array() ) )
+ );
}
echo '</ul>';
diff --git a/plugins/jetpack/modules/widgets/contact-info.php b/plugins/jetpack/modules/widgets/contact-info.php
index 93b4695b..761c7b02 100644
--- a/plugins/jetpack/modules/widgets/contact-info.php
+++ b/plugins/jetpack/modules/widgets/contact-info.php
@@ -1,8 +1,12 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+
+use Automattic\Jetpack\Assets;
if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) {
- //register Contact_Info_Widget widget
+ /**
+ * Register Contact_Info_Widget widget
+ */
function jetpack_contact_info_widget_init() {
register_widget( 'Jetpack_Contact_Info_Widget' );
}
@@ -19,7 +23,9 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) {
/**
* Constructor
*/
- function __construct() {
+ public function __construct() {
+ global $pagenow;
+
$widget_ops = array(
'classname' => 'widget_contact_info',
'description' => __( 'Display a map with your location, hours, and contact information.', 'jetpack' ),
@@ -35,14 +41,23 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) {
if ( is_customize_preview() ) {
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
+ } elseif ( 'widgets.php' === $pagenow ) {
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
}
+
+ add_action( 'wp_ajax_customize-contact-info-api-key', array( $this, 'ajax_check_api_key' ) );
}
/**
* Enqueue scripts and styles.
*/
public function enqueue_scripts() {
- wp_enqueue_style( 'contact-info-map-css', plugins_url( 'contact-info/contact-info-map.css', __FILE__ ), null, 20160623 );
+ wp_enqueue_style(
+ 'contact-info-map-css',
+ plugins_url( 'contact-info/contact-info-map.css', __FILE__ ),
+ array(),
+ JETPACK__VERSION
+ );
}
@@ -62,26 +77,25 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) {
'email' => null,
'showmap' => 0,
'apikey' => null,
- 'lat' => null,
- 'lon' => null,
+ 'goodmap' => null,
);
}
/**
* Outputs the HTML for this widget.
*
- * @param array $args An array of standard parameters for widgets in this theme
- * @param array $instance An array of settings for this widget instance
+ * @param array $args An array of standard parameters for widgets in this theme.
+ * @param array $instance An array of settings for this widget instance.
*
* @return void Echoes it's output
**/
- function widget( $args, $instance ) {
+ public function widget( $args, $instance ) {
$instance = wp_parse_args( $instance, $this->defaults() );
- echo $args['before_widget'];
+ echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- if ( '' != $instance['title'] ) {
- echo $args['before_title'] . $instance['title'] . $args['after_title'];
+ if ( '' !== $instance['title'] ) {
+ echo $args['before_title'] . esc_html( $instance['title'] ) . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
/**
@@ -95,12 +109,12 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) {
echo '<div itemscope itemtype="http://schema.org/LocalBusiness">';
- if ( '' != $instance['address'] ) {
+ if ( '' !== $instance['address'] ) {
$showmap = $instance['showmap'];
+ $goodmap = isset( $instance['goodmap'] ) ? $instance['goodmap'] : $this->has_good_map( $instance );
- /** This action is documented in modules/widgets/contact-info.php */
- if ( $showmap && $this->has_good_map( $instance ) ) {
+ if ( $showmap && true === $goodmap ) {
/**
* Set a Google Maps API Key.
*
@@ -109,15 +123,24 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) {
* @param string $api_key Google Maps API Key
*/
$api_key = apply_filters( 'jetpack_google_maps_api_key', $instance['apikey'] );
- echo $this->build_map( $instance['address'], $api_key );
+ echo $this->build_map( $instance['address'], $api_key ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ } elseif ( $showmap && is_customize_preview() && true !== $goodmap ) {
+ printf(
+ '<span class="contact-map-api-error" style="display: block;">%s</span>',
+ esc_html( $instance['goodmap'] )
+ );
}
$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>';
+ printf(
+ '<div class="confit-address" itemscope itemtype="http://schema.org/PostalAddress" itemprop="address"><a href="%1$s" target="_blank" rel="noopener noreferrer">%2$s</a></div>',
+ esc_url( $map_link ),
+ str_replace( "\n", '<br/>', esc_html( $instance['address'] ) ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ );
}
- if ( '' != $instance['phone'] ) {
+ 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 {
@@ -132,8 +155,11 @@ 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>';
+ if ( '' !== $instance['hours'] ) {
+ printf(
+ '<div class="confit-hours" itemprop="openingHours">%s</div>',
+ str_replace( "\n", '<br/>', esc_html( $instance['hours'] ) ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ );
}
echo '</div>';
@@ -147,7 +173,7 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) {
*/
do_action( 'jetpack_contact_info_widget_end' );
- echo $args['after_widget'];
+ echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
/** This action is documented in modules/widgets/gravatar-profile.php */
do_action( 'jetpack_stats_extra', 'widget_view', 'contact_info' );
@@ -158,19 +184,12 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) {
* Deals with the settings when they are saved by the admin. Here is
* where any validation should be dealt with.
*
- * @param array $new_instance New configuration values
- * @param array $old_instance Old configuration values
+ * @param array $new_instance New configuration values.
+ * @param array $old_instance Old configuration values.
*
* @return array
*/
- function update( $new_instance, $old_instance ) {
- $update_lat_lon = false;
- if (
- ! isset( $old_instance['address'] ) ||
- $this->urlencode_address( $old_instance['address'] ) != $this->urlencode_address( $new_instance['address'] )
- ) {
- $update_lat_lon = true;
- }
+ public function update( $new_instance, $old_instance ) {
$instance = array();
$instance['title'] = wp_kses( $new_instance['title'], array() );
@@ -179,50 +198,6 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) {
$instance['email'] = wp_kses( $new_instance['email'], array() );
$instance['hours'] = wp_kses( $new_instance['hours'], array() );
$instance['apikey'] = wp_kses( isset( $new_instance['apikey'] ) ? $new_instance['apikey'] : $old_instance['apikey'], array() );
- $instance['lat'] = isset( $old_instance['lat'] ) ? floatval( $old_instance['lat'] ) : 0;
- $instance['lon'] = isset( $old_instance['lon'] ) ? floatval( $old_instance['lon'] ) : 0;
-
- if ( ! $instance['lat'] || ! $instance['lon'] ) {
- $update_lat_lon = true;
- }
-
- if ( $instance['address'] && $update_lat_lon ) {
-
- // 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;
- /** 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 ) ) );
-
- 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' );
- die();
- }
-
- $json_obj = json_decode( $json );
-
- 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 {
-
- $loc = $json_obj->results[0]->geometry->location;
-
- $lat = floatval( $loc->lat );
- $lon = floatval( $loc->lng );
-
- $instance['lat'] = "$lat";
- $instance['lon'] = "$lon";
- }
- }
if ( ! isset( $new_instance['showmap'] ) ) {
$instance['showmap'] = 0;
@@ -230,6 +205,8 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) {
$instance['showmap'] = intval( $new_instance['showmap'] );
}
+ $instance['goodmap'] = $this->update_goodmap( $old_instance, $instance );
+
return $instance;
}
@@ -241,18 +218,31 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) {
*
* @return void
*/
- function form( $instance ) {
+ public function form( $instance ) {
$instance = wp_parse_args( $instance, $this->defaults() );
+ /** This filter is documented in modules/widgets/contact-info.php */
+ $apikey = apply_filters( 'jetpack_google_maps_api_key', $instance['apikey'] );
+
wp_enqueue_script(
'contact-info-admin',
- Jetpack::get_file_url_for_environment(
+ Assets::get_file_url_for_environment(
'_inc/build/widgets/contact-info/contact-info-admin.min.js',
'modules/widgets/contact-info/contact-info-admin.js'
),
array( 'jquery' ),
- 20160727
+ 20160727,
+ false
);
+ if ( is_customize_preview() ) {
+ $customize_contact_info_api_key_nonce = wp_create_nonce( 'customize_contact_info_api_key' );
+ wp_localize_script(
+ 'contact-info-admin',
+ 'contact_info_api_key_ajax_obj',
+ array( 'nonce' => $customize_contact_info_api_key_nonce )
+ );
+ }
+
?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'jetpack' ); ?></label>
@@ -262,30 +252,48 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) {
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'address' ) ); ?>"><?php esc_html_e( 'Address:', 'jetpack' ); ?></label>
<textarea class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'address' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'address' ) ); ?>"><?php echo esc_textarea( $instance['address'] ); ?></textarea>
- <?php
- if ( $this->has_good_map( $instance ) ) {
- ?>
- <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 {
- ?>
- <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" />
- <?php
- }
- ?>
+
+ <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>
</p>
- <p class="jp-contact-info-apikey" style="<?php echo $instance['showmap'] ? '' : 'display: none;'; ?>">
+ <p class="jp-contact-info-admin-map" style="<?php echo $instance['showmap'] ? '' : 'display: none;'; ?>">
<label for="<?php echo esc_attr( $this->get_field_id( 'apikey' ) ); ?>">
- <?php _e( 'Google Maps API Key', 'jetpack' ); ?>
- <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'apikey' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'apikey' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['apikey'] ); ?>" />
+ <?php esc_html_e( 'Google Maps API Key', 'jetpack' ); ?>
+ <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'apikey' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'apikey' ) ); ?>" type="text" value="<?php echo esc_attr( $apikey ); ?>" />
<br />
- <small><?php printf( wp_kses( __( 'Google now requires an API key to use their maps on your site. <a href="%s">See our documentation</a> for instructions on acquiring a key.', 'jetpack' ), array( 'a' => array( 'href' => true ) ) ), 'https://jetpack.com/support/extra-sidebar-widgets/contact-info-widget/' ); ?></small>
+ <small>
+ <?php
+ printf(
+ wp_kses(
+ /* Translators: placeholder is a URL to support documentation. */
+ __( 'Google now requires an API key to use their maps on your site. <a href="%s">See our documentation</a> for instructions on acquiring a key.', 'jetpack' ),
+ array(
+ 'a' => array(
+ 'href' => true,
+ ),
+ )
+ ),
+ 'https://jetpack.com/support/extra-sidebar-widgets/contact-info-widget/'
+ );
+ ?>
+ </small>
</label>
</p>
+ <p class="jp-contact-info-admin-map jp-contact-info-embed-map" style="<?php echo $instance['showmap'] ? '' : 'display: none;'; ?>">
+ <?php
+ if ( ! is_customize_preview() && true === $instance['goodmap'] ) {
+ echo $this->build_map( $instance['address'], $apikey ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ } elseif ( true !== $instance['goodmap'] && ! empty( $instance['goodmap'] ) ) {
+ printf(
+ '<span class="notice notice-warning" style="display: block;">%s</span>',
+ esc_html( $instance['goodmap'] )
+ );
+ }
+ ?>
+ </p>
+
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'phone' ) ); ?>"><?php esc_html_e( 'Phone:', 'jetpack' ); ?></label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'phone' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'phone' ) ); ?>" type="text" value="<?php echo esc_attr( $instance['phone'] ); ?>" />
@@ -312,21 +320,21 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) {
*
* @return string
*/
- function build_map_link( $address ) {
+ private 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 );
}
/**
- * Builds map display HTML code from the supplied latitude and longitude.
+ * Builds map display HTML code from the supplied address.
*
* @param string $address Address.
* @param string $api_key API Key.
*
* @return string HTML of the map.
*/
- function build_map( $address, $api_key = null ) {
+ private function build_map( $address, $api_key = null ) {
$this->enqueue_scripts();
$src = add_query_arg( 'q', rawurlencode( $address ), 'https://www.google.com/maps/embed/v1/place' );
if ( ! empty( $api_key ) ) {
@@ -365,16 +373,54 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) {
/**
* Encode an URL
*
- * @param string $address The URL to encode
+ * @param string $address The URL to encode.
*
* @return string The encoded URL
*/
- function urlencode_address( $address ) {
+ private 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
- return urlencode( $address );
+ // Get rid of any unwanted whitespace.
+ $address = preg_replace( '/\s+/', ' ', trim( $address ) );
+ // Use + not %20.
+ $address = str_ireplace( ' ', '+', $address );
+ return rawurlencode( $address );
+ }
+
+ /**
+ * Returns the instance's updated 'goodmap' value.
+ *
+ * @param array $old_instance Old configuration values.
+ * @param array $instance Current configuration values.
+ *
+ * @return bool|string The instance's updated 'goodmap' value. The value is true if
+ * $instance can display a good map. If not, returns an error message.
+ */
+ private function update_goodmap( $old_instance, $instance ) {
+ /*
+ * If we have no address or don't want to show a map,
+ * no need to check if the map is valid.
+ */
+ if ( empty( $instance['address'] ) || 0 === $instance['showmap'] ) {
+ return false;
+ }
+
+ /*
+ * If there have been any changes that may impact the map in the widget
+ * (adding an address, address changes, new API key, API key change)
+ * then we want to check whether our map can be displayed again.
+ */
+ if (
+ ! isset( $instance['goodmap'] )
+ || ! isset( $old_instance['address'] )
+ || $this->urlencode_address( $old_instance['address'] ) !== $this->urlencode_address( $instance['address'] )
+ || ! isset( $old_instance['apikey'] )
+ || $old_instance['apikey'] !== $instance['apikey']
+ ) {
+ return $this->has_good_map( $instance );
+ } else {
+ return $instance['goodmap'];
+ }
}
/**
@@ -382,11 +428,49 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) {
*
* @param array $instance Widget instance configuration.
*
- * @return bool Whether or not there is a valid map.
+ * @return bool|string Whether or not there is a valid map. If not, return an error message.
+ */
+ private function has_good_map( $instance ) {
+ /** This filter is documented in modules/widgets/contact-info.php */
+ $api_key = apply_filters( 'jetpack_google_maps_api_key', $instance['apikey'] );
+ if ( ! empty( $api_key ) ) {
+ $path = add_query_arg(
+ array(
+ 'q' => rawurlencode( $instance['address'] ),
+ 'key' => $api_key,
+ ),
+ 'https://www.google.com/maps/embed/v1/place'
+ );
+ $wp_remote_get_args = array(
+ 'headers' => array( 'Referer' => home_url() ),
+ );
+ $response = wp_remote_get( esc_url_raw( $path ), $wp_remote_get_args );
+
+ if ( 200 === wp_remote_retrieve_response_code( $response ) ) {
+ return true;
+ } else {
+ return wp_remote_retrieve_body( $response );
+ }
+ }
+
+ return __( 'Please enter a valid Google API Key.', 'jetpack' );
+ }
+
+ /**
+ * Check the Google Maps API key after an Ajax call from the widget's admin form in
+ * the Customizer preview.
*/
- 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'] );
+ public function ajax_check_api_key() {
+ if ( isset( $_POST['apikey'] ) ) {
+ if ( check_ajax_referer( 'customize_contact_info_api_key' ) && current_user_can( 'customize' ) ) {
+ $apikey = wp_kses( $_POST['apikey'], array() );
+ $default_instance = $this->defaults();
+ $default_instance['apikey'] = $apikey;
+ wp_send_json( array( 'result' => esc_html( $this->has_good_map( $default_instance ) ) ) );
+ }
+ } else {
+ wp_die();
+ }
}
}
diff --git a/plugins/jetpack/modules/widgets/contact-info/contact-info-admin.js b/plugins/jetpack/modules/widgets/contact-info/contact-info-admin.js
index f51dccda..9d3d9d46 100644
--- a/plugins/jetpack/modules/widgets/contact-info/contact-info-admin.js
+++ b/plugins/jetpack/modules/widgets/contact-info/contact-info-admin.js
@@ -1,3 +1,5 @@
+/* global ajaxurl, contact_info_api_key_ajax_obj */
+
( function( $ ) {
$( document ).on( 'change', '.jp-contact-info-showmap', function() {
var $checkbox = $( this ),
@@ -5,7 +7,51 @@
$checkbox
.closest( '.widget' )
- .find( '.jp-contact-info-apikey' )
+ .find( '.jp-contact-info-admin-map' )
.toggle( isChecked );
} );
+
+ $( document ).on( 'widget-synced', function( event, widgetContainer ) {
+ // This event fires for all widgets, so restrict this to Contact Info widgets and the API key input.
+ if (
+ ! widgetContainer.is( '[id*="widget_contact_info"]' ) ||
+ ! $( document.activeElement ).is( 'input[id*="apikey"]' )
+ ) {
+ return;
+ }
+
+ event.preventDefault();
+
+ var $apikey_input = widgetContainer.find( 'input[id*="apikey"]' );
+
+ $.post(
+ ajaxurl,
+ {
+ _ajax_nonce: contact_info_api_key_ajax_obj.nonce,
+ action: 'customize-contact-info-api-key',
+ apikey: $apikey_input.val(),
+ },
+ function( data ) {
+ var $map_element = $apikey_input
+ .closest( '.jp-contact-info-admin-map' )
+ .parent()
+ .find( '.jp-contact-info-embed-map' );
+ var $warning_span = $map_element.find( '[class*="notice"]' );
+
+ if ( '1' !== data.result ) {
+ if ( $warning_span.length === 0 ) {
+ $map_element.append(
+ '<span class="notice notice-warning" style="display: block;">' +
+ data.result +
+ '</span>'
+ );
+ } else if ( $warning_span.text() !== data.result ) {
+ $warning_span.text( data.result );
+ }
+ } else {
+ $map_element.empty();
+ }
+ }
+ );
+ } );
} )( window.jQuery );
diff --git a/plugins/jetpack/modules/widgets/contact-info/contact-info-map.css b/plugins/jetpack/modules/widgets/contact-info/contact-info-map.css
index 7aa9e698..b64d2caa 100644
--- a/plugins/jetpack/modules/widgets/contact-info/contact-info-map.css
+++ b/plugins/jetpack/modules/widgets/contact-info/contact-info-map.css
@@ -1,4 +1,13 @@
.contact-map {
max-width: 100%;
border: 0;
+}
+
+.contact-map-api-error {
+ border-left-color: #ffb900;
+ border-left-style: solid;
+ border-left-width: 4px;
+ box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);
+ margin: 5px 0 15px;
+ padding: 1px 12px;
} \ No newline at end of file
diff --git a/plugins/jetpack/modules/widgets/eu-cookie-law.php b/plugins/jetpack/modules/widgets/eu-cookie-law.php
index 62acda4a..27ffa9a3 100644
--- a/plugins/jetpack/modules/widgets/eu-cookie-law.php
+++ b/plugins/jetpack/modules/widgets/eu-cookie-law.php
@@ -1,5 +1,7 @@
<?php
+use Automattic\Jetpack\Assets;
+
/**
* Disable direct access/execution to/of the widget code.
*/
@@ -99,7 +101,7 @@ if ( ! class_exists( 'Jetpack_EU_Cookie_Law_Widget' ) ) {
wp_enqueue_style( 'eu-cookie-law-style', plugins_url( 'eu-cookie-law/style.css', __FILE__ ), array(), '20170403' );
wp_enqueue_script(
'eu-cookie-law-script',
- Jetpack::get_file_url_for_environment(
+ Assets::get_file_url_for_environment(
'_inc/build/widgets/eu-cookie-law/eu-cookie-law.min.js',
'modules/widgets/eu-cookie-law/eu-cookie-law.js'
),
@@ -189,7 +191,7 @@ if ( ! class_exists( 'Jetpack_EU_Cookie_Law_Widget' ) ) {
wp_enqueue_script(
'eu-cookie-law-widget-admin',
- Jetpack::get_file_url_for_environment(
+ Assets::get_file_url_for_environment(
'_inc/build/widgets/eu-cookie-law/eu-cookie-law-admin.min.js',
'modules/widgets/eu-cookie-law/eu-cookie-law-admin.js'
),
diff --git a/plugins/jetpack/modules/widgets/facebook-likebox.php b/plugins/jetpack/modules/widgets/facebook-likebox.php
index 5fbc23e0..cb392b98 100644
--- a/plugins/jetpack/modules/widgets/facebook-likebox.php
+++ b/plugins/jetpack/modules/widgets/facebook-likebox.php
@@ -77,7 +77,7 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
$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['stream'] = (bool) $like_args['stream'] ? 'timeline' : 'false';
$like_args['cover'] = (bool) $like_args['cover'] ? 'false' : 'true';
echo $before_widget;
@@ -105,7 +105,7 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
?>
<div id="fb-root"></div>
- <div class="fb-page" data-href="<?php echo esc_url( $page_url ); ?>" data-width="<?php echo intval( $like_args['width'] ); ?>" data-height="<?php echo intval( $like_args['height'] ); ?>" data-hide-cover="<?php echo esc_attr( $like_args['cover'] ); ?>" data-show-facepile="<?php echo esc_attr( $like_args['show_faces'] ); ?>" data-show-posts="<?php echo esc_attr( $like_args['stream'] ); ?>">
+ <div class="fb-page" data-href="<?php echo esc_url( $page_url ); ?>" data-width="<?php echo intval( $like_args['width'] ); ?>" data-height="<?php echo intval( $like_args['height'] ); ?>" data-hide-cover="<?php echo esc_attr( $like_args['cover'] ); ?>" data-show-facepile="<?php echo esc_attr( $like_args['show_faces'] ); ?>" data-tabs="<?php echo esc_attr( $like_args['stream'] ); ?>">
<div class="fb-xfbml-parse-ignore"><blockquote cite="<?php echo esc_url( $page_url ); ?>"><a href="<?php echo esc_url( $page_url ); ?>"><?php echo esc_html( $title ); ?></a></blockquote></div>
</div>
<?php
@@ -193,7 +193,7 @@ class WPCOM_Widget_Facebook_LikeBox extends WP_Widget {
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'stream' ) ); ?>">
<input type="checkbox" name="<?php echo esc_attr( $this->get_field_name( 'stream' ) ); ?>" id="<?php echo esc_attr( $this->get_field_id( 'stream' ) ); ?>" <?php checked( $like_args['stream'] ); ?> />
- <?php _e( 'Show Stream', 'jetpack' ); ?>
+ <?php _e( 'Show Timeline', 'jetpack' ); ?>
<br />
<small><?php _e( 'Show Page Posts.', 'jetpack' ); ?></small>
</label>
diff --git a/plugins/jetpack/modules/widgets/flickr.php b/plugins/jetpack/modules/widgets/flickr.php
index a7867612..20b32dd2 100644
--- a/plugins/jetpack/modules/widgets/flickr.php
+++ b/plugins/jetpack/modules/widgets/flickr.php
@@ -51,6 +51,7 @@ if ( ! class_exists( 'Jetpack_Flickr_Widget' ) ) {
return array(
'title' => esc_html__( 'Flickr Photos', 'jetpack' ),
'items' => 4,
+ 'target' => false,
'flickr_image_size' => 'thumbnail',
'flickr_rss_url' => '',
);
@@ -73,7 +74,7 @@ if ( ! class_exists( 'Jetpack_Flickr_Widget' ) ) {
* Parse the URL, and rebuild a URL that's sure to display images.
* Some Flickr Feeds do not display images by default.
*/
- $flickr_parameters = parse_url( htmlspecialchars_decode( $instance['flickr_rss_url'] ) );
+ $flickr_parameters = wp_parse_url( htmlspecialchars_decode( $instance['flickr_rss_url'] ) );
// Is it a Flickr Feed.
if (
@@ -129,8 +130,11 @@ if ( ! class_exists( 'Jetpack_Flickr_Widget' ) ) {
break;
}
- $photos .= '<a href="' . esc_url( $photo->get_permalink(), array( 'http', 'https' ) ) . '">';
- $photos .= '<img src="' . esc_url( $src, array( 'http', 'https' ) ) . '" ';
+ $photos .= '<a href="' . esc_url( $photo->get_permalink(), array( 'http', 'https' ) ) . '" ';
+ if ( $instance['target'] ) {
+ $photos .= 'target="_blank" rel="noopener noreferrer" ';
+ }
+ $photos .= '><img src="' . esc_url( $src, array( 'http', 'https' ) ) . '" ';
$photos .= 'alt="' . esc_attr( $photo->get_title() ) . '" ';
$photos .= 'title="' . esc_attr( $photo->get_title() ) . '" ';
$photos .= ' /></a>';
@@ -189,6 +193,10 @@ if ( ! class_exists( 'Jetpack_Flickr_Widget' ) ) {
$instance['items'] = intval( $new_instance['items'] );
}
+ if ( isset( $new_instance['target'] ) ) {
+ $instance['target'] = (bool) $new_instance['target'];
+ }
+
if (
isset( $new_instance['flickr_image_size'] ) &&
in_array( $new_instance['flickr_image_size'], array( 'thumbnail', 'small', 'large' ) )
diff --git a/plugins/jetpack/modules/widgets/flickr/form.php b/plugins/jetpack/modules/widgets/flickr/form.php
index b08e7c4d..0dfc5c9a 100644
--- a/plugins/jetpack/modules/widgets/flickr/form.php
+++ b/plugins/jetpack/modules/widgets/flickr/form.php
@@ -30,7 +30,7 @@
<small>
<?php printf(
__( 'Leave the Flickr RSS URL field blank to display <a target="_blank" href="%s">interesting</a> Flickr photos.', 'jetpack' ),
- 'http://www.flickr.com/explore/interesting'
+ 'https://www.flickr.com/explore/interesting'
); ?>
</small>
</p>
@@ -52,6 +52,16 @@
</p>
<p>
+ <label>
+ <input
+ type="checkbox"
+ name="<?php echo esc_attr( $this->get_field_name( 'target' ) ); ?>"
+ <?php checked( $instance['target'] ); ?>
+ />
+ <?php esc_html_e( 'Open images in new tab?', 'jetpack' ); ?>
+ </label>
+</p>
+<p>
<div>
<?php esc_html_e( 'What size photos would you like to display?', 'jetpack' ); ?>
</div>
diff --git a/plugins/jetpack/modules/widgets/gallery.php b/plugins/jetpack/modules/widgets/gallery.php
index 8cb24d01..aa631e62 100644
--- a/plugins/jetpack/modules/widgets/gallery.php
+++ b/plugins/jetpack/modules/widgets/gallery.php
@@ -5,9 +5,11 @@ Plugin Name: Gallery
Description: Gallery widget
Author: Automattic Inc.
Version: 1.0
-Author URI: http://automattic.com
+Author URI: https://automattic.com
*/
+use Automattic\Jetpack\Assets;
+
class Jetpack_Gallery_Widget extends WP_Widget {
const THUMB_SIZE = 45;
const DEFAULT_WIDTH = 265;
@@ -400,7 +402,7 @@ class Jetpack_Gallery_Widget extends WP_Widget {
public function enqueue_frontend_scripts() {
wp_register_script(
'gallery-widget',
- Jetpack::get_file_url_for_environment(
+ Assets::get_file_url_for_environment(
'_inc/build/widgets/gallery/js/gallery.min.js',
'modules/widgets/gallery/js/gallery.js'
)
@@ -417,7 +419,7 @@ class Jetpack_Gallery_Widget extends WP_Widget {
wp_enqueue_script(
'gallery-widget-admin',
- Jetpack::get_file_url_for_environment(
+ Assets::get_file_url_for_environment(
'_inc/build/widgets/gallery/js/admin.min.js',
'modules/widgets/gallery/js/admin.js'
),
diff --git a/plugins/jetpack/modules/widgets/gallery/js/admin.js b/plugins/jetpack/modules/widgets/gallery/js/admin.js
index 71025a9b..6a926d69 100644
--- a/plugins/jetpack/modules/widgets/gallery/js/admin.js
+++ b/plugins/jetpack/modules/widgets/gallery/js/admin.js
@@ -1,4 +1,3 @@
-/* jshint onevar: false, multistr: true */
/* global _wpMediaViewsL10n, _wpGalleryWidgetAdminSettings */
( function( $ ) {
diff --git a/plugins/jetpack/modules/widgets/goodreads.php b/plugins/jetpack/modules/widgets/goodreads.php
index 4160c868..d6ea6515 100644
--- a/plugins/jetpack/modules/widgets/goodreads.php
+++ b/plugins/jetpack/modules/widgets/goodreads.php
@@ -95,7 +95,7 @@ class WPCOM_Widget_Goodreads extends WP_Widget {
$response = wp_remote_head(
$url, array(
'httpversion' => '1.1',
- 'timeout' => 3,
+ 'timeout' => 10,
'redirection' => 2,
)
);
diff --git a/plugins/jetpack/modules/widgets/google-translate.php b/plugins/jetpack/modules/widgets/google-translate.php
index 241fb8ed..87742317 100644
--- a/plugins/jetpack/modules/widgets/google-translate.php
+++ b/plugins/jetpack/modules/widgets/google-translate.php
@@ -1,11 +1,14 @@
<?php
+
+use Automattic\Jetpack\Assets;
+
/**
* Plugin Name: Google Translate Widget for WordPress.com
- * Plugin URI: http://automattic.com
+ * Plugin URI: https://automattic.com
* Description: Add a widget for automatic translation
* Author: Artur Piszek
* Version: 0.1
- * Author URI: http://automattic.com
+ * Author URI: https://automattic.com
* Text Domain: jetpack
*/
if ( ! defined( 'ABSPATH' ) ) {
@@ -46,7 +49,7 @@ class Jetpack_Google_Translate_Widget extends WP_Widget {
public function enqueue_scripts() {
wp_register_script(
'google-translate-init',
- Jetpack::get_file_url_for_environment(
+ Assets::get_file_url_for_environment(
'_inc/build/widgets/google-translate/google-translate.min.js',
'modules/widgets/google-translate/google-translate.js'
)
diff --git a/plugins/jetpack/modules/widgets/gravatar-profile.php b/plugins/jetpack/modules/widgets/gravatar-profile.php
index f5171665..2dd4e5fb 100644
--- a/plugins/jetpack/modules/widgets/gravatar-profile.php
+++ b/plugins/jetpack/modules/widgets/gravatar-profile.php
@@ -11,7 +11,7 @@ function jetpack_gravatar_profile_widget_init() {
/**
* Display a widgetized version of your Gravatar Profile
- * http://blog.gravatar.com/2010/03/26/gravatar-profiles/
+ * https://blog.gravatar.com/2010/03/26/gravatar-profiles/
*/
class Jetpack_Gravatar_Profile_Widget extends WP_Widget {
diff --git a/plugins/jetpack/modules/widgets/image-widget.php b/plugins/jetpack/modules/widgets/image-widget.php
index 37a353c1..d455b4c2 100644
--- a/plugins/jetpack/modules/widgets/image-widget.php
+++ b/plugins/jetpack/modules/widgets/image-widget.php
@@ -229,13 +229,13 @@ class Jetpack_Image_Widget extends WP_Widget {
<p><label for="' . $this->get_field_id( 'img_url' ) . '">' . esc_html__( 'Image URL:', 'jetpack' ) . '
<input class="widefat" id="' . $this->get_field_id( 'img_url' ) . '" name="' . $this->get_field_name( 'img_url' ) . '" type="text" value="' . $img_url . '" />
</label></p>
- <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>
+ <p><label for="' . $this->get_field_id( 'alt_text' ) . '">' . esc_html__( 'Alternate text:', 'jetpack' ) . ' <a href="https://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="https://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>
+ <p><label for="' . $this->get_field_id( 'caption' ) . '">' . esc_html__( 'Caption:', 'jetpack' ) . ' <a href="https://support.wordpress.com/widgets/image-widget/#image-widget-caption" target="_blank">( ? )</a>
<textarea class="widefat" id="' . $this->get_field_id( 'caption' ) . '" name="' . $this->get_field_name( 'caption' ) . '" rows="2" cols="20">' . $caption . '</textarea>
</label></p>';
diff --git a/plugins/jetpack/modules/widgets/milestone/milestone.php b/plugins/jetpack/modules/widgets/milestone/milestone.php
index 8490a8ec..2da5582b 100644
--- a/plugins/jetpack/modules/widgets/milestone/milestone.php
+++ b/plugins/jetpack/modules/widgets/milestone/milestone.php
@@ -4,10 +4,12 @@ Plugin Name: Milestone
Description: Countdown to a specific date.
Version: 1.0
Author: Automattic Inc.
-Author URI: http://automattic.com/
+Author URI: https://automattic.com/
License: GPLv2 or later
*/
+use Automattic\Jetpack\Assets;
+
function jetpack_register_widget_milestone() {
register_widget( 'Milestone_Widget' );
}
@@ -62,7 +64,7 @@ class Milestone_Widget extends WP_Widget {
wp_enqueue_style( 'milestone-admin', self::$url . 'style-admin.css', array(), '20161215' );
wp_enqueue_script(
'milestone-admin-js',
- Jetpack::get_file_url_for_environment(
+ Assets::get_file_url_for_environment(
'_inc/build/widgets/milestone/admin.min.js',
'modules/widgets/milestone/admin.js'
),
@@ -80,7 +82,7 @@ class Milestone_Widget extends WP_Widget {
wp_enqueue_script(
'milestone',
- Jetpack::get_file_url_for_environment(
+ Assets::get_file_url_for_environment(
'_inc/build/widgets/milestone/milestone.min.js',
'modules/widgets/milestone/milestone.js'
),
@@ -531,7 +533,7 @@ class Milestone_Widget extends WP_Widget {
* Sanitize an instance of this widget.
*
* Date ranges match the documentation for mktime in the php manual.
- * @see http://php.net/manual/en/function.mktime.php#refsect1-function.mktime-parameters
+ * @see https://php.net/manual/en/function.mktime.php#refsect1-function.mktime-parameters
*
* @uses Milestone_Widget::sanitize_range().
*/
diff --git a/plugins/jetpack/modules/widgets/search.php b/plugins/jetpack/modules/widgets/search.php
index 54d866b5..49cb9b7f 100644
--- a/plugins/jetpack/modules/widgets/search.php
+++ b/plugins/jetpack/modules/widgets/search.php
@@ -7,6 +7,9 @@
* @since 5.0.0
*/
+use Automattic\Jetpack\Constants;
+use Automattic\Jetpack\Status;
+
add_action( 'widgets_init', 'jetpack_search_widget_init' );
function jetpack_search_widget_init() {
@@ -164,7 +167,7 @@ class Jetpack_Search_Widget extends WP_Widget {
* @since 5.8.0
*/
public function enqueue_frontend_scripts() {
- if ( ! is_active_widget( false, false, $this->id_base, true ) ) {
+ if ( ! is_active_widget( false, false, $this->id_base, true ) || Constants::is_true( 'JETPACK_SEARCH_PROTOTYPE' ) ) {
return;
}
@@ -266,7 +269,7 @@ class Jetpack_Search_Widget extends WP_Widget {
$display_filters = false;
- if ( Jetpack::is_development_mode() ) {
+ if ( ( new Status() )->is_development_mode() ) {
echo $args['before_widget'];
?><div id="<?php echo esc_attr( $this->id ); ?>-wrapper">
<div class="jetpack-search-sort-wrapper">
@@ -309,7 +312,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">
+ ?><div id="<?php echo esc_attr( $this->id ); ?>-wrapper" class="<?php
+ echo Constants::is_true( 'JETPACK_SEARCH_PROTOTYPE' ) ? 'jetpack-instant-search-wrapper' : '' ?>">
<?php
if ( ! empty( $title ) ) {
@@ -393,6 +397,10 @@ class Jetpack_Search_Widget extends WP_Widget {
* @param string $orderby The orderby to initialize the select with.
*/
private function maybe_render_sort_javascript( $instance, $order, $orderby ) {
+ if ( Constants::is_true( 'JETPACK_SEARCH_PROTOTYPE' ) ) {
+ return;
+ }
+
if ( ! empty( $instance['user_sort_enabled'] ) ) :
?>
<script type="text/javascript">
diff --git a/plugins/jetpack/modules/widgets/simple-payments.php b/plugins/jetpack/modules/widgets/simple-payments.php
index 4eb60bdb..397c43fe 100644
--- a/plugins/jetpack/modules/widgets/simple-payments.php
+++ b/plugins/jetpack/modules/widgets/simple-payments.php
@@ -1,4 +1,6 @@
<?php
+use Automattic\Jetpack\Tracking;
+
/**
* Disable direct access/execution to/of the widget code.
*/
@@ -13,7 +15,19 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_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/
+ /**
+ * Currencies should be supported by PayPal:
+ * @link https://developer.paypal.com/docs/api/reference/currency-codes/
+ *
+ * List has to be in sync with list at the block's client side and API's backend side:
+ * @link https://github.com/Automattic/jetpack/blob/31efa189ad223c0eb7ad085ac0650a23facf9ef5/extensions/blocks/simple-payments/constants.js#L9-L39
+ * @link https://github.com/Automattic/jetpack/blob/31efa189ad223c0eb7ad085ac0650a23facf9ef5/modules/simple-payments/simple-payments.php#L386-L415
+ *
+ * Indian Rupee (INR) is listed here for backwards compatibility with previously added widgets.
+ * It's not supported by Simple Payments because at the time of the creation of this file
+ * because it's limited to in-country PayPal India accounts only.
+ * Discussion: https://github.com/Automattic/wp-calypso/pull/28236
+ */
private static $supported_currency_list = array(
'USD' => '$',
'GBP' => '&#163;',
@@ -435,7 +449,8 @@ if ( ! class_exists( 'Jetpack_Simple_Payments_Widget' ) ) {
return;
}
- jetpack_tracks_record_event( $current_user, 'jetpack_wpa_simple_payments_button_' . $event_action, $event_properties );
+ $tracking = new Tracking();
+ $tracking->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 );
diff --git a/plugins/jetpack/modules/widgets/social-icons.php b/plugins/jetpack/modules/widgets/social-icons.php
index 7afbd27d..bea4a147 100644
--- a/plugins/jetpack/modules/widgets/social-icons.php
+++ b/plugins/jetpack/modules/widgets/social-icons.php
@@ -1,6 +1,12 @@
-<?php
+<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
+
+/**
+ * Social Icons Widget.
+ */
class Jetpack_Widget_Social_Icons extends WP_Widget {
/**
+ * Default widget options.
+ *
* @var array Default widget options.
*/
protected $defaults;
@@ -52,8 +58,19 @@ class Jetpack_Widget_Social_Icons extends WP_Widget {
* Script & styles for admin widget form.
*/
public function enqueue_admin_scripts() {
- wp_enqueue_script( 'jetpack-widget-social-icons-script', plugins_url( 'social-icons/social-icons-admin.js', __FILE__ ), array( 'jquery-ui-sortable' ), '20170506' );
- wp_enqueue_style( 'jetpack-widget-social-icons-admin', plugins_url( 'social-icons/social-icons-admin.css', __FILE__ ), array(), '20170506' );
+ wp_enqueue_script(
+ 'jetpack-widget-social-icons-script',
+ plugins_url( 'social-icons/social-icons-admin.js', __FILE__ ),
+ array( 'jquery-ui-sortable' ),
+ '20170506',
+ true
+ );
+ wp_enqueue_style(
+ 'jetpack-widget-social-icons-admin',
+ plugins_url( 'social-icons/social-icons-admin.css', __FILE__ ),
+ array(),
+ '20170506'
+ );
}
/**
@@ -67,28 +84,28 @@ class Jetpack_Widget_Social_Icons extends WP_Widget {
* JavaScript for admin widget form.
*/
public function render_admin_js() {
- ?>
+ ?>
<script type="text/html" id="tmpl-jetpack-widget-social-icons-template">
<?php self::render_icons_template(); ?>
</script>
- <?php
+ <?php
}
/**
* Add SVG definitions to the footer.
*/
public function include_svg_icons() {
- // Define SVG sprite file in Jetpack
+ // Define SVG sprite file in Jetpack.
$svg_icons = dirname( dirname( __FILE__ ) ) . '/theme-tools/social-menu/social-menu.svg';
- // Define SVG sprite file in WPCOM
+ // Define SVG sprite file in WPCOM.
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
$svg_icons = dirname( dirname( __FILE__ ) ) . '/social-menu/social-menu.svg';
}
// If it exists, include it.
if ( is_file( $svg_icons ) ) {
- require_once( $svg_icons );
+ require_once $svg_icons;
}
}
@@ -106,10 +123,10 @@ class Jetpack_Widget_Social_Icons extends WP_Widget {
/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
$title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
- echo $args['before_widget'];
+ echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
if ( ! empty( $title ) ) {
- echo $args['before_title'] . esc_html( $title ) . $args['after_title'];
+ echo $args['before_title'] . esc_html( $title ) . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
if ( ! empty( $instance['icons'] ) ) :
@@ -118,13 +135,13 @@ class Jetpack_Widget_Social_Icons extends WP_Widget {
$social_icons = $this->get_supported_icons();
$default_icon = $this->get_svg_icon( array( 'icon' => 'chain' ) );
- // Set target attribute for the link
+ // Set target attribute for the link.
if ( true === $instance['new-tab'] ) {
$target = '_blank';
} else {
$target = '_self';
}
- ?>
+ ?>
<ul class="jetpack-social-widget-list size-<?php echo esc_attr( $instance['icon-size'] ); ?>">
@@ -132,21 +149,31 @@ class Jetpack_Widget_Social_Icons extends WP_Widget {
<?php if ( ! empty( $icon['url'] ) ) : ?>
<li class="jetpack-social-widget-item">
- <a href="<?php echo esc_url( $icon['url'], array( 'http', 'https', 'mailto', 'skype' ) ); ?>" target="<?php echo $target; ?>">
+ <a href="<?php echo esc_url( $icon['url'], array( 'http', 'https', 'mailto', 'skype' ) ); ?>" target="<?php echo esc_attr( $target ); ?>">
<?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_icon['url'] as $url_fragment ) {
+ if ( false !== stripos( $icon['url'], $url_fragment ) ) {
+ printf(
+ '<span class="screen-reader-text">%1$s</span>%2$s',
+ esc_attr( $social_icon['label'] ),
+ // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
+ $this->get_svg_icon(
+ array(
+ 'icon' => esc_attr( $social_icon['icon'] ),
+ )
+ )
+ );
+ $found_icon = true;
+ break;
+ }
}
}
if ( ! $found_icon ) {
- echo $default_icon;
+ echo $default_icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
?>
</a>
@@ -157,10 +184,10 @@ class Jetpack_Widget_Social_Icons extends WP_Widget {
</ul>
- <?php
+ <?php
endif;
- echo $args['after_widget'];
+ echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
/** This action is documented in modules/widgets/gravatar-profile.php */
do_action( 'jetpack_stats_extra', 'widget_view', 'social_icons' );
@@ -177,15 +204,16 @@ class Jetpack_Widget_Social_Icons extends WP_Widget {
* @return array Updated safe values to be saved.
*/
public function update( $new_instance, $old_instance ) {
+ $instance = array();
+
$instance['title'] = sanitize_text_field( $new_instance['title'] );
$instance['icon-size'] = $this->defaults['icon-size'];
- if ( in_array( $new_instance['icon-size'], array( 'small', 'medium', 'large' ) ) ) {
+ if ( in_array( $new_instance['icon-size'], array( 'small', 'medium', 'large' ), true ) ) {
$instance['icon-size'] = $new_instance['icon-size'];
}
$instance['new-tab'] = isset( $new_instance['new-tab'] ) ? (bool) $new_instance['new-tab'] : false;
- $icon_count = count( $new_instance['url-icons'] );
$instance['icons'] = array();
foreach ( $new_instance['url-icons'] as $url ) {
@@ -222,13 +250,13 @@ class Jetpack_Widget_Social_Icons extends WP_Widget {
?>
<p>
- <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'jetpack' ); ?></label>
- <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 for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'jetpack' ); ?></label>
+ <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
</p>
<p>
- <label for="<?php echo $this->get_field_id( 'icon-size' ); ?>"><?php esc_html_e( 'Size:', 'jetpack' ); ?></label>
- <select class="widefat" name="<?php echo $this->get_field_name( 'icon-size' ); ?>">
+ <label for="<?php echo esc_attr( $this->get_field_id( 'icon-size' ) ); ?>"><?php esc_html_e( 'Size:', 'jetpack' ); ?></label>
+ <select class="widefat" name="<?php echo esc_attr( $this->get_field_name( 'icon-size' ) ); ?>">
<?php foreach ( $sizes as $value => $label ) : ?>
<option value="<?php echo esc_attr( $value ); ?>" <?php selected( $value, $instance['icon-size'] ); ?>><?php echo esc_attr( $label ); ?></option>
<?php endforeach; ?>
@@ -236,8 +264,8 @@ class Jetpack_Widget_Social_Icons extends WP_Widget {
</p>
<div class="jetpack-social-icons-widget-list"
- data-url-icon-id="<?php echo $this->get_field_id( 'url-icons' ); ?>"
- data-url-icon-name="<?php echo $this->get_field_name( 'url-icons' ); ?>"
+ data-url-icon-id="<?php echo esc_attr( $this->get_field_id( 'url-icons' ) ); ?>"
+ data-url-icon-name="<?php echo esc_attr( $this->get_field_name( 'url-icons' ) ); ?>"
>
<?php
@@ -282,19 +310,19 @@ class Jetpack_Widget_Social_Icons extends WP_Widget {
</p>
<p>
- <input type="checkbox" class="checkbox" id="<?php echo $this->get_field_id( 'new-tab' ); ?>" name="<?php echo $this->get_field_name( 'new-tab' ); ?>" <?php checked( $new_tab ); ?> />
- <label for="<?php echo $this->get_field_id( 'new-tab' ); ?>"><?php esc_html_e( 'Open link in a new tab', 'jetpack' ); ?></label>
+ <input type="checkbox" class="checkbox" id="<?php echo esc_attr( $this->get_field_id( 'new-tab' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'new-tab' ) ); ?>" <?php checked( $new_tab ); ?> />
+ <label for="<?php echo esc_attr( $this->get_field_id( 'new-tab' ) ); ?>"><?php esc_html_e( 'Open link in a new tab', 'jetpack' ); ?></label>
</p>
- <?php
+ <?php
}
/**
* Generates template to add icons.
*
- * @param array $args Template arguments
+ * @param array $args Template arguments.
*/
- static function render_icons_template( $args = array() ) {
+ private static function render_icons_template( $args = array() ) {
$defaults = array(
'url-icon-id' => '',
'url-icon-name' => '',
@@ -311,7 +339,7 @@ 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"/>',
+ '<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' ),
@@ -364,7 +392,7 @@ class Jetpack_Widget_Social_Icons extends WP_Widget {
$aria_hidden = ' aria-hidden="true"';
// Begin SVG markup.
- $svg = '<svg class="icon icon-' . esc_attr( $args['icon'] ) . '"' . $aria_hidden . ' role="img">';
+ $svg = '<svg class="icon icon-' . esc_attr( $args['icon'] ) . '"' . $aria_hidden . ' role="presentation">';
/*
* Display the icon.
@@ -388,277 +416,256 @@ class Jetpack_Widget_Social_Icons extends WP_Widget {
public function get_supported_icons() {
$social_links_icons = array(
array(
- 'url' => '500px.com',
+ 'url' => array( '500px.com' ),
'icon' => '500px',
'label' => '500px',
),
array(
- 'url' => 'amazon.cn',
- 'icon' => 'amazon',
- 'label' => 'Amazon',
- ),
- array(
- 'url' => 'amazon.in',
- 'icon' => 'amazon',
- 'label' => 'Amazon',
- ),
- array(
- 'url' => 'amazon.fr',
- 'icon' => 'amazon',
- 'label' => 'Amazon',
- ),
- array(
- 'url' => 'amazon.de',
- 'icon' => 'amazon',
- 'label' => 'Amazon',
- ),
- array(
- 'url' => 'amazon.it',
- 'icon' => 'amazon',
- 'label' => 'Amazon',
- ),
- array(
- 'url' => 'amazon.nl',
- 'icon' => 'amazon',
- 'label' => 'Amazon',
- ),
- array(
- 'url' => 'amazon.es',
- 'icon' => 'amazon',
- 'label' => 'Amazon',
- ),
- array(
- 'url' => 'amazon.co',
- 'icon' => 'amazon',
- 'label' => 'Amazon',
- ),
- array(
- 'url' => 'amazon.ca',
- 'icon' => 'amazon',
- 'label' => 'Amazon',
- ),
- array(
- 'url' => 'amazon.com',
+ 'url' => array(
+ 'amazon.cn',
+ 'amazon.in',
+ 'amazon.fr',
+ 'amazon.de',
+ 'amazon.it',
+ 'amazon.nl',
+ 'amazon.es',
+ 'amazon.co',
+ 'amazon.ca',
+ 'amazon.com',
+ ),
'icon' => 'amazon',
'label' => 'Amazon',
),
array(
- 'url' => 'apple.com',
+ 'url' => array( 'apple.com' ),
'icon' => 'apple',
'label' => 'Apple',
),
array(
- 'url' => 'itunes.com',
+ 'url' => array( 'itunes.com' ),
'icon' => 'apple',
'label' => 'iTunes',
),
array(
- 'url' => 'bandcamp.com',
+ 'url' => array( 'bandcamp.com' ),
'icon' => 'bandcamp',
'label' => 'Bandcamp',
),
array(
- 'url' => 'behance.net',
+ 'url' => array( 'behance.net' ),
'icon' => 'behance',
'label' => 'Behance',
),
array(
- 'url' => 'codepen.io',
+ 'url' => array( 'codepen.io' ),
'icon' => 'codepen',
'label' => 'CodePen',
),
array(
- 'url' => 'deviantart.com',
+ 'url' => array( 'deviantart.com' ),
'icon' => 'deviantart',
'label' => 'DeviantArt',
),
array(
- 'url' => 'digg.com',
+ 'url' => array( 'digg.com' ),
'icon' => 'digg',
'label' => 'Digg',
),
array(
- 'url' => 'discord.gg',
+ 'url' => array( 'discord.gg', 'discordapp.com' ),
'icon' => 'discord',
'label' => 'Discord',
),
array(
- 'url' => 'discordapp.com',
- 'icon' => 'discord',
- 'label' => 'Discord',
- ),
- array(
- 'url' => 'dribbble.com',
+ 'url' => array( 'dribbble.com' ),
'icon' => 'dribbble',
'label' => 'Dribbble',
),
array(
- 'url' => 'dropbox.com',
+ 'url' => array( 'dropbox.com' ),
'icon' => 'dropbox',
'label' => 'Dropbox',
),
array(
- 'url' => 'etsy.com',
+ 'url' => array( 'etsy.com' ),
'icon' => 'etsy',
'label' => 'Etsy',
),
array(
- 'url' => 'facebook.com',
+ 'url' => array( 'facebook.com' ),
'icon' => 'facebook',
'label' => 'Facebook',
),
array(
- 'url' => '/feed/',
+ 'url' => array(
+ '/feed/', // WordPress default feed url.
+ '/feeds/', // Blogspot and others.
+ '/blog/feed', // No trailing slash WordPress feed, could use /feed but may match unexpectedly.
+ 'format=RSS', // Squarespace and others.
+ '/rss', // Tumblr.
+ '/.rss', // Reddit.
+ '/rss.xml', // Moveable Type, Typepad.
+ 'http://rss.', // Old custom format.
+ 'https://rss.', // Old custom format.
+ 'rss=1',
+ '/feed=rss', // Catches feed=rss / feed=rss2.
+ '?feed=rss', // WordPress non-permalink - Catches feed=rss / feed=rss2.
+ '?feed=rdf', // WordPress non-permalink.
+ '?feed=atom', // WordPress non-permalink.
+ 'http://feeds.', // FeedBurner.
+ 'https://feeds.', // FeedBurner.
+ '/feed.xml', // Feedburner Alias, and others.
+ '/index.xml', // Moveable Type, and others.
+ '/atom.xml', // Typepad, Squarespace.
+ '.atom', // Shopify blog.
+ '/atom', // Some non-WordPress feeds.
+ 'index.rdf', // Typepad.
+ ),
'icon' => 'feed',
'label' => __( 'RSS Feed', 'jetpack' ),
),
array(
- 'url' => 'flickr.com',
+ 'url' => array( 'flickr.com' ),
'icon' => 'flickr',
'label' => 'Flickr',
),
array(
- 'url' => 'foursquare.com',
+ 'url' => array( 'foursquare.com' ),
'icon' => 'foursquare',
'label' => 'Foursquare',
),
array(
- 'url' => 'goodreads.com',
+ 'url' => array( 'goodreads.com' ),
'icon' => 'goodreads',
'label' => 'Goodreads',
- ),
+ ),
array(
- 'url' => 'google.com',
+ 'url' => array( 'google.com', 'google.co.uk', 'google.ca', 'google.cn', 'google.it' ),
'icon' => 'google',
'label' => 'Google',
),
array(
- 'url' => 'github.com',
+ 'url' => array( 'github.com' ),
'icon' => 'github',
'label' => 'GitHub',
),
array(
- 'url' => 'instagram.com',
+ 'url' => array( 'instagram.com' ),
'icon' => 'instagram',
'label' => 'Instagram',
),
array(
- 'url' => 'linkedin.com',
+ 'url' => array( 'linkedin.com' ),
'icon' => 'linkedin',
'label' => 'LinkedIn',
),
array(
- 'url' => 'mailto:',
+ 'url' => array( 'mailto:' ),
'icon' => 'mail',
'label' => __( 'Email', 'jetpack' ),
),
array(
- 'url' => 'meetup.com',
+ 'url' => array( 'meetup.com' ),
'icon' => 'meetup',
'label' => 'Meetup',
),
array(
- 'url' => 'medium.com',
+ 'url' => array( 'medium.com' ),
'icon' => 'medium',
'label' => 'Medium',
),
array(
- 'url' => 'pinterest.',
+ 'url' => array( 'pinterest.' ),
'icon' => 'pinterest',
'label' => 'Pinterest',
),
array(
- 'url' => 'getpocket.com',
+ 'url' => array( 'getpocket.com' ),
'icon' => 'pocket',
'label' => 'Pocket',
),
array(
- 'url' => 'reddit.com',
+ 'url' => array( 'reddit.com' ),
'icon' => 'reddit',
'label' => 'Reddit',
),
array(
- 'url' => 'skype.com',
+ 'url' => array( 'skype.com' ),
'icon' => 'skype',
'label' => 'Skype',
),
array(
- 'url' => 'skype:',
+ 'url' => array( 'skype:' ),
'icon' => 'skype',
'label' => 'Skype',
),
array(
- 'url' => 'slideshare.net',
+ 'url' => array( 'slideshare.net' ),
'icon' => 'slideshare',
'label' => 'SlideShare',
),
array(
- 'url' => 'snapchat.com',
+ 'url' => array( 'snapchat.com' ),
'icon' => 'snapchat',
'label' => 'Snapchat',
),
array(
- 'url' => 'soundcloud.com',
+ 'url' => array( 'soundcloud.com' ),
'icon' => 'soundcloud',
'label' => 'SoundCloud',
),
array(
- 'url' => 'spotify.com',
+ 'url' => array( 'spotify.com' ),
'icon' => 'spotify',
'label' => 'Spotify',
),
array(
- 'url' => 'stackoverflow.com',
+ 'url' => array( 'stackoverflow.com' ),
'icon' => 'stackoverflow',
'label' => 'Stack Overflow',
),
array(
- 'url' => 'stumbleupon.com',
+ 'url' => array( 'stumbleupon.com' ),
'icon' => 'stumbleupon',
'label' => 'StumbleUpon',
),
array(
- 'url' => 'tumblr.com',
+ 'url' => array( 'tumblr.com' ),
'icon' => 'tumblr',
'label' => 'Tumblr',
),
array(
- 'url' => 'twitch.tv',
+ 'url' => array( 'twitch.tv' ),
'icon' => 'twitch',
'label' => 'Twitch',
),
array(
- 'url' => 'twitter.com',
+ 'url' => array( 'twitter.com' ),
'icon' => 'twitter',
'label' => 'Twitter',
),
array(
- 'url' => 'vimeo.com',
+ 'url' => array( 'vimeo.com' ),
'icon' => 'vimeo',
'label' => 'Vimeo',
),
array(
- 'url' => 'vk.com',
+ 'url' => array( 'vk.com' ),
'icon' => 'vk',
'label' => 'VK',
),
array(
- 'url' => 'wordpress.com',
- 'icon' => 'wordpress',
- 'label' => 'WordPress.com',
- ),
- array(
- 'url' => 'wordpress.org',
+ 'url' => array( 'wordpress.com', 'wordpress.org' ),
'icon' => 'wordpress',
'label' => 'WordPress',
),
array(
- 'url' => 'yelp.com',
+ 'url' => array( 'yelp.com' ),
'icon' => 'yelp',
'label' => 'Yelp',
),
array(
- 'url' => 'youtube.com',
+ 'url' => array( 'youtube.com' ),
'icon' => 'youtube',
'label' => 'YouTube',
),
diff --git a/plugins/jetpack/modules/widgets/social-media-icons.php b/plugins/jetpack/modules/widgets/social-media-icons.php
index 0e8028ef..214e6ed9 100644
--- a/plugins/jetpack/modules/widgets/social-media-icons.php
+++ b/plugins/jetpack/modules/widgets/social-media-icons.php
@@ -147,7 +147,7 @@ class WPCOM_social_media_icons_widget extends WP_Widget {
/** Check if full URL entered in configuration, use it instead of tinkering **/
if (
in_array(
- parse_url( $username, PHP_URL_SCHEME ),
+ wp_parse_url( $username, PHP_URL_SCHEME ),
array( 'http', 'https' )
)
) {
diff --git a/plugins/jetpack/modules/widgets/top-posts.php b/plugins/jetpack/modules/widgets/top-posts.php
index cdcd59d1..9a804392 100644
--- a/plugins/jetpack/modules/widgets/top-posts.php
+++ b/plugins/jetpack/modules/widgets/top-posts.php
@@ -310,7 +310,7 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
if ( ! $posts ) {
$link = 'https://jetpack.com/support/getting-more-views-and-traffic/';
if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) {
- $link = 'http://en.support.wordpress.com/getting-more-site-traffic/';
+ $link = 'https://en.support.wordpress.com/getting-more-site-traffic/';
}
if ( current_user_can( 'edit_theme_options' ) ) {
@@ -363,7 +363,7 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
$image = Jetpack_PostImages::get_image(
$post['post_id'],
array(
- 'fallback_to_avatars' => true,
+ 'fallback_to_avatars' => (bool) $get_image_options['fallback_to_avatars'],
'width' => (int) $width,
'height' => (int) $height,
'avatar_size' => (int) $get_image_options['avatar_size'],
@@ -406,11 +406,16 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
*/
$filtered_permalink = apply_filters( 'jetpack_top_posts_widget_permalink', $post['permalink'], $post );
- ?>
- <a href="<?php echo esc_url( $filtered_permalink ); ?>" title="<?php echo esc_attr( wp_kses( $post['title'], array() ) ); ?>" class="bump-view" data-bump-view="tp">
- <img width="<?php echo absint( $width ); ?>" height="<?php echo absint( $height ); ?>" src="<?php echo esc_url( $post['image'] ); ?>" alt="<?php echo esc_attr( wp_kses( $post['title'], array() ) ); ?>" data-pin-nopin="true" />
- </a>
- <?php
+ printf(
+ '<a href="%1$s" title="%2$s" class="bump-view" data-bump-view="tp"%3$s><img width="%4$d" height="%5$d" src="%6$s" alt="%2$s" data-pin-nopin="true"/></a>',
+ esc_url( $filtered_permalink ),
+ esc_attr( wp_kses( $post['title'], array() ) ),
+ ( get_queried_object_id() === $post['post_id'] ? ' aria-current="page"' : '' ),
+ absint( $width ),
+ absint( $height ),
+ esc_url( $post['image'] )
+ );
+
/**
* Fires after each Top Post result, inside <li>.
*
@@ -437,16 +442,24 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
/** This filter is documented in modules/widgets/top-posts.php */
$filtered_permalink = apply_filters( 'jetpack_top_posts_widget_permalink', $post['permalink'], $post );
- ?>
- <a href="<?php echo esc_url( $filtered_permalink ); ?>" title="<?php echo esc_attr( wp_kses( $post['title'], array() ) ); ?>" class="bump-view" data-bump-view="tp">
- <img width="<?php echo absint( $width ); ?>" height="<?php echo absint( $height ); ?>" src="<?php echo esc_url( $post['image'] ); ?>" class='widgets-list-layout-blavatar' alt="<?php echo esc_attr( wp_kses( $post['title'], array() ) ); ?>" data-pin-nopin="true" />
- </a>
- <div class="widgets-list-layout-links">
- <a href="<?php echo esc_url( $filtered_permalink ); ?>" class="bump-view" data-bump-view="tp">
- <?php echo esc_html( wp_kses( $post['title'], array() ) ); ?>
+
+ printf(
+ '<a href="%1$s" title="%2$s" class="bump-view" data-bump-view="tp"%3$s>
+ <img width="%4$d" height="%5$d" src="%6$s" alt="%2$s" data-pin-nopin="true" class="widgets-list-layout-blavatar"/>
</a>
- </div>
- <?php
+ <div class="widgets-list-layout-links">
+ <a href="%1$s" title="%2$s" class="bump-view" data-bump-view="tp"%3$s>%7$s</a>
+ </div>
+ ',
+ esc_url( $filtered_permalink ),
+ esc_attr( wp_kses( $post['title'], array() ) ),
+ ( get_queried_object_id() === $post['post_id'] ? ' aria-current="page"' : '' ),
+ absint( $width ),
+ absint( $height ),
+ esc_url( $post['image'] ),
+ esc_html( wp_kses( $post['title'], array() ) )
+ );
+
/** This action is documented in modules/widgets/top-posts.php */
do_action( 'jetpack_widget_top_posts_after_post', $post['post_id'] );
?>
@@ -467,11 +480,14 @@ class Jetpack_Top_Posts_Widget extends WP_Widget {
/** This filter is documented in modules/widgets/top-posts.php */
$filtered_permalink = apply_filters( 'jetpack_top_posts_widget_permalink', $post['permalink'], $post );
- ?>
- <a href="<?php echo esc_url( $filtered_permalink ); ?>" class="bump-view" data-bump-view="tp">
- <?php echo esc_html( wp_kses( $post['title'], array() ) ); ?>
- </a>
- <?php
+
+ printf(
+ '<a href="%1$s" class="bump-view" data-bump-view="tp"%2$s>%3$s</a>',
+ esc_url( $filtered_permalink ),
+ ( get_queried_object_id() === $post['post_id'] ? ' aria-current="page"' : '' ),
+ esc_html( wp_kses( $post['title'], array() ) )
+ );
+
/** This action is documented in modules/widgets/top-posts.php */
do_action( 'jetpack_widget_top_posts_after_post', $post['post_id'] );
?>
diff --git a/plugins/jetpack/modules/widgets/twitter-timeline.php b/plugins/jetpack/modules/widgets/twitter-timeline.php
index 0f16e330..6f9662a3 100644
--- a/plugins/jetpack/modules/widgets/twitter-timeline.php
+++ b/plugins/jetpack/modules/widgets/twitter-timeline.php
@@ -8,6 +8,8 @@
* - https://dev.twitter.com/docs/embedded-timelines
*/
+use Automattic\Jetpack\Assets;
+
/**
* Register the widget for use in Appearance -> Widgets
*/
@@ -65,7 +67,7 @@ class Jetpack_Twitter_Timeline_Widget extends WP_Widget {
if ( 'widgets.php' === $hook ) {
wp_enqueue_script(
'twitter-timeline-admin',
- Jetpack::get_file_url_for_environment(
+ Assets::get_file_url_for_environment(
'_inc/build/widgets/twitter-timeline-admin.min.js',
'modules/widgets/twitter-timeline-admin.js'
)
diff --git a/plugins/jetpack/modules/widgets/wordpress-post-widget.php b/plugins/jetpack/modules/widgets/wordpress-post-widget.php
index f518ad61..fb9ffa7a 100644
--- a/plugins/jetpack/modules/widgets/wordpress-post-widget.php
+++ b/plugins/jetpack/modules/widgets/wordpress-post-widget.php
@@ -4,7 +4,7 @@
* Description: Displays recent posts from a WordPress.com or Jetpack-enabled self-hosted WordPress site.
* Version: 1.0
* Author: Brad Angelcyk, Kathryn Presner, Justin Shreve, Carolyn Sonnek
- * Author URI: http://automattic.com
+ * Author URI: https://automattic.com
* License: GPL2
*/
diff --git a/plugins/jetpack/modules/widgets/wordpress-post-widget/class.jetpack-display-posts-widget.php b/plugins/jetpack/modules/widgets/wordpress-post-widget/class.jetpack-display-posts-widget.php
index 265e2ebb..723bc5a5 100644
--- a/plugins/jetpack/modules/widgets/wordpress-post-widget/class.jetpack-display-posts-widget.php
+++ b/plugins/jetpack/modules/widgets/wordpress-post-widget/class.jetpack-display-posts-widget.php
@@ -1,5 +1,7 @@
<?php
+use Automattic\Jetpack\Status;
+
/*
* Display a list of recent posts from a WordPress.com or Jetpack-enabled blog.
*/
@@ -145,7 +147,7 @@ class Jetpack_Display_Posts_Widget extends Jetpack_Display_Posts_Widget__Base {
/**
* If Jetpack is not active or in development mode, we don't want to update widget data.
*/
- if ( ! Jetpack::is_active() && ! Jetpack::is_development_mode() ) {
+ if ( ! Jetpack::is_active() && ! ( new Status() )->is_development_mode() ) {
return false;
}
diff --git a/plugins/jetpack/modules/widgets/wordpress-post-widget/style.css b/plugins/jetpack/modules/widgets/wordpress-post-widget/style.css
index 651ec153..026e40db 100644
--- a/plugins/jetpack/modules/widgets/wordpress-post-widget/style.css
+++ b/plugins/jetpack/modules/widgets/wordpress-post-widget/style.css
@@ -3,20 +3,13 @@
}
.jetpack-display-remote-posts h4 {
- font-size: 90%;
margin: 5px 0;
padding: 0;
}
-.jetpack-display-remote-posts h4 a {
- text-decoration: none;
-}
-
.jetpack-display-remote-posts p {
- margin: 0 !important;
+ margin: 0;
padding: 0;
- line-height: 1.4em !important;
- font-size: 90%;
}
.jetpack-display-remote-posts img {