@@ -22,13 +22,18 @@ function __construct() {
2222 apply_filters ( 'jetpack_widget_name ' , __ ( 'Gravatar Profile ' , 'jetpack ' ) ),
2323 array (
2424 'classname ' => 'widget-grofile grofile ' ,
25- 'description ' => __ ( 'Display a mini version of your Gravatar Profile ' , 'jetpack ' )
25+ 'description ' => __ ( 'Display a mini version of your Gravatar Profile ' , 'jetpack ' ),
26+ 'customize_selective_refresh ' => true ,
2627 )
2728 );
2829
2930 if ( is_admin () ) {
3031 add_action ( 'admin_footer-widgets.php ' , array ( $ this , 'admin_script ' ) );
3132 }
33+
34+ if ( is_customize_preview () ) {
35+ add_action ( 'wp_enqueue_scripts ' , array ( $ this , 'enqueue_scripts ' ) );
36+ }
3237 }
3338
3439 function widget ( $ args , $ instance ) {
@@ -69,19 +74,8 @@ function widget( $args, $instance ) {
6974 ) );
7075 $ gravatar_url = add_query_arg ( 's ' , 320 , $ profile ['thumbnailUrl ' ] ); // the default grav returned by grofiles is super small
7176
72- wp_enqueue_style (
73- 'gravatar-profile-widget ' ,
74- plugins_url ( 'gravatar-profile.css ' , __FILE__ ),
75- array (),
76- '20120711 '
77- );
78-
79- wp_enqueue_style (
80- 'gravatar-card-services ' ,
81- is_ssl () ? 'https://secure.gravatar.com/css/services.css ' : 'http://s.gravatar.com/css/services.css ' ,
82- array (),
83- defined ( 'GROFILES__CACHE_BUSTER ' ) ? GROFILES__CACHE_BUSTER : gmdate ( 'YW ' )
84- );
77+ // Enqueue front end assets.
78+ $ this ->enqueue_scripts ();
8579
8680 ?>
8781 <img src="<?php echo esc_url ( $ gravatar_url ); ?> " class="grofile-thumbnail no-grav" alt="<?php echo esc_attr ( $ profile ['displayName ' ] ); ?> " />
@@ -221,6 +215,27 @@ function display_accounts( $accounts = array() ) {
221215 <?php
222216 }
223217
218+ /**
219+ * Enqueue CSS and JavaScript.
220+ *
221+ * @since 3.10
222+ */
223+ function enqueue_scripts () {
224+ wp_enqueue_style (
225+ 'gravatar-profile-widget ' ,
226+ plugins_url ( 'gravatar-profile.css ' , __FILE__ ),
227+ array (),
228+ '20120711 '
229+ );
230+
231+ wp_enqueue_style (
232+ 'gravatar-card-services ' ,
233+ is_ssl () ? 'https://secure.gravatar.com/css/services.css ' : 'http://s.gravatar.com/css/services.css ' ,
234+ array (),
235+ defined ( 'GROFILES__CACHE_BUSTER ' ) ? GROFILES__CACHE_BUSTER : gmdate ( 'YW ' )
236+ );
237+ }
238+
224239 function form ( $ instance ) {
225240 $ title = isset ( $ instance ['title ' ] ) ? $ instance ['title ' ] : '' ;
226241 $ email = isset ( $ instance ['email ' ] ) ? $ instance ['email ' ] : '' ;
0 commit comments