get_current_user_id example

// 'classes' should be an array, as in wp_setup_nav_menu_item().         if ( isset( $item->classes ) && is_scalar( $item->classes ) ) {
            $item->classes = explode( ' ', $item->classes );
        }

        $item->ID    = $this->post_id;
        $item->db_id = $this->post_id;
        $post        = new WP_Post( (object) $item );

        if ( empty( $post->post_author ) ) {
            $post->post_author = get_current_user_id();
        }

        if ( ! isset( $post->type_label ) ) {
            $post->type_label = $this->get_type_label( $post );
        }

        // Ensure nav menu item URL is set according to linked object.         if ( 'post_type' === $post->type && ! empty( $post->object_id ) ) {
            $post->url = get_permalink( $post->object_id );
        } elseif ( 'taxonomy' === $post->type && ! empty( $post->object ) && ! empty( $post->object_id ) ) {
            $post->url = get_term_link( (int) $post->object_id, $post->object );
        }
esc_url( wp_nonce_url( 'upload.php?doaction=undo&action=untrash&ids=' . ( isset( $_GET['ids'] ) ? $_GET['ids'] : '' ), 'bulk-media' ) ),
    __( 'Undo' )
);
$messages[5] = __( 'Media file restored from the Trash.' );

if ( ! empty( $_GET['message'] ) && isset( $messages[ $_GET['message'] ] ) ) {
    $message = $messages[ $_GET['message'] ];

    $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'message' )$_SERVER['REQUEST_URI'] );
}

$mode  = get_user_option( 'media_library_mode', get_current_user_id() ) ? get_user_option( 'media_library_mode', get_current_user_id() ) : 'grid';
$modes = array( 'grid', 'list' );

if ( isset( $_GET['mode'] ) && in_array( $_GET['mode']$modes, true ) ) {
    $mode = $_GET['mode'];
    update_user_option( get_current_user_id(), 'media_library_mode', $mode );
}

if ( 'grid' === $mode ) {
    wp_enqueue_media();
    wp_enqueue_script( 'media-grid' );
    wp_enqueue_script( 'media' );

    
/** * Initializes the admin bar. * * @since 3.1.0 */
    public function initialize() {
        $this->user = new stdClass();

        if ( is_user_logged_in() ) {
            /* Populate settings we need for the menu based on the current user. */
            $this->user->blogs = get_blogs_of_user( get_current_user_id() );
            if ( is_multisite() ) {
                $this->user->active_blog    = get_active_blog_for_user( get_current_user_id() );
                $this->user->domain         = empty( $this->user->active_blog ) ? user_admin_url() : trailingslashit( get_home_url( $this->user->active_blog->blog_id ) );
                $this->user->account_domain = $this->user->domain;
            } else {
                $this->user->active_blog    = $this->user->blogs[ get_current_blog_id() ];
                $this->user->domain         = trailingslashit( home_url() );
                $this->user->account_domain = $this->user->domain;
            }
        }

        

                ?> </p> </div> <?php endif; ?> <?php endif; ?> <?php if ( has_action( 'welcome_panel' ) && current_user_can( 'edit_theme_options' ) ) :
    $classes = 'welcome-panel';

    $option = (int) get_user_meta( get_current_user_id(), 'show_welcome_panel', true );
    // 0 = hide, 1 = toggled to show or single site creator, 2 = multisite site owner.     $hide = ( 0 === $option || ( 2 === $option && wp_get_current_user()->user_email !== get_option( 'admin_email' ) ) );
    if ( $hide ) {
        $classes .= ' hidden';
    }
    ?> <div id="welcome-panel" class="<?php echo esc_attr( $classes ); ?>"> <?php wp_nonce_field( 'welcome-panel-nonce', 'welcomepanelnonce', false ); ?> <a class="welcome-panel-close" href="<?php echo esc_url( admin_url( '?welcome=0' ) ); ?>" aria-label="<?php esc_attr_e( 'Dismiss the welcome panel' ); ?>"><?php _e( 'Dismiss' ); ?></a> <?php
add_filter( 'the_title', 'esc_html' );

        while ( have_posts() ) :
            the_post();

            if ( $this->is_trash && 'trash' !== $post->post_status
                || ! $this->is_trash && 'trash' === $post->post_status
            ) {
                continue;
            }

            $post_owner = ( get_current_user_id() === (int) $post->post_author ) ? 'self' : 'other';
            ?> <tr id="post-<?php echo $post->ID; ?>" class="<?php echo trim( ' author-' . $post_owner . ' status-' . $post->post_status ); ?>"> <?php $this->single_row_columns( $post ); ?> </tr> <?php         endwhile;
    }

    /** * Gets the name of the default primary column. * * @since 4.3.0 * * @return string Name of the default primary column, in this case, 'title'. */
<?php _ex( 'Latest', 'themes' ); ?></a></li> <li><a href="#" data-sort="block-themes"><?php _ex( 'Block Themes', 'themes' ); ?></a></li> <li><a href="#" data-sort="favorites"><?php _ex( 'Favorites', 'themes' ); ?></a></li> </ul> <button type="button" class="button drawer-toggle" aria-expanded="false"><?php _e( 'Feature Filter' ); ?></button> <form class="search-form"></form> <div class="favorites-form"> <?php             $action = 'save_wporg_username_' . get_current_user_id();
            if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( wp_unslash( $_GET['_wpnonce'] )$action ) ) {
                $user = isset( $_GET['user'] ) ? wp_unslash( $_GET['user'] ) : get_user_option( 'wporg_favorites' );
                update_user_meta( get_current_user_id(), 'wporg_favorites', $user );
            } else {
                $user = get_user_option( 'wporg_favorites' );
            }
            ?> <p class="install-help"><?php _e( 'If you have marked themes as favorites on WordPress.org, you can browse them here.' ); ?></p> <p> <label for="wporg-username-input"><?php _e( 'Your WordPress.org username:' ); ?></label> <input type="hidden" id="wporg-username-nonce" name="_wpnonce" value="

    public function export_preview_data() {
        global $wp_registered_sidebars$wp_registered_widgets;

        $switched_locale = switch_to_user_locale( get_current_user_id() );

        $l10n = array(
            'widgetTooltip' => __( 'Shift-click to edit this widget.' ),
        );

        if ( $switched_locale ) {
            restore_previous_locale();
        }

        $rendered_sidebars = array_filter( $this->rendered_sidebars );
        $rendered_widgets  = array_filter( $this->rendered_widgets );

        

            );

            if ( current_user_can( 'edit_user', $user_object->ID ) ) {
                $edit            = "<strong><a href=\"{$edit_link}\">{$user_object->user_login}</a>{$super_admin}</strong><br />";
                $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
            } else {
                $edit = "<strong>{$user_object->user_login}{$super_admin}</strong><br />";
            }

            if ( ! is_multisite()
                && get_current_user_id() !== $user_object->ID
                && current_user_can( 'delete_user', $user_object->ID )
            ) {
                $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url( "users.php?action=delete&amp;user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Delete' ) . '</a>';
            }

            if ( is_multisite()
                && current_user_can( 'remove_user', $user_object->ID )
            ) {
                $actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url( $url . "action=remove&amp;user=$user_object->ID", 'bulk-users' ) . "'>" . __( 'Remove' ) . '</a>';
            }

            

    public function get_current_item_permissions_check( $request ) {
        $user = $this->get_user( $request );

        if ( is_wp_error( $user ) ) {
            return $user;
        }

        if ( get_current_user_id() !== $user->ID ) {
            return new WP_Error(
                'rest_cannot_introspect_app_password_for_non_authenticated_user',
                __( 'The authenticated application password can only be introspected for the current user.' ),
                array( 'status' => rest_authorization_required_code() )
            );
        }

        return true;
    }

    /** * Retrieves the application password being currently used for authentication of a user. * * @since 5.7.0 * * @param WP_REST_Request $request Full details about the request. * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. */
define( 'DOING_AUTOSAVE', true );
        }

        $post = get_post( $request['id'] );

        if ( is_wp_error( $post ) ) {
            return $post;
        }

        $prepared_post     = $this->parent_controller->prepare_item_for_database( $request );
        $prepared_post->ID = $post->ID;
        $user_id           = get_current_user_id();

        // We need to check post lock to ensure the original author didn't leave their browser tab open.         if ( ! function_exists( 'wp_check_post_lock' ) ) {
            require_once ABSPATH . 'wp-admin/includes/post.php';
        }

        $post_lock = wp_check_post_lock( $post->ID );
        $is_draft  = 'draft' === $post->post_status || 'auto-draft' === $post->post_status;

        if ( $is_draft && (int) $post->post_author === $user_id && ! $post_lock ) {
            /* * Draft posts for the same author: autosaving updates the post and does not create a revision. * Convert the post object to an array and add slashes, wp_update_post() expects escaped array. */
if ( ! $allow_anonymous ) {
                return new WP_Error(
                    'rest_comment_login_required',
                    __( 'Sorry, you must be logged in to comment.' ),
                    array( 'status' => 401 )
                );
            }
        }

        // Limit who can set comment `author`, `author_ip` or `status` to anything other than the default.         if ( isset( $request['author'] ) && get_current_user_id() !== $request['author'] && ! current_user_can( 'moderate_comments' ) ) {
            return new WP_Error(
                'rest_comment_invalid_author',
                /* translators: %s: Request parameter. */
                sprintf( __( "Sorry, you are not allowed to edit '%s' for comments." ), 'author' ),
                array( 'status' => rest_authorization_required_code() )
            );
        }

        if ( isset( $request['author_ip'] ) && ! current_user_can( 'moderate_comments' ) ) {
            if ( empty( $_SERVER['REMOTE_ADDR'] ) || $request['author_ip'] !== $_SERVER['REMOTE_ADDR'] ) {
                return new WP_Error(
                    

        $caps_required = array(
            // None currently.         );

        // Get dismissed pointers.         $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );

        $got_pointers = false;
        foreach ( array_diff( $pointers$dismissed ) as $pointer ) {
            if ( isset( $caps_required[ $pointer ] ) ) {
                foreach ( $caps_required[ $pointer ] as $cap ) {
                    if ( ! current_user_can( $cap ) ) {
                        continue 2;
                    }
                }
            }

            
/** * Retrieves the edit user link. * * @since 3.5.0 * * @param int $user_id Optional. User ID. Defaults to the current user. * @return string URL to edit user page or empty string. */
function get_edit_user_link( $user_id = null ) {
    if ( ! $user_id ) {
        $user_id = get_current_user_id();
    }

    if ( empty( $user_id ) || ! current_user_can( 'edit_user', $user_id ) ) {
        return '';
    }

    $user = get_userdata( $user_id );

    if ( ! $user ) {
        return '';
    }

    
return $is_flood;
    }

    // Don't throttle admins or moderators.     if ( current_user_can( 'manage_options' ) || current_user_can( 'moderate_comments' ) ) {
        return false;
    }

    $hour_ago = gmdate( 'Y-m-d H:i:s', time() - HOUR_IN_SECONDS );

    if ( is_user_logged_in() ) {
        $user         = get_current_user_id();
        $check_column = '`user_id`';
    } else {
        $user         = $ip;
        $check_column = '`comment_author_IP`';
    }

    $sql = $wpdb->prepare(
        "SELECT `comment_date_gmt` FROM `$wpdb->comments` WHERE `comment_date_gmt` >= %s AND ( $check_column = %s OR `comment_author_email` = %s ) ORDER BY `comment_date_gmt` DESC LIMIT 1",
        $hour_ago,
        $user,
        $email
    );
<?php endif; ?> </div> <?php wp_print_file_editor_templates(); ?> </form> <?php endif; // End if $error. ?> <br class="clear" /> </div> <?php $dismissed_pointers = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
if ( ! in_array( 'theme_editor_notice', $dismissed_pointers, true ) ) :
    // Get a back URL.     $referer = wp_get_referer();

    $excluded_referer_basenames = array( 'theme-editor.php', 'wp-login.php' );

    $return_url = admin_url( '/' );
    if ( $referer ) {
        $referer_path = parse_url( $referer, PHP_URL_PATH );
        if ( is_string( $referer_path ) && ! in_array( basename( $referer_path )$excluded_referer_basenames, true ) ) {
            $return_url = $referer;
        }
Home | Imprint | This part of the site doesn't use cookies.