PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.1
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.1
16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 All 504 releases
← All changes | modules/widgets/gravatar-profile.php +41 -12 12.5.2 → 16.3-a.1 View file →
@@ -1,6 +1,10 @@
1 1 <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2 2
3 +if ( ! defined( 'ABSPATH' ) ) {
4 + exit( 0 );
5 +}
6 +
3 7 // phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files.
4 8
5 9 add_action( 'widgets_init', 'jetpack_gravatar_profile_widget_init' );
6 10 /**
@@ -114,15 +118,32 @@
114 118 'urls' => array(),
115 119 'accounts' => array(),
116 120 )
117 121 );
118 - $gravatar_url = add_query_arg( 's', 320, $profile['thumbnailUrl'] ); // The default grav returned by grofiles is super small.
122 + $base_width = 320;
123 + $gravatar_url = add_query_arg( 's', $base_width, $profile['thumbnailUrl'] ); // The default grav returned by grofiles is super small.
119 124
125 + // Generate a srcset with larger sizes for high DPI screens.
126 + $srcset = '';
127 + $multipliers = array( 1, 1.5, 2, 3, 4 );
128 + $srcset_values = array();
129 + foreach ( $multipliers as $multiplier ) {
130 + $srcset_width = (int) ( $base_width * $multiplier );
131 + $srcset_url = add_query_arg( 's', $srcset_width, $profile['thumbnailUrl'] );
132 + $srcset_values[] = "{$srcset_url} {$multiplier}x";
133 + }
134 + $srcset = implode( ', ', $srcset_values );
135 +
120 136 // Enqueue front end assets.
121 137 $this->enqueue_scripts();
122 138
123 139 ?>
124 - <img src="<?php echo esc_url( $gravatar_url ); ?>" class="grofile-thumbnail no-grav" alt="<?php echo esc_attr( $profile['displayName'] ); ?>" />
140 + <img
141 + src="<?php echo esc_url( $gravatar_url ); ?>"
142 + srcset="<?php echo esc_attr( $srcset ); ?>"
143 + class="grofile-thumbnail no-grav"
144 + alt="<?php echo esc_attr( $profile['displayName'] ); ?>"
145 + loading="lazy" />
125 146 <div class="grofile-meta">
126 147 <h4><a href="<?php echo esc_url( $profile['profileUrl'] ); ?>"><?php echo esc_html( $profile['displayName'] ); ?></a></h4>
127 148 <p><?php echo wp_kses_post( $profile['aboutMe'] ); ?></p>
128 149 </div>
@@ -133,9 +154,9 @@
133 154 $this->display_personal_links( (array) $profile['urls'] );
134 155 }
135 156
136 157 if ( $instance['show_account_links'] ) {
137 - $this->display_accounts( (array) $profile['accounts'] );
158 + $this->display_accounts( (array) $profile['accounts'], $profile['displayName'] );
138 159 }
139 160
140 161 ?>
141 162
@@ -199,8 +220,9 @@
199 220 </h4>
200 221 <ul class="grofile-urls grofile-links">
201 222
202 223 <?php foreach ( $personal_links as $personal_link ) : ?>
224 + <?php if ( is_array( $personal_link ) ) : ?>
203 225 <li>
204 226 <a href="<?php echo esc_url( $personal_link['value'] ); ?>">
205 227 <?php
206 228 $link_title = ( ! empty( $personal_link['title'] ) ) ? $personal_link['title'] : $personal_link['value'];
@@ -207,8 +229,9 @@
207 229 echo esc_html( $link_title );
208 230 ?>
209 231 </a>
210 232 </li>
233 + <?php endif; ?>
211 234 <?php endforeach; ?>
212 235 </ul>
213 236
214 237 <?php
@@ -216,11 +239,12 @@
216 239
217 240 /**
218 241 * Displays the "Verified Services" accounts.
219 242 *
220 - * @param array $accounts Array of social accounts.
243 + * @param array $accounts Array of social accounts.
244 + * @param string $display_name Gravatar display name of the user.
221 245 */
222 - public function display_accounts( $accounts = array() ) {
246 + public function display_accounts( $accounts = array(), $display_name = '' ) {
223 247 if ( empty( $accounts ) ) {
224 248 return;
225 249 }
226 250 ?>
@@ -247,17 +271,18 @@
247 271 <ul class="grofile-urls grofile-accounts">
248 272
249 273 <?php
250 274 foreach ( $accounts as $account ) :
251 - if ( 'true' !== $account['verified'] ) {
275 + $is_hidden = $account['is_hidden'] ?? false;
276 + if ( true !== $account['verified'] || $is_hidden ) {
252 277 continue;
253 278 }
254 279
255 280 $sanitized_service_name = $this->get_sanitized_service_name( $account['shortname'] );
256 281 $link_title = sprintf(
257 - /* translators: %1$s: service username. %2$s: service name ( Facebook, Twitter, etc.) */
282 + /* translators: %1$s: account display name. %2$s: service name ( Facebook, Twitter, etc.) */
258 283 _x( '%1$s on %2$s', '1: User Name, 2: Service Name (Facebook, Twitter, ...)', 'jetpack' ),
259 - esc_html( $account['display'] ),
284 + esc_html( $display_name ),
260 285 esc_html( $sanitized_service_name )
261 286 );
262 287 ?>
263 288
@@ -262,9 +287,12 @@
262 287 ?>
263 288
264 289 <li>
265 290 <a href="<?php echo esc_url( $account['url'] ); ?>" title="<?php echo esc_html( $link_title ); ?>">
266 - <span class="grofile-accounts-logo grofile-accounts-<?php echo esc_attr( $account['shortname'] ); ?> accounts_<?php echo esc_attr( $account['shortname'] ); ?>"></span>
291 + <span
292 + class="grofile-accounts-logo grofile-accounts-<?php echo esc_attr( $account['shortname'] ); ?> accounts_<?php echo esc_attr( $account['shortname'] ); ?>"
293 + style="background-image: url('<?php echo esc_attr( $account['iconUrl'] ); ?>')"
294 + ></span>
267 295 </a>
268 296 </li>
269 297
270 298 <?php endforeach; ?>
@@ -297,13 +325,14 @@
297 325 /**
298 326 * Outputs the widget settings form.
299 327 *
300 328 * @param array $instance Current settings.
329 + * @return string|void
301 330 */
302 331 public function form( $instance ) {
303 - $title = isset( $instance['title'] ) ? $instance['title'] : '';
304 - $email = isset( $instance['email'] ) ? $instance['email'] : '';
305 - $email_user = isset( $instance['email_user'] ) ? $instance['email_user'] : get_current_user_id();
332 + $title = $instance['title'] ?? '';
333 + $email = $instance['email'] ?? '';
334 + $email_user = $instance['email_user'] ?? get_current_user_id();
306 335 $show_personal_links = isset( $instance['show_personal_links'] ) ? (bool) $instance['show_personal_links'] : '';
307 336 $show_account_links = isset( $instance['show_account_links'] ) ? (bool) $instance['show_account_links'] : '';
308 337 $profile_url = 'https://gravatar.com/profile/edit';
309 338