wp_get_current_user example

__( 'Comment Submission Failure' ),
            array(
                'response'  => $data,
                'back_link' => true,
            )
        );
    } else {
        exit;
    }
}

$user            = wp_get_current_user();
$cookies_consent = ( isset( $_POST['wp-comment-cookies-consent'] ) );

/** * Fires after comment cookies are set. * * @since 3.4.0 * @since 4.9.6 The `$cookies_consent` parameter was added. * * @param WP_Comment $comment Comment object. * @param WP_User $user Comment author's user object. The user may not exist. * @param bool $cookies_consent Comment author's consent to store cookies. */


/** * Adds the "My Account" item. * * @since 3.3.0 * * @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance. */
function wp_admin_bar_my_account_item( $wp_admin_bar ) {
    $user_id      = get_current_user_id();
    $current_user = wp_get_current_user();

    if ( ! $user_id ) {
        return;
    }

    if ( current_user_can( 'read' ) ) {
        $profile_url = get_edit_profile_url( $user_id );
    } elseif ( is_multisite() ) {
        $profile_url = get_dashboard_url( $user_id, 'profile.php' );
    } else {
        $profile_url = false;
    }


        if ( is_wp_error( $created ) ) {
            $error = $created;
        } else {
            list( $new_password ) = $created;

            if ( $success_url ) {
                $redirect = add_query_arg(
                    array(
                        'site_url'   => urlencode( site_url() ),
                        'user_login' => urlencode( wp_get_current_user()->user_login ),
                        'password'   => urlencode( $new_password ),
                    ),
                    $success_url
                );
            }
        }
    }

    if ( $redirect ) {
        // Explicitly not using wp_safe_redirect b/c sends to arbitrary domain.         wp_redirect( $redirect );
        
$id = $request['user_id'];

        if ( 'me' === $id ) {
            if ( ! is_user_logged_in() ) {
                return new WP_Error(
                    'rest_not_logged_in',
                    __( 'You are not currently logged in.' ),
                    array( 'status' => 401 )
                );
            }

            $user = wp_get_current_user();
        } else {
            $id = (int) $id;

            if ( $id <= 0 ) {
                return $error;
            }

            $user = get_userdata( $id );
        }

        if ( empty( $user ) || ! $user->exists() ) {
            

function wp_switch_roles_and_user( $new_site_id$old_site_id ) {
    if ( $new_site_id == $old_site_id ) {
        return;
    }

    if ( ! did_action( 'init' ) ) {
        return;
    }

    wp_roles()->for_site( $new_site_id );
    wp_get_current_user()->for_site( $new_site_id );
}

/** * Determines if switch_to_blog() is in effect. * * @since 3.5.0 * * @global array $_wp_switched_stack * * @return bool True if switched, false otherwise. */
'nav-menus',
        'side',
        'default'
    );
    wp_nav_menu_taxonomy_meta_boxes();

    // Register advanced menu items (columns).     add_filter( 'manage_nav-menus_columns', 'wp_nav_menu_manage_columns' );

    // If first time editing, disable advanced items by default.     if ( false === get_user_option( 'managenav-menuscolumnshidden' ) ) {
        $user = wp_get_current_user();
        update_user_meta(
            $user->ID,
            'managenav-menuscolumnshidden',
            array(
                0 => 'link-target',
                1 => 'css-classes',
                2 => 'xfn',
                3 => 'description',
                4 => 'title-attribute',
            )
        );
    }

    public static function add_help_text() {
        $screen = get_current_screen();

        $content  = '<p>';
        $content .= __( 'Use the Custom HTML widget to add arbitrary HTML code to your widget areas.' );
        $content .= '</p>';

        if ( 'false' !== wp_get_current_user()->syntax_highlighting ) {
            $content .= '<p>';
            $content .= sprintf(
                /* translators: 1: Link to user profile, 2: Additional link attributes, 3: Accessibility text. */
                __( 'The edit field automatically highlights code syntax. You can disable this in your <a href="%1$s" %2$s>user profile%3$s</a> to work in plain text mode.' ),
                esc_url( get_edit_profile_url() ),
                'class="external-link" target="_blank"',
                sprintf(
                    '<span class="screen-reader-text"> %s</span>',
                    /* translators: Hidden accessibility text. */
                    __( '(opens in a new tab)' )
                )
            );
if ( ! current_user_can( 'edit_post', $comment_post_id ) ) {
        wp_die( -1 );
    }

    if ( empty( $post->post_status ) ) {
        wp_die( 1 );
    } elseif ( in_array( $post->post_status, array( 'draft', 'pending', 'trash' ), true ) ) {
        wp_die( __( 'You cannot reply to a comment on a draft post.' ) );
    }

    $user = wp_get_current_user();

    if ( $user->exists() ) {
        $comment_author       = wp_slash( $user->display_name );
        $comment_author_email = wp_slash( $user->user_email );
        $comment_author_url   = wp_slash( $user->user_url );
        $user_id              = $user->ID;

        if ( current_user_can( 'unfiltered_html' ) ) {
            if ( ! isset( $_POST['_wp_unfiltered_html_comment'] ) ) {
                $_POST['_wp_unfiltered_html_comment'] = '';
            }

            
/** * Fires before a comment is posted. * * @since 2.8.0 * * @param int $comment_post_id Post ID. */
        do_action( 'pre_comment_on_post', $comment_post_id );
    }

    // If the user is logged in.     $user = wp_get_current_user();
    if ( $user->exists() ) {
        if ( empty( $user->display_name ) ) {
            $user->display_name = $user->user_login;
        }

        $comment_author       = $user->display_name;
        $comment_author_email = $user->user_email;
        $comment_author_url   = $user->user_url;
        $user_id              = $user->ID;

        if ( current_user_can( 'unfiltered_html' ) ) {
            

        do_action( 'comment_form_comments_closed' );

        return;
    }

    $post_id       = $post->ID;
    $commenter     = wp_get_current_commenter();
    $user          = wp_get_current_user();
    $user_identity = $user->exists() ? $user->display_name : '';

    $args = wp_parse_args( $args );
    if ( ! isset( $args['format'] ) ) {
        $args['format'] = current_theme_supports( 'html5', 'comment-form' ) ? 'html5' : 'xhtml';
    }

    $req   = get_option( 'require_name_email' );
    $html5 = 'html5' === $args['format'];

    // Define attributes in HTML5 or XHTML syntax.

function is_user_spammy( $user = null ) {
    if ( ! ( $user instanceof WP_User ) ) {
        if ( $user ) {
            $user = get_user_by( 'login', $user );
        } else {
            $user = wp_get_current_user();
        }
    }

    return $user && isset( $user->spam ) && 1 == $user->spam;
}

/** * Updates this blog's 'public' setting in the global blogs table. * * Public blogs have a setting of 1, private blogs are 0. * * @since MU (3.0.0) * * @param int $old_value The old public value. * @param int $value The new public value. */

function get_user_locale( $user = 0 ) {
    $user_object = false;

    if ( 0 === $user && function_exists( 'wp_get_current_user' ) ) {
        $user_object = wp_get_current_user();
    } elseif ( $user instanceof WP_User ) {
        $user_object = $user;
    } elseif ( $user && is_numeric( $user ) ) {
        $user_object = get_user_by( 'id', $user );
    }

    if ( ! $user_object ) {
        return get_locale();
    }

    $locale = $user_object->locale;

    
<script type="text/javascript"> var tb_pathToImage = "<?php echo esc_js( includes_url( 'js/thickbox/loadingAnimation.gif', 'relative' ) ); ?>"; </script> <?php }

/** * @param array $users * @return bool */
function confirm_delete_users( $users ) {
    $current_user = wp_get_current_user();
    if ( ! is_array( $users ) || empty( $users ) ) {
        return false;
    }
    ?> <h1><?php esc_html_e( 'Users' ); ?></h1> <?php if ( 1 === count( $users ) ) : ?> <p><?php _e( 'You have chosen to delete the user from all networks and sites.' ); ?></p> <?php else : ?> <p><?php _e( 'You have chosen to delete the following users from all networks and sites.' ); ?></p> <?php endif; ?>
__( '(opens in a new tab)' )
        );
        $section_description .= '</p>';

        $section_description .= '<p id="editor-keyboard-trap-help-1">' . __( 'When using a keyboard to navigate:' ) . '</p>';
        $section_description .= '<ul>';
        $section_description .= '<li id="editor-keyboard-trap-help-2">' . __( 'In the editing area, the Tab key enters a tab character.' ) . '</li>';
        $section_description .= '<li id="editor-keyboard-trap-help-3">' . __( 'To move away from this area, press the Esc key followed by the Tab key.' ) . '</li>';
        $section_description .= '<li id="editor-keyboard-trap-help-4">' . __( 'Screen reader users: when in forms mode, you may need to press the Esc key twice.' ) . '</li>';
        $section_description .= '</ul>';

        if ( 'false' !== wp_get_current_user()->syntax_highlighting ) {
            $section_description .= '<p>';
            $section_description .= sprintf(
                /* translators: 1: Link to user profile, 2: Additional link attributes, 3: Accessibility text. */
                __( 'The edit field automatically highlights code syntax. You can disable this in your <a href="%1$s" %2$s>user profile%3$s</a> to work in plain text mode.' ),
                esc_url( get_edit_profile_url() ),
                'class="external-link" target="_blank"',
                sprintf(
                    '<span class="screen-reader-text"> %s</span>',
                    /* translators: Hidden accessibility text. */
                    __( '(opens in a new tab)' )
                )
            );
/* translators: %s: Network title. */
                __( 'Thank you for using %s, your site has been deleted. Happy trails to you until we meet again.' ),
                get_network()->site_name
            )
        );
    } else {
        wp_die( __( 'Sorry, the link you clicked is stale. Please select another option.' ) );
    }
}

$blog = get_site();
$user = wp_get_current_user();

// Used in the HTML title tag. $title       = __( 'Delete Site' );
$parent_file = 'tools.php';

require_once ABSPATH . 'wp-admin/admin-header.php';

echo '<div class="wrap">';
echo '<h1>' . esc_html( $title ) . '</h1>';

if ( isset( $_POST['action'] ) && 'deleteblog' === $_POST['action'] && isset( $_POST['confirmdelete'] ) && '1' === $_POST['confirmdelete'] ) {
    
Home | Imprint | This part of the site doesn't use cookies.