| 1 |
<?php |
| 2 |
/* |
| 3 |
* License: GPLv3 |
| 4 |
* License URI: https://www.gnu.org/licenses/gpl.txt |
| 5 |
* Copyright 2012-2026 Jean-Sebastien Morisset (https://wpsso.com/) |
| 6 |
*/ |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
|
| 10 |
die( 'These aren\'t the droids you\'re looking for.' ); |
| 11 |
} |
| 12 |
|
| 13 |
if ( ! class_exists( 'WpssoIntegUserUltimateMember' ) ) { |
| 14 |
|
| 15 |
class WpssoIntegUserUltimateMember { |
| 16 |
|
| 17 |
private $p; // Wpsso class object. |
| 18 |
|
| 19 |
public function __construct( &$plugin ) { |
| 20 |
|
| 21 |
$this->p =& $plugin; |
| 22 |
|
| 23 |
if ( $this->p->debug->enabled ) { |
| 24 |
|
| 25 |
$this->p->debug->mark(); |
| 26 |
} |
| 27 |
|
| 28 |
$this->p->util->add_plugin_filters( $this, array( |
| 29 |
'user_image_urls' => 4, |
| 30 |
), $prio = 500 ); |
| 31 |
} |
| 32 |
|
| 33 |
public function filter_user_image_urls( $urls, $size_names, $user_id, $mod ) { |
| 34 |
|
| 35 |
if ( $this->p->debug->enabled ) { |
| 36 |
|
| 37 |
$this->p->debug->mark(); |
| 38 |
} |
| 39 |
|
| 40 |
static $local_cache = array(); |
| 41 |
|
| 42 |
if ( ! isset( $local_cache[ $user_id ] ) ) { // Key does not exist or value is not null. |
| 43 |
|
| 44 |
$img_size = $this->p->media->get_gravatar_size(); |
| 45 |
$img_url = (string) um_get_user_avatar_url( $mod[ 'id' ], $img_size ); |
| 46 |
|
| 47 |
if ( $this->p->debug->enabled ) { |
| 48 |
|
| 49 |
$this->p->debug->log( 'adding user image url "' . $img_url . '" to local cache' ); |
| 50 |
} |
| 51 |
|
| 52 |
$local_cache[ $user_id ] = $img_url; // Empty string or image URL. |
| 53 |
} |
| 54 |
|
| 55 |
if ( ! empty( $local_cache[ $user_id ] ) ) { // Not false or empty string. |
| 56 |
|
| 57 |
$urls[] = $local_cache[ $user_id ]; |
| 58 |
} |
| 59 |
|
| 60 |
return $urls; |
| 61 |
} |
| 62 |
} |
| 63 |
} |
| 64 |
|