Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../public_h.../wp-inclu...
File: pluggable.php
return apply_filters( 'salt', $cached_salts[ $scheme ], $scheme );
[2500] Fix | Delete
}
[2501] Fix | Delete
endif;
[2502] Fix | Delete
[2503] Fix | Delete
if ( ! function_exists( 'wp_hash' ) ) :
[2504] Fix | Delete
/**
[2505] Fix | Delete
* Gets hash of given string.
[2506] Fix | Delete
*
[2507] Fix | Delete
* @since 2.0.3
[2508] Fix | Delete
*
[2509] Fix | Delete
* @param string $data Plain text to hash.
[2510] Fix | Delete
* @param string $scheme Authentication scheme (auth, secure_auth, logged_in, nonce).
[2511] Fix | Delete
* @return string Hash of $data.
[2512] Fix | Delete
*/
[2513] Fix | Delete
function wp_hash( $data, $scheme = 'auth' ) {
[2514] Fix | Delete
$salt = wp_salt( $scheme );
[2515] Fix | Delete
[2516] Fix | Delete
return hash_hmac( 'md5', $data, $salt );
[2517] Fix | Delete
}
[2518] Fix | Delete
endif;
[2519] Fix | Delete
[2520] Fix | Delete
if ( ! function_exists( 'wp_hash_password' ) ) :
[2521] Fix | Delete
/**
[2522] Fix | Delete
* Creates a hash (encrypt) of a plain text password.
[2523] Fix | Delete
*
[2524] Fix | Delete
* For integration with other applications, this function can be overwritten to
[2525] Fix | Delete
* instead use the other package password checking algorithm.
[2526] Fix | Delete
*
[2527] Fix | Delete
* @since 2.5.0
[2528] Fix | Delete
*
[2529] Fix | Delete
* @global PasswordHash $wp_hasher PHPass object.
[2530] Fix | Delete
*
[2531] Fix | Delete
* @param string $password Plain text user password to hash.
[2532] Fix | Delete
* @return string The hash string of the password.
[2533] Fix | Delete
*/
[2534] Fix | Delete
function wp_hash_password( $password ) {
[2535] Fix | Delete
global $wp_hasher;
[2536] Fix | Delete
[2537] Fix | Delete
if ( empty( $wp_hasher ) ) {
[2538] Fix | Delete
require_once ABSPATH . WPINC . '/class-phpass.php';
[2539] Fix | Delete
// By default, use the portable hash from phpass.
[2540] Fix | Delete
$wp_hasher = new PasswordHash( 8, true );
[2541] Fix | Delete
}
[2542] Fix | Delete
[2543] Fix | Delete
return $wp_hasher->HashPassword( trim( $password ) );
[2544] Fix | Delete
}
[2545] Fix | Delete
endif;
[2546] Fix | Delete
[2547] Fix | Delete
if ( ! function_exists( 'wp_check_password' ) ) :
[2548] Fix | Delete
/**
[2549] Fix | Delete
* Checks the plaintext password against the encrypted Password.
[2550] Fix | Delete
*
[2551] Fix | Delete
* Maintains compatibility between old version and the new cookie authentication
[2552] Fix | Delete
* protocol using PHPass library. The $hash parameter is the encrypted password
[2553] Fix | Delete
* and the function compares the plain text password when encrypted similarly
[2554] Fix | Delete
* against the already encrypted password to see if they match.
[2555] Fix | Delete
*
[2556] Fix | Delete
* For integration with other applications, this function can be overwritten to
[2557] Fix | Delete
* instead use the other package password checking algorithm.
[2558] Fix | Delete
*
[2559] Fix | Delete
* @since 2.5.0
[2560] Fix | Delete
*
[2561] Fix | Delete
* @global PasswordHash $wp_hasher PHPass object used for checking the password
[2562] Fix | Delete
* against the $hash + $password.
[2563] Fix | Delete
* @uses PasswordHash::CheckPassword
[2564] Fix | Delete
*
[2565] Fix | Delete
* @param string $password Plaintext user's password.
[2566] Fix | Delete
* @param string $hash Hash of the user's password to check against.
[2567] Fix | Delete
* @param string|int $user_id Optional. User ID.
[2568] Fix | Delete
* @return bool False, if the $password does not match the hashed password.
[2569] Fix | Delete
*/
[2570] Fix | Delete
function wp_check_password( $password, $hash, $user_id = '' ) {
[2571] Fix | Delete
global $wp_hasher;
[2572] Fix | Delete
[2573] Fix | Delete
// If the hash is still md5...
[2574] Fix | Delete
if ( strlen( $hash ) <= 32 ) {
[2575] Fix | Delete
$check = hash_equals( $hash, md5( $password ) );
[2576] Fix | Delete
if ( $check && $user_id ) {
[2577] Fix | Delete
// Rehash using new hash.
[2578] Fix | Delete
wp_set_password( $password, $user_id );
[2579] Fix | Delete
$hash = wp_hash_password( $password );
[2580] Fix | Delete
}
[2581] Fix | Delete
[2582] Fix | Delete
/**
[2583] Fix | Delete
* Filters whether the plaintext password matches the encrypted password.
[2584] Fix | Delete
*
[2585] Fix | Delete
* @since 2.5.0
[2586] Fix | Delete
*
[2587] Fix | Delete
* @param bool $check Whether the passwords match.
[2588] Fix | Delete
* @param string $password The plaintext password.
[2589] Fix | Delete
* @param string $hash The hashed password.
[2590] Fix | Delete
* @param string|int $user_id User ID. Can be empty.
[2591] Fix | Delete
*/
[2592] Fix | Delete
return apply_filters( 'check_password', $check, $password, $hash, $user_id );
[2593] Fix | Delete
}
[2594] Fix | Delete
[2595] Fix | Delete
/*
[2596] Fix | Delete
* If the stored hash is longer than an MD5,
[2597] Fix | Delete
* presume the new style phpass portable hash.
[2598] Fix | Delete
*/
[2599] Fix | Delete
if ( empty( $wp_hasher ) ) {
[2600] Fix | Delete
require_once ABSPATH . WPINC . '/class-phpass.php';
[2601] Fix | Delete
// By default, use the portable hash from phpass.
[2602] Fix | Delete
$wp_hasher = new PasswordHash( 8, true );
[2603] Fix | Delete
}
[2604] Fix | Delete
[2605] Fix | Delete
$check = $wp_hasher->CheckPassword( $password, $hash );
[2606] Fix | Delete
[2607] Fix | Delete
/** This filter is documented in wp-includes/pluggable.php */
[2608] Fix | Delete
return apply_filters( 'check_password', $check, $password, $hash, $user_id );
[2609] Fix | Delete
}
[2610] Fix | Delete
endif;
[2611] Fix | Delete
[2612] Fix | Delete
if ( ! function_exists( 'wp_generate_password' ) ) :
[2613] Fix | Delete
/**
[2614] Fix | Delete
* Generates a random password drawn from the defined set of characters.
[2615] Fix | Delete
*
[2616] Fix | Delete
* Uses wp_rand() to create passwords with far less predictability
[2617] Fix | Delete
* than similar native PHP functions like `rand()` or `mt_rand()`.
[2618] Fix | Delete
*
[2619] Fix | Delete
* @since 2.5.0
[2620] Fix | Delete
*
[2621] Fix | Delete
* @param int $length Optional. The length of password to generate. Default 12.
[2622] Fix | Delete
* @param bool $special_chars Optional. Whether to include standard special characters.
[2623] Fix | Delete
* Default true.
[2624] Fix | Delete
* @param bool $extra_special_chars Optional. Whether to include other special characters.
[2625] Fix | Delete
* Used when generating secret keys and salts. Default false.
[2626] Fix | Delete
* @return string The random password.
[2627] Fix | Delete
*/
[2628] Fix | Delete
function wp_generate_password( $length = 12, $special_chars = true, $extra_special_chars = false ) {
[2629] Fix | Delete
$chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
[2630] Fix | Delete
if ( $special_chars ) {
[2631] Fix | Delete
$chars .= '!@#$%^&*()';
[2632] Fix | Delete
}
[2633] Fix | Delete
if ( $extra_special_chars ) {
[2634] Fix | Delete
$chars .= '-_ []{}<>~`+=,.;:/?|';
[2635] Fix | Delete
}
[2636] Fix | Delete
[2637] Fix | Delete
$password = '';
[2638] Fix | Delete
for ( $i = 0; $i < $length; $i++ ) {
[2639] Fix | Delete
$password .= substr( $chars, wp_rand( 0, strlen( $chars ) - 1 ), 1 );
[2640] Fix | Delete
}
[2641] Fix | Delete
[2642] Fix | Delete
/**
[2643] Fix | Delete
* Filters the randomly-generated password.
[2644] Fix | Delete
*
[2645] Fix | Delete
* @since 3.0.0
[2646] Fix | Delete
* @since 5.3.0 Added the `$length`, `$special_chars`, and `$extra_special_chars` parameters.
[2647] Fix | Delete
*
[2648] Fix | Delete
* @param string $password The generated password.
[2649] Fix | Delete
* @param int $length The length of password to generate.
[2650] Fix | Delete
* @param bool $special_chars Whether to include standard special characters.
[2651] Fix | Delete
* @param bool $extra_special_chars Whether to include other special characters.
[2652] Fix | Delete
*/
[2653] Fix | Delete
return apply_filters( 'random_password', $password, $length, $special_chars, $extra_special_chars );
[2654] Fix | Delete
}
[2655] Fix | Delete
endif;
[2656] Fix | Delete
[2657] Fix | Delete
if ( ! function_exists( 'wp_rand' ) ) :
[2658] Fix | Delete
/**
[2659] Fix | Delete
* Generates a random non-negative number.
[2660] Fix | Delete
*
[2661] Fix | Delete
* @since 2.6.2
[2662] Fix | Delete
* @since 4.4.0 Uses PHP7 random_int() or the random_compat library if available.
[2663] Fix | Delete
* @since 6.1.0 Returns zero instead of a random number if both `$min` and `$max` are zero.
[2664] Fix | Delete
*
[2665] Fix | Delete
* @global string $rnd_value
[2666] Fix | Delete
*
[2667] Fix | Delete
* @param int $min Optional. Lower limit for the generated number.
[2668] Fix | Delete
* Accepts positive integers or zero. Defaults to 0.
[2669] Fix | Delete
* @param int $max Optional. Upper limit for the generated number.
[2670] Fix | Delete
* Accepts positive integers. Defaults to 4294967295.
[2671] Fix | Delete
* @return int A random non-negative number between min and max.
[2672] Fix | Delete
*/
[2673] Fix | Delete
function wp_rand( $min = null, $max = null ) {
[2674] Fix | Delete
global $rnd_value;
[2675] Fix | Delete
[2676] Fix | Delete
/*
[2677] Fix | Delete
* Some misconfigured 32-bit environments (Entropy PHP, for example)
[2678] Fix | Delete
* truncate integers larger than PHP_INT_MAX to PHP_INT_MAX rather than overflowing them to floats.
[2679] Fix | Delete
*/
[2680] Fix | Delete
$max_random_number = 3000000000 === 2147483647 ? (float) '4294967295' : 4294967295; // 4294967295 = 0xffffffff
[2681] Fix | Delete
[2682] Fix | Delete
if ( null === $min ) {
[2683] Fix | Delete
$min = 0;
[2684] Fix | Delete
}
[2685] Fix | Delete
[2686] Fix | Delete
if ( null === $max ) {
[2687] Fix | Delete
$max = $max_random_number;
[2688] Fix | Delete
}
[2689] Fix | Delete
[2690] Fix | Delete
// We only handle ints, floats are truncated to their integer value.
[2691] Fix | Delete
$min = (int) $min;
[2692] Fix | Delete
$max = (int) $max;
[2693] Fix | Delete
[2694] Fix | Delete
// Use PHP's CSPRNG, or a compatible method.
[2695] Fix | Delete
static $use_random_int_functionality = true;
[2696] Fix | Delete
if ( $use_random_int_functionality ) {
[2697] Fix | Delete
try {
[2698] Fix | Delete
// wp_rand() can accept arguments in either order, PHP cannot.
[2699] Fix | Delete
$_max = max( $min, $max );
[2700] Fix | Delete
$_min = min( $min, $max );
[2701] Fix | Delete
$val = random_int( $_min, $_max );
[2702] Fix | Delete
if ( false !== $val ) {
[2703] Fix | Delete
return absint( $val );
[2704] Fix | Delete
} else {
[2705] Fix | Delete
$use_random_int_functionality = false;
[2706] Fix | Delete
}
[2707] Fix | Delete
} catch ( Error $e ) {
[2708] Fix | Delete
$use_random_int_functionality = false;
[2709] Fix | Delete
} catch ( Exception $e ) {
[2710] Fix | Delete
$use_random_int_functionality = false;
[2711] Fix | Delete
}
[2712] Fix | Delete
}
[2713] Fix | Delete
[2714] Fix | Delete
/*
[2715] Fix | Delete
* Reset $rnd_value after 14 uses.
[2716] Fix | Delete
* 32 (md5) + 40 (sha1) + 40 (sha1) / 8 = 14 random numbers from $rnd_value.
[2717] Fix | Delete
*/
[2718] Fix | Delete
if ( strlen( $rnd_value ) < 8 ) {
[2719] Fix | Delete
if ( defined( 'WP_SETUP_CONFIG' ) ) {
[2720] Fix | Delete
static $seed = '';
[2721] Fix | Delete
} else {
[2722] Fix | Delete
$seed = get_transient( 'random_seed' );
[2723] Fix | Delete
}
[2724] Fix | Delete
$rnd_value = md5( uniqid( microtime() . mt_rand(), true ) . $seed );
[2725] Fix | Delete
$rnd_value .= sha1( $rnd_value );
[2726] Fix | Delete
$rnd_value .= sha1( $rnd_value . $seed );
[2727] Fix | Delete
$seed = md5( $seed . $rnd_value );
[2728] Fix | Delete
if ( ! defined( 'WP_SETUP_CONFIG' ) && ! defined( 'WP_INSTALLING' ) ) {
[2729] Fix | Delete
set_transient( 'random_seed', $seed );
[2730] Fix | Delete
}
[2731] Fix | Delete
}
[2732] Fix | Delete
[2733] Fix | Delete
// Take the first 8 digits for our value.
[2734] Fix | Delete
$value = substr( $rnd_value, 0, 8 );
[2735] Fix | Delete
[2736] Fix | Delete
// Strip the first eight, leaving the remainder for the next call to wp_rand().
[2737] Fix | Delete
$rnd_value = substr( $rnd_value, 8 );
[2738] Fix | Delete
[2739] Fix | Delete
$value = abs( hexdec( $value ) );
[2740] Fix | Delete
[2741] Fix | Delete
// Reduce the value to be within the min - max range.
[2742] Fix | Delete
$value = $min + ( $max - $min + 1 ) * $value / ( $max_random_number + 1 );
[2743] Fix | Delete
[2744] Fix | Delete
return abs( (int) $value );
[2745] Fix | Delete
}
[2746] Fix | Delete
endif;
[2747] Fix | Delete
[2748] Fix | Delete
if ( ! function_exists( 'wp_set_password' ) ) :
[2749] Fix | Delete
/**
[2750] Fix | Delete
* Updates the user's password with a new encrypted one.
[2751] Fix | Delete
*
[2752] Fix | Delete
* For integration with other applications, this function can be overwritten to
[2753] Fix | Delete
* instead use the other package password checking algorithm.
[2754] Fix | Delete
*
[2755] Fix | Delete
* Please note: This function should be used sparingly and is really only meant for single-time
[2756] Fix | Delete
* application. Leveraging this improperly in a plugin or theme could result in an endless loop
[2757] Fix | Delete
* of password resets if precautions are not taken to ensure it does not execute on every page load.
[2758] Fix | Delete
*
[2759] Fix | Delete
* @since 2.5.0
[2760] Fix | Delete
*
[2761] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[2762] Fix | Delete
*
[2763] Fix | Delete
* @param string $password The plaintext new user password.
[2764] Fix | Delete
* @param int $user_id User ID.
[2765] Fix | Delete
*/
[2766] Fix | Delete
function wp_set_password( $password, $user_id ) {
[2767] Fix | Delete
global $wpdb;
[2768] Fix | Delete
[2769] Fix | Delete
$hash = wp_hash_password( $password );
[2770] Fix | Delete
$wpdb->update(
[2771] Fix | Delete
$wpdb->users,
[2772] Fix | Delete
array(
[2773] Fix | Delete
'user_pass' => $hash,
[2774] Fix | Delete
'user_activation_key' => '',
[2775] Fix | Delete
),
[2776] Fix | Delete
array( 'ID' => $user_id )
[2777] Fix | Delete
);
[2778] Fix | Delete
[2779] Fix | Delete
clean_user_cache( $user_id );
[2780] Fix | Delete
[2781] Fix | Delete
/**
[2782] Fix | Delete
* Fires after the user password is set.
[2783] Fix | Delete
*
[2784] Fix | Delete
* @since 6.2.0
[2785] Fix | Delete
*
[2786] Fix | Delete
* @param string $password The plaintext password just set.
[2787] Fix | Delete
* @param int $user_id The ID of the user whose password was just set.
[2788] Fix | Delete
*/
[2789] Fix | Delete
do_action( 'wp_set_password', $password, $user_id );
[2790] Fix | Delete
}
[2791] Fix | Delete
endif;
[2792] Fix | Delete
[2793] Fix | Delete
if ( ! function_exists( 'get_avatar' ) ) :
[2794] Fix | Delete
/**
[2795] Fix | Delete
* Retrieves the avatar `<img>` tag for a user, email address, MD5 hash, comment, or post.
[2796] Fix | Delete
*
[2797] Fix | Delete
* @since 2.5.0
[2798] Fix | Delete
* @since 4.2.0 Added the optional `$args` parameter.
[2799] Fix | Delete
* @since 5.5.0 Added the `loading` argument.
[2800] Fix | Delete
* @since 6.1.0 Added the `decoding` argument.
[2801] Fix | Delete
* @since 6.3.0 Added the `fetchpriority` argument.
[2802] Fix | Delete
*
[2803] Fix | Delete
* @param mixed $id_or_email The avatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
[2804] Fix | Delete
* user email, WP_User object, WP_Post object, or WP_Comment object.
[2805] Fix | Delete
* @param int $size Optional. Height and width of the avatar in pixels. Default 96.
[2806] Fix | Delete
* @param string $default_value URL for the default image or a default type. Accepts:
[2807] Fix | Delete
* - '404' (return a 404 instead of a default image)
[2808] Fix | Delete
* - 'retro' (a 8-bit arcade-style pixelated face)
[2809] Fix | Delete
* - 'robohash' (a robot)
[2810] Fix | Delete
* - 'monsterid' (a monster)
[2811] Fix | Delete
* - 'wavatar' (a cartoon face)
[2812] Fix | Delete
* - 'identicon' (the "quilt", a geometric pattern)
[2813] Fix | Delete
* - 'mystery', 'mm', or 'mysteryman' (The Oyster Man)
[2814] Fix | Delete
* - 'blank' (transparent GIF)
[2815] Fix | Delete
* - 'gravatar_default' (the Gravatar logo)
[2816] Fix | Delete
* Default is the value of the 'avatar_default' option,
[2817] Fix | Delete
* with a fallback of 'mystery'.
[2818] Fix | Delete
* @param string $alt Optional. Alternative text to use in the avatar image tag.
[2819] Fix | Delete
* Default empty.
[2820] Fix | Delete
* @param array $args {
[2821] Fix | Delete
* Optional. Extra arguments to retrieve the avatar.
[2822] Fix | Delete
*
[2823] Fix | Delete
* @type int $height Display height of the avatar in pixels. Defaults to $size.
[2824] Fix | Delete
* @type int $width Display width of the avatar in pixels. Defaults to $size.
[2825] Fix | Delete
* @type bool $force_default Whether to always show the default image, never the Gravatar.
[2826] Fix | Delete
* Default false.
[2827] Fix | Delete
* @type string $rating What rating to display avatars up to. Accepts:
[2828] Fix | Delete
* - 'G' (suitable for all audiences)
[2829] Fix | Delete
* - 'PG' (possibly offensive, usually for audiences 13 and above)
[2830] Fix | Delete
* - 'R' (intended for adult audiences above 17)
[2831] Fix | Delete
* - 'X' (even more mature than above)
[2832] Fix | Delete
* Default is the value of the 'avatar_rating' option.
[2833] Fix | Delete
* @type string $scheme URL scheme to use. See set_url_scheme() for accepted values.
[2834] Fix | Delete
* Default null.
[2835] Fix | Delete
* @type array|string $class Array or string of additional classes to add to the img element.
[2836] Fix | Delete
* Default null.
[2837] Fix | Delete
* @type bool $force_display Whether to always show the avatar - ignores the show_avatars option.
[2838] Fix | Delete
* Default false.
[2839] Fix | Delete
* @type string $loading Value for the `loading` attribute.
[2840] Fix | Delete
* Default null.
[2841] Fix | Delete
* @type string $fetchpriority Value for the `fetchpriority` attribute.
[2842] Fix | Delete
* Default null.
[2843] Fix | Delete
* @type string $decoding Value for the `decoding` attribute.
[2844] Fix | Delete
* Default null.
[2845] Fix | Delete
* @type string $extra_attr HTML attributes to insert in the IMG element. Is not sanitized.
[2846] Fix | Delete
* Default empty.
[2847] Fix | Delete
* }
[2848] Fix | Delete
* @return string|false `<img>` tag for the user's avatar. False on failure.
[2849] Fix | Delete
*/
[2850] Fix | Delete
function get_avatar( $id_or_email, $size = 96, $default_value = '', $alt = '', $args = null ) {
[2851] Fix | Delete
$defaults = array(
[2852] Fix | Delete
// get_avatar_data() args.
[2853] Fix | Delete
'size' => 96,
[2854] Fix | Delete
'height' => null,
[2855] Fix | Delete
'width' => null,
[2856] Fix | Delete
'default' => get_option( 'avatar_default', 'mystery' ),
[2857] Fix | Delete
'force_default' => false,
[2858] Fix | Delete
'rating' => get_option( 'avatar_rating' ),
[2859] Fix | Delete
'scheme' => null,
[2860] Fix | Delete
'alt' => '',
[2861] Fix | Delete
'class' => null,
[2862] Fix | Delete
'force_display' => false,
[2863] Fix | Delete
'loading' => null,
[2864] Fix | Delete
'fetchpriority' => null,
[2865] Fix | Delete
'decoding' => null,
[2866] Fix | Delete
'extra_attr' => '',
[2867] Fix | Delete
);
[2868] Fix | Delete
[2869] Fix | Delete
if ( empty( $args ) ) {
[2870] Fix | Delete
$args = array();
[2871] Fix | Delete
}
[2872] Fix | Delete
[2873] Fix | Delete
$args['size'] = (int) $size;
[2874] Fix | Delete
$args['default'] = $default_value;
[2875] Fix | Delete
$args['alt'] = $alt;
[2876] Fix | Delete
[2877] Fix | Delete
$args = wp_parse_args( $args, $defaults );
[2878] Fix | Delete
[2879] Fix | Delete
if ( empty( $args['height'] ) ) {
[2880] Fix | Delete
$args['height'] = $args['size'];
[2881] Fix | Delete
}
[2882] Fix | Delete
if ( empty( $args['width'] ) ) {
[2883] Fix | Delete
$args['width'] = $args['size'];
[2884] Fix | Delete
}
[2885] Fix | Delete
[2886] Fix | Delete
// Update args with loading optimized attributes.
[2887] Fix | Delete
$loading_optimization_attr = wp_get_loading_optimization_attributes( 'img', $args, 'get_avatar' );
[2888] Fix | Delete
[2889] Fix | Delete
$args = array_merge( $args, $loading_optimization_attr );
[2890] Fix | Delete
[2891] Fix | Delete
if ( is_object( $id_or_email ) && isset( $id_or_email->comment_ID ) ) {
[2892] Fix | Delete
$id_or_email = get_comment( $id_or_email );
[2893] Fix | Delete
}
[2894] Fix | Delete
[2895] Fix | Delete
/**
[2896] Fix | Delete
* Allows the HTML for a user's avatar to be returned early.
[2897] Fix | Delete
*
[2898] Fix | Delete
* Returning a non-null value will effectively short-circuit get_avatar(), passing
[2899] Fix | Delete
* the value through the {@see 'get_avatar'} filter and returning early.
[2900] Fix | Delete
*
[2901] Fix | Delete
* @since 4.2.0
[2902] Fix | Delete
*
[2903] Fix | Delete
* @param string|null $avatar HTML for the user's avatar. Default null.
[2904] Fix | Delete
* @param mixed $id_or_email The avatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
[2905] Fix | Delete
* user email, WP_User object, WP_Post object, or WP_Comment object.
[2906] Fix | Delete
* @param array $args Arguments passed to get_avatar_url(), after processing.
[2907] Fix | Delete
*/
[2908] Fix | Delete
$avatar = apply_filters( 'pre_get_avatar', null, $id_or_email, $args );
[2909] Fix | Delete
[2910] Fix | Delete
if ( ! is_null( $avatar ) ) {
[2911] Fix | Delete
/** This filter is documented in wp-includes/pluggable.php */
[2912] Fix | Delete
return apply_filters( 'get_avatar', $avatar, $id_or_email, $args['size'], $args['default'], $args['alt'], $args );
[2913] Fix | Delete
}
[2914] Fix | Delete
[2915] Fix | Delete
if ( ! $args['force_display'] && ! get_option( 'show_avatars' ) ) {
[2916] Fix | Delete
return false;
[2917] Fix | Delete
}
[2918] Fix | Delete
[2919] Fix | Delete
$url2x = get_avatar_url( $id_or_email, array_merge( $args, array( 'size' => $args['size'] * 2 ) ) );
[2920] Fix | Delete
[2921] Fix | Delete
$args = get_avatar_data( $id_or_email, $args );
[2922] Fix | Delete
[2923] Fix | Delete
$url = $args['url'];
[2924] Fix | Delete
[2925] Fix | Delete
if ( ! $url || is_wp_error( $url ) ) {
[2926] Fix | Delete
return false;
[2927] Fix | Delete
}
[2928] Fix | Delete
[2929] Fix | Delete
$class = array( 'avatar', 'avatar-' . (int) $args['size'], 'photo' );
[2930] Fix | Delete
[2931] Fix | Delete
if ( ! $args['found_avatar'] || $args['force_default'] ) {
[2932] Fix | Delete
$class[] = 'avatar-default';
[2933] Fix | Delete
}
[2934] Fix | Delete
[2935] Fix | Delete
if ( $args['class'] ) {
[2936] Fix | Delete
if ( is_array( $args['class'] ) ) {
[2937] Fix | Delete
$class = array_merge( $class, $args['class'] );
[2938] Fix | Delete
} else {
[2939] Fix | Delete
$class[] = $args['class'];
[2940] Fix | Delete
}
[2941] Fix | Delete
}
[2942] Fix | Delete
[2943] Fix | Delete
// Add `loading`, `fetchpriority`, and `decoding` attributes.
[2944] Fix | Delete
$extra_attr = $args['extra_attr'];
[2945] Fix | Delete
[2946] Fix | Delete
if ( in_array( $args['loading'], array( 'lazy', 'eager' ), true )
[2947] Fix | Delete
&& ! preg_match( '/\bloading\s*=/', $extra_attr )
[2948] Fix | Delete
) {
[2949] Fix | Delete
if ( ! empty( $extra_attr ) ) {
[2950] Fix | Delete
$extra_attr .= ' ';
[2951] Fix | Delete
}
[2952] Fix | Delete
[2953] Fix | Delete
$extra_attr .= "loading='{$args['loading']}'";
[2954] Fix | Delete
}
[2955] Fix | Delete
[2956] Fix | Delete
if ( in_array( $args['fetchpriority'], array( 'high', 'low', 'auto' ), true )
[2957] Fix | Delete
&& ! preg_match( '/\bfetchpriority\s*=/', $extra_attr )
[2958] Fix | Delete
) {
[2959] Fix | Delete
if ( ! empty( $extra_attr ) ) {
[2960] Fix | Delete
$extra_attr .= ' ';
[2961] Fix | Delete
}
[2962] Fix | Delete
[2963] Fix | Delete
$extra_attr .= "fetchpriority='{$args['fetchpriority']}'";
[2964] Fix | Delete
}
[2965] Fix | Delete
[2966] Fix | Delete
if ( in_array( $args['decoding'], array( 'async', 'sync', 'auto' ), true )
[2967] Fix | Delete
&& ! preg_match( '/\bdecoding\s*=/', $extra_attr )
[2968] Fix | Delete
) {
[2969] Fix | Delete
if ( ! empty( $extra_attr ) ) {
[2970] Fix | Delete
$extra_attr .= ' ';
[2971] Fix | Delete
}
[2972] Fix | Delete
[2973] Fix | Delete
$extra_attr .= "decoding='{$args['decoding']}'";
[2974] Fix | Delete
}
[2975] Fix | Delete
[2976] Fix | Delete
$avatar = sprintf(
[2977] Fix | Delete
"<img alt='%s' src='%s' srcset='%s' class='%s' height='%d' width='%d' %s/>",
[2978] Fix | Delete
esc_attr( $args['alt'] ),
[2979] Fix | Delete
esc_url( $url ),
[2980] Fix | Delete
esc_url( $url2x ) . ' 2x',
[2981] Fix | Delete
esc_attr( implode( ' ', $class ) ),
[2982] Fix | Delete
(int) $args['height'],
[2983] Fix | Delete
(int) $args['width'],
[2984] Fix | Delete
$extra_attr
[2985] Fix | Delete
);
[2986] Fix | Delete
[2987] Fix | Delete
/**
[2988] Fix | Delete
* Filters the HTML for a user's avatar.
[2989] Fix | Delete
*
[2990] Fix | Delete
* @since 2.5.0
[2991] Fix | Delete
* @since 4.2.0 Added the `$args` parameter.
[2992] Fix | Delete
*
[2993] Fix | Delete
* @param string $avatar HTML for the user's avatar.
[2994] Fix | Delete
* @param mixed $id_or_email The avatar to retrieve. Accepts a user ID, Gravatar MD5 hash,
[2995] Fix | Delete
* user email, WP_User object, WP_Post object, or WP_Comment object.
[2996] Fix | Delete
* @param int $size Height and width of the avatar in pixels.
[2997] Fix | Delete
* @param string $default_value URL for the default image or a default type. Accepts:
[2998] Fix | Delete
* - '404' (return a 404 instead of a default image)
[2999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function