diff options
author | 2016-08-23 20:02:23 -0400 | |
---|---|---|
committer | 2016-08-23 20:02:50 -0400 | |
commit | ad3f35663e4e2b80a92166b590d3e2052b5aab91 (patch) | |
tree | 94f987efbdb50e1426956c1c04ac459a19c77e53 /plugins/jetpack/modules/widgets | |
parent | bin/update-wordpress: also update twentyfourteen twentyfifteen twentysixteen (diff) | |
download | blogs-gentoo-ad3f35663e4e2b80a92166b590d3e2052b5aab91.tar.gz blogs-gentoo-ad3f35663e4e2b80a92166b590d3e2052b5aab91.tar.bz2 blogs-gentoo-ad3f35663e4e2b80a92166b590d3e2052b5aab91.zip |
Update plugin jetpack to 4.2.2
Diffstat (limited to 'plugins/jetpack/modules/widgets')
9 files changed, 52 insertions, 94 deletions
diff --git a/plugins/jetpack/modules/widgets/contact-info.php b/plugins/jetpack/modules/widgets/contact-info.php index 552f9b91..fd5bef61 100644 --- a/plugins/jetpack/modules/widgets/contact-info.php +++ b/plugins/jetpack/modules/widgets/contact-info.php @@ -42,26 +42,10 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) { * Enqueue scripts and styles. */ public function enqueue_scripts() { - $google_url = 'https://maps.googleapis.com/maps/api/js'; - /** - * Set a Google Maps API Key. - * - * @since 4.1.0 - * - * @param string $key Google Maps API Key - */ - $key = apply_filters( 'jetpack_google_maps_api_key', null ); - - if ( ! empty( $key ) ) { - $google_url = add_query_arg( 'key', $key, $google_url ); - } - - wp_enqueue_script( 'jquery' ); - wp_enqueue_script( 'google-maps', esc_url( $google_url, null, null ) ); - wp_enqueue_script( 'contact-info-map-js', plugins_url( 'contact-info/contact-info-map.js', __FILE__ ), array( 'jquery', 'google-maps' ), 20150127 ); - wp_enqueue_style( 'contact-info-map-css', plugins_url( 'contact-info/contact-info-map.css', __FILE__ ), null, 20150127 ); + wp_enqueue_style( 'contact-info-map-css', plugins_url( 'contact-info/contact-info-map.css', __FILE__ ), null, 20160623 ); } + /** * Return an associative array of default values * @@ -75,7 +59,8 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) { 'address' => __( "3999 Mission Boulevard,\nSan Diego CA 92109", 'jetpack' ), 'phone' => _x( '1-202-555-1212', 'Example of a phone number', 'jetpack' ), 'hours' => __( "Lunch: 11am - 2pm \nDinner: M-Th 5pm - 11pm, Fri-Sat:5pm - 1am", 'jetpack' ), - 'showmap' => 1, + 'showmap' => 0, + 'apikey' => null, 'lat' => null, 'lon' => null ); @@ -111,12 +96,17 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) { $showmap = $instance['showmap']; + /** This action is documented in modules/widgets/contact-info.php */ if ( $showmap && $this->has_good_map( $instance ) ) { - - $lat = $instance['lat']; - $lon = $instance['lon']; - - echo $this->build_map( $lat, $lon ); + /** + * Set a Google Maps API Key. + * + * @since 4.1.0 + * + * @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 ); } $map_link = $this->build_map_link( $instance['address'] ); @@ -173,6 +163,7 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) { $instance['address'] = wp_kses( $new_instance['address'], array() ); $instance['phone'] = wp_kses( $new_instance['phone'], 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; @@ -186,7 +177,7 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) { $address = $this->urlencode_address( $instance['address'] ); $path = "http://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', null ); + $key = apply_filters( 'jetpack_google_maps_api_key', $instance['apikey'] ); if ( ! empty( $key ) ) { $path = add_query_arg( 'key', $key, $path ); @@ -239,6 +230,8 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) { */ function form( $instance ) { $instance = wp_parse_args( $instance, $this->defaults() ); + wp_enqueue_script( 'contact-info-admin', plugins_url( 'contact-info/contact-info-admin.js', __FILE__ ), array( 'jquery' ), 20160727 ); + ?> <p> <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php esc_html_e( 'Title:', 'jetpack' ); ?></label> @@ -251,7 +244,7 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) { <?php if ( $this->has_good_map( $instance ) ) { ?> - <input class="" 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 ); ?> /> + <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 } @@ -263,6 +256,16 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) { } ?> </p> + + <p class="jp-contact-info-apikey" 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'] ); ?>" /> + <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.' ), array( 'a' => array( 'href' => true ) ) ), 'https://jetpack.com/support/extra-sidebar-widgets/contact-info-widget/' ); ?></small> + </label> + </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'] ); ?>" /> @@ -298,19 +301,14 @@ if ( ! class_exists( 'Jetpack_Contact_Info_Widget' ) ) { * * @return string HTML of the map */ - function build_map( $lat, $lon ) { + function build_map( $address, $api_key = null ) { $this->enqueue_scripts(); + $src = add_query_arg( 'q', urlencode( $address ), 'https://www.google.com/maps/embed/v1/place' ); + if ( ! empty( $api_key ) ) { + $src = add_query_arg( 'key', $api_key, $src ); + } - $lat = esc_attr( $lat ); - $lon = esc_attr( $lon ); - $html = <<<EOT - <div class="contact-map"> - <input type="hidden" class="contact-info-map-lat" value="$lat" /> - <input type="hidden" class="contact-info-map-lon" value="$lon" /> - <div class="contact-info-map-canvas"></div></div> -EOT; - - return $html; + return '<iframe width="600" height="216" frameborder="0" src="' . esc_url( $src ) . '" class="contact-map"></iframe>'; } /** diff --git a/plugins/jetpack/modules/widgets/contact-info/contact-info-admin.js b/plugins/jetpack/modules/widgets/contact-info/contact-info-admin.js new file mode 100644 index 00000000..e38f0dac --- /dev/null +++ b/plugins/jetpack/modules/widgets/contact-info/contact-info-admin.js @@ -0,0 +1,8 @@ +(function( $ ) { + $( document ).on( 'change', '.jp-contact-info-showmap', function() { + var $checkbox = $( this ), + isChecked = $checkbox.is( ':checked' ); + + $checkbox.closest( '.widget' ).find( '.jp-contact-info-apikey' ).toggle( isChecked ); + }); +})( 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 47629e9b..7aa9e698 100644 --- a/plugins/jetpack/modules/widgets/contact-info/contact-info-map.css +++ b/plugins/jetpack/modules/widgets/contact-info/contact-info-map.css @@ -1,11 +1,4 @@ -.contact-info-map-canvas { - height: 216px; - margin: 0; - padding: 0; - overflow: hidden; -} - -/* Prevent Google maps controls from being hidden */ -.gmnoprint img { - max-width: none !important; -} +.contact-map { + max-width: 100%; + border: 0; +}
\ No newline at end of file diff --git a/plugins/jetpack/modules/widgets/contact-info/contact-info-map.js b/plugins/jetpack/modules/widgets/contact-info/contact-info-map.js deleted file mode 100644 index c7036222..00000000 --- a/plugins/jetpack/modules/widgets/contact-info/contact-info-map.js +++ /dev/null @@ -1,41 +0,0 @@ -/* global google */ -/* jshint unused:false */ -jQuery( function( $ ) { - - function setupContactMaps( rootElement ) { - rootElement = $( rootElement || document.body ); - - rootElement.find( 'div.contact-map' ).each( function() { - - // get lat and lon from hidden input values - var lat = jQuery(this).find('.contact-info-map-lat').val(), - lon = jQuery(this).find('.contact-info-map-lon').val(), - lat_lon = new google.maps.LatLng( lat, lon ), - mapOptions = { - zoom: 16, - center: lat_lon, - mapTypeId: google.maps.MapTypeId.ROADMAP - }, - map = new google.maps.Map(jQuery(this).find('.contact-info-map-canvas')[0], mapOptions), - marker = new google.maps.Marker({ - map: map, - position: lat_lon - }); - - google.maps.event.addListenerOnce(map, 'mouseover', function() { - google.maps.event.trigger(map, 'resize'); - }); - - }); - } - - setupContactMaps(); - - if ( 'undefined' !== typeof wp && wp.customize && wp.customize.selectiveRefresh ) { - wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function( placement ) { - if ( wp.isJetpackWidgetPlaced( placement, 'widget_contact_info' ) ) { - setupContactMaps( placement.container ); - } - } ); - } -} ); diff --git a/plugins/jetpack/modules/widgets/gravatar-profile.php b/plugins/jetpack/modules/widgets/gravatar-profile.php index 00e701e2..a82865ea 100644 --- a/plugins/jetpack/modules/widgets/gravatar-profile.php +++ b/plugins/jetpack/modules/widgets/gravatar-profile.php @@ -115,7 +115,7 @@ class Jetpack_Gravatar_Profile_Widget extends WP_Widget { <?php /** - * Fires when an item is displayed on the frontend. + * Fires when an item is displayed on the front end. * * Can be used to track stats about the number of displays for a specific item * diff --git a/plugins/jetpack/modules/widgets/social-media-icons.php b/plugins/jetpack/modules/widgets/social-media-icons.php index f46ef290..fe836d64 100644 --- a/plugins/jetpack/modules/widgets/social-media-icons.php +++ b/plugins/jetpack/modules/widgets/social-media-icons.php @@ -170,7 +170,7 @@ class WPCOM_social_media_icons_widget extends WP_Widget { echo apply_filters( 'jetpack_social_media_icons_widget_output', $html ); } - // backend + // back end public function form( $instance ) { $instance = wp_parse_args( (array) $instance, $this->defaults ); ?> diff --git a/plugins/jetpack/modules/widgets/top-posts.php b/plugins/jetpack/modules/widgets/top-posts.php index 0756a198..fa1222ff 100644 --- a/plugins/jetpack/modules/widgets/top-posts.php +++ b/plugins/jetpack/modules/widgets/top-posts.php @@ -246,7 +246,7 @@ 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( 'http://en.wordpress.com/i/logo/white-gray-80.png' ) ), + 'gravatar_default' => apply_filters( 'jetpack_static_url', set_url_scheme( 'https://en.wordpress.com/i/logo/white-gray-80.png' ) ), ); if ( 'grid' == $display ) { $get_image_options['avatar_size'] = 200; diff --git a/plugins/jetpack/modules/widgets/top-posts/style.css b/plugins/jetpack/modules/widgets/top-posts/style.css index c301ee16..ceeae12b 100644 --- a/plugins/jetpack/modules/widgets/top-posts/style.css +++ b/plugins/jetpack/modules/widgets/top-posts/style.css @@ -28,7 +28,7 @@ margin: 0 2px 4px 0; } -.widget-grid-view-image:image:nth-child(even) { +.widget-grid-view-image:nth-child(even) { float: right; } diff --git a/plugins/jetpack/modules/widgets/twitter-timeline.php b/plugins/jetpack/modules/widgets/twitter-timeline.php index ef9ed60d..4cb663d2 100644 --- a/plugins/jetpack/modules/widgets/twitter-timeline.php +++ b/plugins/jetpack/modules/widgets/twitter-timeline.php @@ -2,7 +2,7 @@ /* * Based on Evolution Twitter Timeline - * (http://wordpress.org/extend/plugins/evolution-twitter-timeline/) + * (https://wordpress.org/extend/plugins/evolution-twitter-timeline/) * For details on Twitter Timelines see: * - https://twitter.com/settings/widgets * - https://dev.twitter.com/docs/embedded-timelines |