Edit File by line
/home/barbar84/www/wp-inclu...
File: pluggable.php
endif;
[2500] Fix | Delete
[2501] Fix | Delete
if ( ! function_exists( 'wp_rand' ) ) :
[2502] Fix | Delete
/**
[2503] Fix | Delete
* Generates a random number.
[2504] Fix | Delete
*
[2505] Fix | Delete
* @since 2.6.2
[2506] Fix | Delete
* @since 4.4.0 Uses PHP7 random_int() or the random_compat library if available.
[2507] Fix | Delete
*
[2508] Fix | Delete
* @global string $rnd_value
[2509] Fix | Delete
*
[2510] Fix | Delete
* @param int $min Lower limit for the generated number
[2511] Fix | Delete
* @param int $max Upper limit for the generated number
[2512] Fix | Delete
* @return int A random number between min and max
[2513] Fix | Delete
*/
[2514] Fix | Delete
function wp_rand( $min = 0, $max = 0 ) {
[2515] Fix | Delete
global $rnd_value;
[2516] Fix | Delete
[2517] Fix | Delete
// Some misconfigured 32-bit environments (Entropy PHP, for example)
[2518] Fix | Delete
// truncate integers larger than PHP_INT_MAX to PHP_INT_MAX rather than overflowing them to floats.
[2519] Fix | Delete
$max_random_number = 3000000000 === 2147483647 ? (float) '4294967295' : 4294967295; // 4294967295 = 0xffffffff
[2520] Fix | Delete
[2521] Fix | Delete
// We only handle ints, floats are truncated to their integer value.
[2522] Fix | Delete
$min = (int) $min;
[2523] Fix | Delete
$max = (int) $max;
[2524] Fix | Delete
[2525] Fix | Delete
// Use PHP's CSPRNG, or a compatible method.
[2526] Fix | Delete
static $use_random_int_functionality = true;
[2527] Fix | Delete
if ( $use_random_int_functionality ) {
[2528] Fix | Delete
try {
[2529] Fix | Delete
$_max = ( 0 != $max ) ? $max : $max_random_number;
[2530] Fix | Delete
// wp_rand() can accept arguments in either order, PHP cannot.
[2531] Fix | Delete
$_max = max( $min, $_max );
[2532] Fix | Delete
$_min = min( $min, $_max );
[2533] Fix | Delete
$val = random_int( $_min, $_max );
[2534] Fix | Delete
if ( false !== $val ) {
[2535] Fix | Delete
return absint( $val );
[2536] Fix | Delete
} else {
[2537] Fix | Delete
$use_random_int_functionality = false;
[2538] Fix | Delete
}
[2539] Fix | Delete
} catch ( Error $e ) {
[2540] Fix | Delete
$use_random_int_functionality = false;
[2541] Fix | Delete
} catch ( Exception $e ) {
[2542] Fix | Delete
$use_random_int_functionality = false;
[2543] Fix | Delete
}
[2544] Fix | Delete
}
[2545] Fix | Delete
[2546] Fix | Delete
// Reset $rnd_value after 14 uses.
[2547] Fix | Delete
// 32 (md5) + 40 (sha1) + 40 (sha1) / 8 = 14 random numbers from $rnd_value.
[2548] Fix | Delete
if ( strlen( $rnd_value ) < 8 ) {
[2549] Fix | Delete
if ( defined( 'WP_SETUP_CONFIG' ) ) {
[2550] Fix | Delete
static $seed = '';
[2551] Fix | Delete
} else {
[2552] Fix | Delete
$seed = get_transient( 'random_seed' );
[2553] Fix | Delete
}
[2554] Fix | Delete
$rnd_value = md5( uniqid( microtime() . mt_rand(), true ) . $seed );
[2555] Fix | Delete
$rnd_value .= sha1( $rnd_value );
[2556] Fix | Delete
$rnd_value .= sha1( $rnd_value . $seed );
[2557] Fix | Delete
$seed = md5( $seed . $rnd_value );
[2558] Fix | Delete
if ( ! defined( 'WP_SETUP_CONFIG' ) && ! defined( 'WP_INSTALLING' ) ) {
[2559] Fix | Delete
set_transient( 'random_seed', $seed );
[2560] Fix | Delete
}
[2561] Fix | Delete
}
[2562] Fix | Delete
[2563] Fix | Delete
// Take the first 8 digits for our value.
[2564] Fix | Delete
$value = substr( $rnd_value, 0, 8 );
[2565] Fix | Delete
[2566] Fix | Delete
// Strip the first eight, leaving the remainder for the next call to wp_rand().
[2567] Fix | Delete
$rnd_value = substr( $rnd_value, 8 );
[2568] Fix | Delete
[2569] Fix | Delete
$value = abs( hexdec( $value ) );
[2570] Fix | Delete
[2571] Fix | Delete
// Reduce the value to be within the min - max range.
[2572] Fix | Delete
if ( 0 != $max ) {
[2573] Fix | Delete
$value = $min + ( $max - $min + 1 ) * $value / ( $max_random_number + 1 );
[2574] Fix | Delete
}
[2575] Fix | Delete
[2576] Fix | Delete
return abs( (int) $value );
[2577] Fix | Delete
}
[2578] Fix | Delete
endif;
[2579] Fix | Delete
[2580] Fix | Delete
if ( ! function_exists( 'wp_set_password' ) ) :
[2581] Fix | Delete
/**
[2582] Fix | Delete
* Updates the user's password with a new encrypted one.
[2583] Fix | Delete
*
[2584] Fix | Delete
* For integration with other applications, this function can be overwritten to
[2585] Fix | Delete
* instead use the other package password checking algorithm.
[2586] Fix | Delete
*
[2587] Fix | Delete
* Please note: This function should be used sparingly and is really only meant for single-time
[2588] Fix | Delete
* application. Leveraging this improperly in a plugin or theme could result in an endless loop
[2589] Fix | Delete
* of password resets if precautions are not taken to ensure it does not execute on every page load.
[2590] Fix | Delete
*
[2591] Fix | Delete
* @since 2.5.0
[2592] Fix | Delete
*
[2593] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[2594] Fix | Delete
*
[2595] Fix | Delete
* @param string $password The plaintext new user password
[2596] Fix | Delete
* @param int $user_id User ID
[2597] Fix | Delete
*/
[2598] Fix | Delete
function wp_set_password( $password, $user_id ) {
[2599] Fix | Delete
global $wpdb;
[2600] Fix | Delete
[2601] Fix | Delete
$hash = wp_hash_password( $password );
[2602] Fix | Delete
$wpdb->update(
[2603] Fix | Delete
$wpdb->users,
[2604] Fix | Delete
array(
[2605] Fix | Delete
'user_pass' => $hash,
[2606] Fix | Delete
'user_activation_key' => '',
[2607] Fix | Delete
),
[2608] Fix | Delete
array( 'ID' => $user_id )
[2609] Fix | Delete
);
[2610] Fix | Delete
[2611] Fix | Delete
clean_user_cache( $user_id );
[2612] Fix | Delete
}
[2613] Fix | Delete
endif;
[2614] Fix | Delete
[2615] Fix | Delete
if ( ! function_exists( 'get_avatar' ) ) :
[2616] Fix | Delete
/**
[2617] Fix | Delete
* Retrieve the avatar `<img>` tag for a user, email address, MD5 hash, comment, or post.
[2618] Fix | Delete
*
[2619] Fix | Delete
* @since 2.5.0
[2620] Fix | Delete
* @since 4.2.0 Optional `$args` parameter added.
[2621] Fix | Delete
*
[2622] Fix | Delete
* @param mixed $id_or_email The Gravatar to retrieve. Accepts a user_id, gravatar md5 hash,
[2623] Fix | Delete
* user email, WP_User object, WP_Post object, or WP_Comment object.
[2624] Fix | Delete
* @param int $size Optional. Height and width of the avatar image file in pixels. Default 96.
[2625] Fix | Delete
* @param string $default Optional. URL for the default image or a default type. Accepts '404'
[2626] Fix | Delete
* (return a 404 instead of a default image), 'retro' (8bit), 'monsterid'
[2627] Fix | Delete
* (monster), 'wavatar' (cartoon face), 'indenticon' (the "quilt"),
[2628] Fix | Delete
* 'mystery', 'mm', or 'mysteryman' (The Oyster Man), 'blank' (transparent GIF),
[2629] Fix | Delete
* or 'gravatar_default' (the Gravatar logo). Default is the value of the
[2630] Fix | Delete
* 'avatar_default' option, with a fallback of 'mystery'.
[2631] Fix | Delete
* @param string $alt Optional. Alternative text to use in img tag. Default empty.
[2632] Fix | Delete
* @param array $args {
[2633] Fix | Delete
* Optional. Extra arguments to retrieve the avatar.
[2634] Fix | Delete
*
[2635] Fix | Delete
* @type int $height Display height of the avatar in pixels. Defaults to $size.
[2636] Fix | Delete
* @type int $width Display width of the avatar in pixels. Defaults to $size.
[2637] Fix | Delete
* @type bool $force_default Whether to always show the default image, never the Gravatar. Default false.
[2638] Fix | Delete
* @type string $rating What rating to display avatars up to. Accepts 'G', 'PG', 'R', 'X', and are
[2639] Fix | Delete
* judged in that order. Default is the value of the 'avatar_rating' option.
[2640] Fix | Delete
* @type string $scheme URL scheme to use. See set_url_scheme() for accepted values.
[2641] Fix | Delete
* Default null.
[2642] Fix | Delete
* @type array|string $class Array or string of additional classes to add to the img element.
[2643] Fix | Delete
* Default null.
[2644] Fix | Delete
* @type bool $force_display Whether to always show the avatar - ignores the show_avatars option.
[2645] Fix | Delete
* Default false.
[2646] Fix | Delete
* @type string $loading Value for the `loading` attribute.
[2647] Fix | Delete
* Default null.
[2648] Fix | Delete
* @type string $extra_attr HTML attributes to insert in the IMG element. Is not sanitized. Default empty.
[2649] Fix | Delete
* }
[2650] Fix | Delete
* @return string|false `<img>` tag for the user's avatar. False on failure.
[2651] Fix | Delete
*/
[2652] Fix | Delete
function get_avatar( $id_or_email, $size = 96, $default = '', $alt = '', $args = null ) {
[2653] Fix | Delete
$defaults = array(
[2654] Fix | Delete
// get_avatar_data() args.
[2655] Fix | Delete
'size' => 96,
[2656] Fix | Delete
'height' => null,
[2657] Fix | Delete
'width' => null,
[2658] Fix | Delete
'default' => get_option( 'avatar_default', 'mystery' ),
[2659] Fix | Delete
'force_default' => false,
[2660] Fix | Delete
'rating' => get_option( 'avatar_rating' ),
[2661] Fix | Delete
'scheme' => null,
[2662] Fix | Delete
'alt' => '',
[2663] Fix | Delete
'class' => null,
[2664] Fix | Delete
'force_display' => false,
[2665] Fix | Delete
'loading' => null,
[2666] Fix | Delete
'extra_attr' => '',
[2667] Fix | Delete
);
[2668] Fix | Delete
[2669] Fix | Delete
if ( wp_lazy_loading_enabled( 'img', 'get_avatar' ) ) {
[2670] Fix | Delete
$defaults['loading'] = 'lazy';
[2671] Fix | Delete
}
[2672] Fix | Delete
[2673] Fix | Delete
if ( empty( $args ) ) {
[2674] Fix | Delete
$args = array();
[2675] Fix | Delete
}
[2676] Fix | Delete
[2677] Fix | Delete
$args['size'] = (int) $size;
[2678] Fix | Delete
$args['default'] = $default;
[2679] Fix | Delete
$args['alt'] = $alt;
[2680] Fix | Delete
[2681] Fix | Delete
$args = wp_parse_args( $args, $defaults );
[2682] Fix | Delete
[2683] Fix | Delete
if ( empty( $args['height'] ) ) {
[2684] Fix | Delete
$args['height'] = $args['size'];
[2685] Fix | Delete
}
[2686] Fix | Delete
if ( empty( $args['width'] ) ) {
[2687] Fix | Delete
$args['width'] = $args['size'];
[2688] Fix | Delete
}
[2689] Fix | Delete
[2690] Fix | Delete
if ( is_object( $id_or_email ) && isset( $id_or_email->comment_ID ) ) {
[2691] Fix | Delete
$id_or_email = get_comment( $id_or_email );
[2692] Fix | Delete
}
[2693] Fix | Delete
[2694] Fix | Delete
/**
[2695] Fix | Delete
* Allows the HTML for a user's avatar to be returned early.
[2696] Fix | Delete
*
[2697] Fix | Delete
* Passing a non-null value will effectively short-circuit get_avatar(), passing
[2698] Fix | Delete
* the value through the {@see 'get_avatar'} filter and returning early.
[2699] Fix | Delete
*
[2700] Fix | Delete
* @since 4.2.0
[2701] Fix | Delete
*
[2702] Fix | Delete
* @param string|null $avatar HTML for the user's avatar. Default null.
[2703] Fix | Delete
* @param mixed $id_or_email The avatar to retrieve. Accepts a user_id, Gravatar MD5 hash,
[2704] Fix | Delete
* user email, WP_User object, WP_Post object, or WP_Comment object.
[2705] Fix | Delete
* @param array $args Arguments passed to get_avatar_url(), after processing.
[2706] Fix | Delete
*/
[2707] Fix | Delete
$avatar = apply_filters( 'pre_get_avatar', null, $id_or_email, $args );
[2708] Fix | Delete
[2709] Fix | Delete
if ( ! is_null( $avatar ) ) {
[2710] Fix | Delete
/** This filter is documented in wp-includes/pluggable.php */
[2711] Fix | Delete
return apply_filters( 'get_avatar', $avatar, $id_or_email, $args['size'], $args['default'], $args['alt'], $args );
[2712] Fix | Delete
}
[2713] Fix | Delete
[2714] Fix | Delete
if ( ! $args['force_display'] && ! get_option( 'show_avatars' ) ) {
[2715] Fix | Delete
return false;
[2716] Fix | Delete
}
[2717] Fix | Delete
[2718] Fix | Delete
$url2x = get_avatar_url( $id_or_email, array_merge( $args, array( 'size' => $args['size'] * 2 ) ) );
[2719] Fix | Delete
[2720] Fix | Delete
$args = get_avatar_data( $id_or_email, $args );
[2721] Fix | Delete
[2722] Fix | Delete
$url = $args['url'];
[2723] Fix | Delete
[2724] Fix | Delete
if ( ! $url || is_wp_error( $url ) ) {
[2725] Fix | Delete
return false;
[2726] Fix | Delete
}
[2727] Fix | Delete
[2728] Fix | Delete
$class = array( 'avatar', 'avatar-' . (int) $args['size'], 'photo' );
[2729] Fix | Delete
[2730] Fix | Delete
if ( ! $args['found_avatar'] || $args['force_default'] ) {
[2731] Fix | Delete
$class[] = 'avatar-default';
[2732] Fix | Delete
}
[2733] Fix | Delete
[2734] Fix | Delete
if ( $args['class'] ) {
[2735] Fix | Delete
if ( is_array( $args['class'] ) ) {
[2736] Fix | Delete
$class = array_merge( $class, $args['class'] );
[2737] Fix | Delete
} else {
[2738] Fix | Delete
$class[] = $args['class'];
[2739] Fix | Delete
}
[2740] Fix | Delete
}
[2741] Fix | Delete
[2742] Fix | Delete
// Add `loading` attribute.
[2743] Fix | Delete
$extra_attr = $args['extra_attr'];
[2744] Fix | Delete
$loading = $args['loading'];
[2745] Fix | Delete
[2746] Fix | Delete
if ( in_array( $loading, array( 'lazy', 'eager' ), true ) && ! preg_match( '/\bloading\s*=/', $extra_attr ) ) {
[2747] Fix | Delete
if ( ! empty( $extra_attr ) ) {
[2748] Fix | Delete
$extra_attr .= ' ';
[2749] Fix | Delete
}
[2750] Fix | Delete
[2751] Fix | Delete
$extra_attr .= "loading='{$loading}'";
[2752] Fix | Delete
}
[2753] Fix | Delete
[2754] Fix | Delete
$avatar = sprintf(
[2755] Fix | Delete
"<img alt='%s' src='%s' srcset='%s' class='%s' height='%d' width='%d' %s/>",
[2756] Fix | Delete
esc_attr( $args['alt'] ),
[2757] Fix | Delete
esc_url( $url ),
[2758] Fix | Delete
esc_url( $url2x ) . ' 2x',
[2759] Fix | Delete
esc_attr( implode( ' ', $class ) ),
[2760] Fix | Delete
(int) $args['height'],
[2761] Fix | Delete
(int) $args['width'],
[2762] Fix | Delete
$extra_attr
[2763] Fix | Delete
);
[2764] Fix | Delete
[2765] Fix | Delete
/**
[2766] Fix | Delete
* Filters the HTML for a user's avatar.
[2767] Fix | Delete
*
[2768] Fix | Delete
* @since 2.5.0
[2769] Fix | Delete
* @since 4.2.0 The `$args` parameter was added.
[2770] Fix | Delete
*
[2771] Fix | Delete
* @param string $avatar HTML for the user's avatar.
[2772] Fix | Delete
* @param mixed $id_or_email The avatar to retrieve. Accepts a user_id, Gravatar MD5 hash,
[2773] Fix | Delete
* user email, WP_User object, WP_Post object, or WP_Comment object.
[2774] Fix | Delete
* @param int $size Square avatar width and height in pixels to retrieve.
[2775] Fix | Delete
* @param string $default URL for the default image or a default type. Accepts '404', 'retro', 'monsterid',
[2776] Fix | Delete
* 'wavatar', 'indenticon', 'mystery', 'mm', 'mysteryman', 'blank', or 'gravatar_default'.
[2777] Fix | Delete
* Default is the value of the 'avatar_default' option, with a fallback of 'mystery'.
[2778] Fix | Delete
* @param string $alt Alternative text to use in the avatar image tag. Default empty.
[2779] Fix | Delete
* @param array $args Arguments passed to get_avatar_data(), after processing.
[2780] Fix | Delete
*/
[2781] Fix | Delete
return apply_filters( 'get_avatar', $avatar, $id_or_email, $args['size'], $args['default'], $args['alt'], $args );
[2782] Fix | Delete
}
[2783] Fix | Delete
endif;
[2784] Fix | Delete
[2785] Fix | Delete
if ( ! function_exists( 'wp_text_diff' ) ) :
[2786] Fix | Delete
/**
[2787] Fix | Delete
* Displays a human readable HTML representation of the difference between two strings.
[2788] Fix | Delete
*
[2789] Fix | Delete
* The Diff is available for getting the changes between versions. The output is
[2790] Fix | Delete
* HTML, so the primary use is for displaying the changes. If the two strings
[2791] Fix | Delete
* are equivalent, then an empty string will be returned.
[2792] Fix | Delete
*
[2793] Fix | Delete
* @since 2.6.0
[2794] Fix | Delete
*
[2795] Fix | Delete
* @see wp_parse_args() Used to change defaults to user defined settings.
[2796] Fix | Delete
* @uses Text_Diff
[2797] Fix | Delete
* @uses WP_Text_Diff_Renderer_Table
[2798] Fix | Delete
*
[2799] Fix | Delete
* @param string $left_string "old" (left) version of string
[2800] Fix | Delete
* @param string $right_string "new" (right) version of string
[2801] Fix | Delete
* @param string|array $args {
[2802] Fix | Delete
* Associative array of options to pass to WP_Text_Diff_Renderer_Table().
[2803] Fix | Delete
*
[2804] Fix | Delete
* @type string $title Titles the diff in a manner compatible
[2805] Fix | Delete
* with the output. Default empty.
[2806] Fix | Delete
* @type string $title_left Change the HTML to the left of the title.
[2807] Fix | Delete
* Default empty.
[2808] Fix | Delete
* @type string $title_right Change the HTML to the right of the title.
[2809] Fix | Delete
* Default empty.
[2810] Fix | Delete
* @type bool $show_split_view True for split view (two columns), false for
[2811] Fix | Delete
* un-split view (single column). Default true.
[2812] Fix | Delete
* }
[2813] Fix | Delete
* @return string Empty string if strings are equivalent or HTML with differences.
[2814] Fix | Delete
*/
[2815] Fix | Delete
function wp_text_diff( $left_string, $right_string, $args = null ) {
[2816] Fix | Delete
$defaults = array(
[2817] Fix | Delete
'title' => '',
[2818] Fix | Delete
'title_left' => '',
[2819] Fix | Delete
'title_right' => '',
[2820] Fix | Delete
'show_split_view' => true,
[2821] Fix | Delete
);
[2822] Fix | Delete
$args = wp_parse_args( $args, $defaults );
[2823] Fix | Delete
[2824] Fix | Delete
if ( ! class_exists( 'WP_Text_Diff_Renderer_Table', false ) ) {
[2825] Fix | Delete
require ABSPATH . WPINC . '/wp-diff.php';
[2826] Fix | Delete
}
[2827] Fix | Delete
[2828] Fix | Delete
$left_string = normalize_whitespace( $left_string );
[2829] Fix | Delete
$right_string = normalize_whitespace( $right_string );
[2830] Fix | Delete
[2831] Fix | Delete
$left_lines = explode( "\n", $left_string );
[2832] Fix | Delete
$right_lines = explode( "\n", $right_string );
[2833] Fix | Delete
$text_diff = new Text_Diff( $left_lines, $right_lines );
[2834] Fix | Delete
$renderer = new WP_Text_Diff_Renderer_Table( $args );
[2835] Fix | Delete
$diff = $renderer->render( $text_diff );
[2836] Fix | Delete
[2837] Fix | Delete
if ( ! $diff ) {
[2838] Fix | Delete
return '';
[2839] Fix | Delete
}
[2840] Fix | Delete
[2841] Fix | Delete
$is_split_view = ! empty( $args['show_split_view'] );
[2842] Fix | Delete
$is_split_view_class = $is_split_view ? ' is-split-view' : '';
[2843] Fix | Delete
[2844] Fix | Delete
$r = "<table class='diff$is_split_view_class'>\n";
[2845] Fix | Delete
[2846] Fix | Delete
if ( $args['title'] ) {
[2847] Fix | Delete
$r .= "<caption class='diff-title'>$args[title]</caption>\n";
[2848] Fix | Delete
}
[2849] Fix | Delete
[2850] Fix | Delete
if ( $args['title_left'] || $args['title_right'] ) {
[2851] Fix | Delete
$r .= '<thead>';
[2852] Fix | Delete
}
[2853] Fix | Delete
[2854] Fix | Delete
if ( $args['title_left'] || $args['title_right'] ) {
[2855] Fix | Delete
$th_or_td_left = empty( $args['title_left'] ) ? 'td' : 'th';
[2856] Fix | Delete
$th_or_td_right = empty( $args['title_right'] ) ? 'td' : 'th';
[2857] Fix | Delete
[2858] Fix | Delete
$r .= "<tr class='diff-sub-title'>\n";
[2859] Fix | Delete
$r .= "\t<$th_or_td_left>$args[title_left]</$th_or_td_left>\n";
[2860] Fix | Delete
if ( $is_split_view ) {
[2861] Fix | Delete
$r .= "\t<$th_or_td_right>$args[title_right]</$th_or_td_right>\n";
[2862] Fix | Delete
}
[2863] Fix | Delete
$r .= "</tr>\n";
[2864] Fix | Delete
}
[2865] Fix | Delete
[2866] Fix | Delete
if ( $args['title_left'] || $args['title_right'] ) {
[2867] Fix | Delete
$r .= "</thead>\n";
[2868] Fix | Delete
}
[2869] Fix | Delete
[2870] Fix | Delete
$r .= "<tbody>\n$diff\n</tbody>\n";
[2871] Fix | Delete
$r .= '</table>';
[2872] Fix | Delete
[2873] Fix | Delete
return $r;
[2874] Fix | Delete
}
[2875] Fix | Delete
endif;
[2876] Fix | Delete
[2877] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function