wp_rand example


function twenty_twenty_one_password_form( $output$post = 0 ) {
    $post   = get_post( $post );
    $label  = 'pwbox-' . ( empty( $post->ID ) ? wp_rand() : $post->ID );
    $output = '<p class="post-password-message">' . esc_html__( 'This content is password protected. Please enter a password to view.', 'twentytwentyone' ) . '</p> <form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" class="post-password-form" method="post"> <label class="post-password-form__label" for="' . esc_attr( $label ) . '">' . esc_html_x( 'Password', 'Post password form', 'twentytwentyone' ) . '</label><input class="post-password-form__input" name="post_password" id="' . esc_attr( $label ) . '" type="password" spellcheck="false" size="20" /><input type="submit" class="post-password-form__submit" name="' . esc_attr_x( 'Submit', 'Post password form', 'twentytwentyone' ) . '" value="' . esc_attr_x( 'Enter', 'Post password form', 'twentytwentyone' ) . '" /></form> ';
    return $output;
}
add_filter( 'the_password_form', 'twenty_twenty_one_password_form', 10, 2 );

/** * Filters the list of attachment image attributes. * * @since Twenty Twenty-One 1.0 * * @param string[] $attr Array of attribute values for the image markup, keyed by attribute name. * See wp_get_attachment_image(). * @param WP_Post $attachment Image attachment post. * @param string|int[] $size Requested image size. Can be any registered image size name, or * an array of width and height values in pixels (in that order). * @return string[] The filtered attributes for the image markup. */

function update_option_new_admin_email( $old_value$value ) {
    if ( get_option( 'admin_email' ) === $value || ! is_email( $value ) ) {
        return;
    }

    $hash            = md5( $value . time() . wp_rand() );
    $new_admin_email = array(
        'hash'     => $hash,
        'newemail' => $value,
    );
    update_option( 'adminhash', $new_admin_email );

    $switched_locale = switch_to_user_locale( get_current_user_id() );

    /* translators: Do not translate USERNAME, ADMIN_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */
    $email_text = __(
        'Howdy ###USERNAME###, Someone with administrator capabilities recently requested to have the administration email address changed on this site: ###SITEURL### To confirm this change, please click on the following link: ###ADMIN_URL### You can safely ignore and delete this email if you do not want to take this action. This email has been sent to ###EMAIL### Regards, All at ###SITENAME### ###SITEURL###'
/** * Prints the necessary markup for the embed sharing dialog. * * @since 4.4.0 */
function print_embed_sharing_dialog() {
    if ( is_404() ) {
        return;
    }

    $unique_suffix            = get_the_ID() . '-' . wp_rand();
    $share_tab_wordpress_id   = 'wp-embed-share-tab-wordpress-' . $unique_suffix;
    $share_tab_html_id        = 'wp-embed-share-tab-html-' . $unique_suffix;
    $description_wordpress_id = 'wp-embed-share-description-wordpress-' . $unique_suffix;
    $description_html_id      = 'wp-embed-share-description-html-' . $unique_suffix;
    ?> <div class="wp-embed-share-dialog hidden" role="dialog" aria-label="<?php esc_attr_e( 'Sharing options' ); ?>"> <div class="wp-embed-share-dialog-content"> <div class="wp-embed-share-dialog-text"> <ul class="wp-embed-share-tabs" role="tablist"> <li class="wp-embed-share-tab-button wp-embed-share-tab-button-wordpress" role="presentation"> <button type="button" role="tab" aria-controls="<?php echo $share_tab_wordpress_id; ?>" aria-selected="true" tabindex="0"><?php esc_html_e( 'WordPress Embed' ); ?></button> </li> <li class="wp-embed-share-tab-button wp-embed-share-tab-button-html" role="presentation"> <button type="button" role="tab" aria-controls="
'user_email',
                __( '<strong>Error:</strong> The email address is already used.' ),
                array(
                    'form-field' => 'email',
                )
            );
            delete_user_meta( $current_user->ID, '_new_email' );

            return;
        }

        $hash           = md5( $_POST['email'] . time() . wp_rand() );
        $new_user_email = array(
            'hash'     => $hash,
            'newemail' => $_POST['email'],
        );
        update_user_meta( $current_user->ID, '_new_email', $new_user_email );

        $sitename = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );

        /* translators: Do not translate USERNAME, ADMIN_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */
        $email_text = __(
            'Howdy ###USERNAME###, You recently requested to have the email address on your account changed. If this is correct, please click on the following link to change it: ###ADMIN_URL### You can safely ignore and delete this email if you do not want to take this action. This email has been sent to ###EMAIL### Regards, All at ###SITENAME### ###SITEURL###'
function wp_generate_password( $length = 12, $special_chars = true, $extra_special_chars = false ) {
        $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
        if ( $special_chars ) {
            $chars .= '!@#$%^&*()';
        }
        if ( $extra_special_chars ) {
            $chars .= '-_ []{}<>~`+=,.;:/?|';
        }

        $password = '';
        for ( $i = 0; $i < $length$i++ ) {
            $password .= substr( $charswp_rand( 0, strlen( $chars ) - 1 ), 1 );
        }

        /** * Filters the randomly-generated password. * * @since 3.0.0 * @since 5.3.0 Added the `$length`, `$special_chars`, and `$extra_special_chars` parameters. * * @param string $password The generated password. * @param int $length The length of password to generate. * @param bool $special_chars Whether to include standard special characters. * @param bool $extra_special_chars Whether to include other special characters. */

function wpmu_signup_blog( $domain$path$title$user$user_email$meta = array() ) {
    global $wpdb;

    $key = substr( md5( time() . wp_rand() . $domain ), 0, 16 );

    /** * Filters the metadata for a site signup. * * The metadata will be serialized prior to storing it in the database. * * @since 4.8.0 * * @param array $meta Signup meta data. Default empty array. * @param string $domain The requested domain. * @param string $path The requested path. * @param string $title The requested site title. * @param string $user The user's requested login name. * @param string $user_email The user's email address. * @param string $key The user's activation key. */
Home | Imprint | This part of the site doesn't use cookies.