| @@ -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 | /** |
| @@ -150,9 +154,9 @@ | ||
| 150 | 154 | $this->display_personal_links( (array) $profile['urls'] ); |
| 151 | 155 | } |
| 152 | 156 | |
| 153 | 157 | if ( $instance['show_account_links'] ) { |
| 154 | - $this->display_accounts( (array) $profile['accounts'] ); | |
| 158 | + $this->display_accounts( (array) $profile['accounts'], $profile['displayName'] ); | |
| 155 | 159 | } |
| 156 | 160 | |
| 157 | 161 | ?> |
| 158 | 162 | |
| @@ -216,8 +220,9 @@ | ||
| 216 | 220 | </h4> |
| 217 | 221 | <ul class="grofile-urls grofile-links"> |
| 218 | 222 | |
| 219 | 223 | <?php foreach ( $personal_links as $personal_link ) : ?> |
| 224 | + <?php if ( is_array( $personal_link ) ) : ?> | |
| 220 | 225 | <li> |
| 221 | 226 | <a href="<?php echo esc_url( $personal_link['value'] ); ?>"> |
| 222 | 227 | <?php |
| 223 | 228 | $link_title = ( ! empty( $personal_link['title'] ) ) ? $personal_link['title'] : $personal_link['value']; |
| @@ -224,8 +229,9 @@ | ||
| 224 | 229 | echo esc_html( $link_title ); |
| 225 | 230 | ?> |
| 226 | 231 | </a> |
| 227 | 232 | </li> |
| 233 | + <?php endif; ?> | |
| 228 | 234 | <?php endforeach; ?> |
| 229 | 235 | </ul> |
| 230 | 236 | |
| 231 | 237 | <?php |
| @@ -233,11 +239,12 @@ | ||
| 233 | 239 | |
| 234 | 240 | /** |
| 235 | 241 | * Displays the "Verified Services" accounts. |
| 236 | 242 | * |
| 237 | - * @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. | |
| 238 | 245 | */ |
| 239 | - public function display_accounts( $accounts = array() ) { | |
| 246 | + public function display_accounts( $accounts = array(), $display_name = '' ) { | |
| 240 | 247 | if ( empty( $accounts ) ) { |
| 241 | 248 | return; |
| 242 | 249 | } |
| 243 | 250 | ?> |
| @@ -264,17 +271,18 @@ | ||
| 264 | 271 | <ul class="grofile-urls grofile-accounts"> |
| 265 | 272 | |
| 266 | 273 | <?php |
| 267 | 274 | foreach ( $accounts as $account ) : |
| 268 | - if ( 'true' !== $account['verified'] ) { | |
| 275 | + $is_hidden = $account['is_hidden'] ?? false; | |
| 276 | + if ( true !== $account['verified'] || $is_hidden ) { | |
| 269 | 277 | continue; |
| 270 | 278 | } |
| 271 | 279 | |
| 272 | 280 | $sanitized_service_name = $this->get_sanitized_service_name( $account['shortname'] ); |
| 273 | 281 | $link_title = sprintf( |
| 274 | - /* 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.) */ | |
| 275 | 283 | _x( '%1$s on %2$s', '1: User Name, 2: Service Name (Facebook, Twitter, ...)', 'jetpack' ), |
| 276 | - esc_html( $account['display'] ), | |
| 284 | + esc_html( $display_name ), | |
| 277 | 285 | esc_html( $sanitized_service_name ) |
| 278 | 286 | ); |
| 279 | 287 | ?> |
| 280 | 288 | |
| @@ -279,9 +287,12 @@ | ||
| 279 | 287 | ?> |
| 280 | 288 | |
| 281 | 289 | <li> |
| 282 | 290 | <a href="<?php echo esc_url( $account['url'] ); ?>" title="<?php echo esc_html( $link_title ); ?>"> |
| 283 | - <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> | |
| 284 | 295 | </a> |
| 285 | 296 | </li> |
| 286 | 297 | |
| 287 | 298 | <?php endforeach; ?> |
| @@ -314,13 +325,14 @@ | ||
| 314 | 325 | /** |
| 315 | 326 | * Outputs the widget settings form. |
| 316 | 327 | * |
| 317 | 328 | * @param array $instance Current settings. |
| 329 | + * @return string|void | |
| 318 | 330 | */ |
| 319 | 331 | public function form( $instance ) { |
| 320 | - $title = isset( $instance['title'] ) ? $instance['title'] : ''; | |
| 321 | - $email = isset( $instance['email'] ) ? $instance['email'] : ''; | |
| 322 | - $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(); | |
| 323 | 335 | $show_personal_links = isset( $instance['show_personal_links'] ) ? (bool) $instance['show_personal_links'] : ''; |
| 324 | 336 | $show_account_links = isset( $instance['show_account_links'] ) ? (bool) $instance['show_account_links'] : ''; |
| 325 | 337 | $profile_url = 'https://gravatar.com/profile/edit'; |
| 326 | 338 | |