current_user_can example

if ( ! isset( $_GET['tax'] ) ) {
        wp_die( 0 );
    }

    $taxonomy        = sanitize_key( $_GET['tax'] );
    $taxonomy_object = get_taxonomy( $taxonomy );

    if ( ! $taxonomy_object ) {
        wp_die( 0 );
    }

    if ( ! current_user_can( $taxonomy_object->cap->assign_terms ) ) {
        wp_die( -1 );
    }

    $search = wp_unslash( $_GET['q'] );

    $comma = _x( ',', 'tag delimiter' );
    if ( ',' !== $comma ) {
        $search = str_replace( $comma, ',', $search );
    }

    if ( str_contains( $search, ',' ) ) {
        
<?php /** * Media Library administration panel. * * @package WordPress * @subpackage Administration */

/** WordPress Administration Bootstrap */
require_once __DIR__ . '/admin.php';

if ( ! current_user_can( 'upload_files' ) ) {
    wp_die( __( 'Sorry, you are not allowed to upload files.' ) );
}

$message = '';
if ( ! empty( $_GET['posted'] ) ) {
    $message = __( 'Media file updated.' );

    $_SERVER['REQUEST_URI'] = remove_query_arg( array( 'posted' )$_SERVER['REQUEST_URI'] );
    unset( $_GET['posted'] );
}


    public function floated_admin_avatar( $name$comment_id ) {
        $comment = get_comment( $comment_id );
        $avatar  = get_avatar( $comment, 32, 'mystery' );
        return "$avatar $name";
    }

    /** * @return bool */
    public function ajax_user_can() {
        return current_user_can( 'edit_posts' );
    }

    /** * @global string $mode List table view mode. * @global int $post_id * @global string $comment_status * @global string $comment_type * @global string $search */
    public function prepare_items() {
        global $mode$post_id$comment_status$comment_type$search;

        
public function __construct( $manager ) {
        $this->manager                     = $manager;
        $this->original_nav_menu_locations = get_nav_menu_locations();

        // See https://github.com/xwp/wp-customize-snapshots/blob/962586659688a5b1fd9ae93618b7ce2d4e7a421c/php/class-customize-snapshot-manager.php#L469-L499         add_action( 'customize_register', array( $this, 'customize_register' ), 11 );
        add_filter( 'customize_dynamic_setting_args', array( $this, 'filter_dynamic_setting_args' ), 10, 2 );
        add_filter( 'customize_dynamic_setting_class', array( $this, 'filter_dynamic_setting_class' ), 10, 3 );
        add_action( 'customize_save_nav_menus_created_posts', array( $this, 'save_nav_menus_created_posts' ) );

        // Skip remaining hooks when the user can't manage nav menus anyway.         if ( ! current_user_can( 'edit_theme_options' ) ) {
            return;
        }

        add_filter( 'customize_refresh_nonces', array( $this, 'filter_nonces' ) );
        add_action( 'wp_ajax_load-available-menu-items-customizer', array( $this, 'ajax_load_available_items' ) );
        add_action( 'wp_ajax_search-available-menu-items-customizer', array( $this, 'ajax_search_available_items' ) );
        add_action( 'wp_ajax_customize-nav-menus-insert-auto-draft', array( $this, 'ajax_insert_auto_draft_post' ) );
        add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
        add_action( 'customize_controls_print_footer_scripts', array( $this, 'print_templates' ) );
        add_action( 'customize_controls_print_footer_scripts', array( $this, 'available_items_template' ) );
        add_action( 'customize_preview_init', array( $this, 'customize_preview_init' ) );
        
<?php /** * Privacy tools, Export Personal Data screen. * * @package WordPress * @subpackage Administration */

/** WordPress Administration Bootstrap */
require_once __DIR__ . '/admin.php';

if ( ! current_user_can( 'export_others_personal_data' ) ) {
    wp_die( __( 'Sorry, you are not allowed to export personal data on this site.' ) );
}

// Used in the HTML title tag. $title = __( 'Export Personal Data' );

// Contextual help - choose Help on the top right of admin panel to preview this. get_current_screen()->add_help_tab(
    array(
        'id'      => 'overview',
        'title'   => __( 'Overview' ),
        


    /** * Checks required user capabilities and whether the theme has the * feature support required by the section. * * @since 3.4.0 * * @return bool False if theme doesn't support the section or user doesn't have the capability. */
    final public function check_capabilities() {
        if ( $this->capability && ! current_user_can( $this->capability ) ) {
            return false;
        }

        if ( $this->theme_supports && ! current_theme_supports( ... (array) $this->theme_supports ) ) {
            return false;
        }

        return true;
    }

    /** * Get the section's content for insertion into the Customizer pane. * * @since 4.1.0 * * @return string Contents of the section. */
array(
                'plural' => 'bookmarks',
                'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
            )
        );
    }

    /** * @return bool */
    public function ajax_user_can() {
        return current_user_can( 'manage_links' );
    }

    /** * @global int $cat_id * @global string $s * @global string $orderby * @global string $order */
    public function prepare_items() {
        global $cat_id$s$orderby$order;

        
/** * Checks whether the current user has read permission for the endpoint. * * This allows for any user that can `edit_theme_options` or edit any REST API available post type. * * @since 5.9.0 * * @param WP_REST_Request $request Full details about the request. * @return bool|WP_Error Whether the current user has permission. */
    protected function check_has_read_only_access( $request ) {
        if ( current_user_can( 'edit_theme_options' ) ) {
            return true;
        }

        if ( current_user_can( 'edit_posts' ) ) {
            return true;
        }

        foreach ( get_post_types( array( 'show_in_rest' => true ), 'objects' ) as $post_type ) {
            if ( current_user_can( $post_type->cap->edit_posts ) ) {
                return true;
            }
        }


/** WordPress Administration Bootstrap */
require_once __DIR__ . '/admin.php';

/** WordPress Translation Installation API */
require_once ABSPATH . 'wp-admin/includes/translation-install.php';

if ( ! current_user_can( 'manage_options' ) ) {
    wp_die( __( 'Sorry, you are not allowed to manage options for this site.' ) );
}

// Used in the HTML title tag. $title       = __( 'General Settings' );
$parent_file = 'options-general.php';
/* translators: Date and time format for exact current time, mainly about timezones, see https://www.php.net/manual/datetime.format.php */
$timezone_format = _x( 'Y-m-d H:i:s', 'timezone date format' );

add_action( 'admin_head', 'options_general_add_js' );

if ( $set['drag_drop_upload'] ) {
            self::$drag_drop_upload = true;
        }

        if ( ! empty( $set['editor_height'] ) ) {
            $height = ' style="height: ' . (int) $set['editor_height'] . 'px"';
        } else {
            $height = ' rows="' . (int) $set['textarea_rows'] . '"';
        }

        if ( ! current_user_can( 'upload_files' ) ) {
            $set['media_buttons'] = false;
        }

        if ( self::$this_tinymce ) {
            $autocomplete = ' autocomplete="off"';

            if ( self::$this_quicktags ) {
                $default_editor = $set['default_editor'] ? $set['default_editor'] : wp_default_editor();
                // 'html' is used for the "Text" editor tab.                 if ( 'html' !== $default_editor ) {
                    $default_editor = 'tinymce';
                }
/** * Filters the path of the current template before including it. * * @since 3.0.0 * * @param string $template The path of the template to include. */
    $template = apply_filters( 'template_include', $template );
    if ( $template ) {
        include $template;
    } elseif ( current_user_can( 'switch_themes' ) ) {
        $theme = wp_get_theme();
        if ( $theme->errors() ) {
            wp_die( $theme->errors() );
        }
    }
    return;
}
// Check nonce and capabilities.         $nonce     = $_REQUEST['_wpnonce'];
        $error_msg = false;

        // For output of the Quick Draft dashboard widget.         require_once ABSPATH . 'wp-admin/includes/dashboard.php';

        if ( ! wp_verify_nonce( $nonce, 'add-post' ) ) {
            $error_msg = __( 'Unable to submit this form, please refresh and try again.' );
        }

        if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) {
            exit;
        }

        if ( $error_msg ) {
            return wp_dashboard_quick_press( $error_msg );
        }

        $post = get_post( $_REQUEST['post_ID'] );
        check_admin_referer( 'add-' . $post->post_type );

        $_POST['comment_status'] = get_default_comment_status( $post->post_type );
        
/** * Multisite users administration panel. * * @package WordPress * @subpackage Multisite * @since 3.0.0 */

/** Load WordPress Administration Bootstrap */
require_once __DIR__ . '/admin.php';

if ( ! current_user_can( 'manage_network_users' ) ) {
    wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
}

if ( isset( $_GET['action'] ) ) {
    /** This action is documented in wp-admin/network/edit.php */
    do_action( 'wpmuadminedit' );

    switch ( $_GET['action'] ) {
        case 'deleteuser':
            if ( ! current_user_can( 'manage_network_users' ) ) {
                wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
            }


    /** * Checks whether a given request has permission to read menu locations. * * @since 5.9.0 * * @param WP_REST_Request $request Full details about the request. * @return WP_Error|bool True if the request has read access, WP_Error object otherwise. */
    public function get_items_permissions_check( $request ) {
        if ( ! current_user_can( 'edit_theme_options' ) ) {
            return new WP_Error(
                'rest_cannot_view',
                __( 'Sorry, you are not allowed to view menu locations.' ),
                array( 'status' => rest_authorization_required_code() )
            );
        }

        return true;
    }

    /** * Retrieves all menu locations, depending on user context. * * @since 5.9.0 * * @param WP_REST_Request $request Full details about the request. * @return WP_Error|WP_REST_Response Response object on success, or WP_Error object on failure. */
<?php /** * Plugins administration panel. * * @package WordPress * @subpackage Administration */

/** WordPress Administration Bootstrap */
require_once __DIR__ . '/admin.php';

if ( ! current_user_can( 'activate_plugins' ) ) {
    wp_die( __( 'Sorry, you are not allowed to manage plugins for this site.' ) );
}

$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
$pagenum       = $wp_list_table->get_pagenum();

$action = $wp_list_table->current_action();

$plugin = isset( $_REQUEST['plugin'] ) ? wp_unslash( $_REQUEST['plugin'] ) : '';
$s      = isset( $_REQUEST['s'] ) ? urlencode( wp_unslash( $_REQUEST['s'] ) ) : '';

Home | Imprint | This part of the site doesn't use cookies.