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/gravatar-hovercards.php +14 -7 13.5.216.3-a.1 View file →
@@ -1,8 +1,8 @@
1 1 <?php
2 2 /**
3 3 * Module Name: Gravatar Hovercards
4 - * Module Description: Enable pop-up business cards over commenters’ Gravatars.
4 + * Module Description: Show a user’s Gravatar profile when visitors hover over their name or image.
5 5 * Sort Order: 11
6 6 * Recommendation Order: 13
7 7 * First Introduced: 1.1
8 8 * Requires Connection: No
@@ -13,8 +13,12 @@
13 13 *
14 14 * @package automattic/jetpack
15 15 */
16 16
17 +if ( ! defined( 'ABSPATH' ) ) {
18 + exit( 0 );
19 +}
20 +
17 21 define( 'GROFILES__CACHE_BUSTER', gmdate( 'YW' ) );
18 22
19 23 /**
20 24 * Actions that are run on init.
@@ -207,12 +211,12 @@
207 211 wp_cache_set( $cache_key, $response_body, $cache_group, 60 * MINUTE_IN_SECONDS );
208 212 }
209 213 }
210 214
211 - $profile = isset( $response_body->entry[0] ) ? $response_body->entry[0] : null;
212 - $display_name = isset( $profile->displayName ) ? $profile->displayName : ''; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
213 - $location = isset( $profile->currentLocation ) ? $profile->currentLocation : ''; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
214 - $description = isset( $profile->aboutMe ) ? $profile->aboutMe : ''; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
215 + $profile = $response_body->entry[0] ?? null;
216 + $display_name = $profile->displayName ?? ''; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
217 + $location = $profile->currentLocation ?? ''; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
218 + $description = $profile->aboutMe ?? ''; // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
215 219
216 220 $avatar = '
217 221 <figure data-amp-lightbox="true">
218 222 ' . $avatar . '
@@ -244,10 +248,8 @@
244 248 }
245 249
246 250 /**
247 251 * Loads Gravatar Hovercard script.
248 - *
249 - * @todo is_singular() only?
250 252 */
251 253 function grofiles_attach_cards() {
252 254
253 255 // Is the display of Avatars disabled?
@@ -256,8 +258,13 @@
256 258 }
257 259
258 260 // Is the display of Gravatar Hovercards disabled?
259 261 if ( 'disabled' === Jetpack_Options::get_option_and_ensure_autoload( 'gravatar_disable_hovercards', '0' ) ) {
262 + return;
263 + }
264 +
265 + // Hovercards are only relevant on pages that render avatars.
266 + if ( ! is_singular() && ! is_home() && ! is_front_page() && ! is_archive() && ! is_search() ) {
260 267 return;
261 268 }
262 269
263 270 if ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() ) {