wp_die example



get_current_screen()->set_help_sidebar(
    '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
    '<p>' . __( '<a href="https://wordpress.org/documentation/article/network-admin-updates-screen/">Documentation on Upgrade Network</a>' ) . '</p>' .
    '<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>'
);

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

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

echo '<div class="wrap">';
echo '<h1>' . __( 'Upgrade Network' ) . '</h1>';

$action = isset( $_GET['action'] ) ? $_GET['action'] : 'show';

switch ( $action ) {
    case 'upgrade':
        $n = ( isset( $_GET['n'] ) ) ? (int) $_GET['n'] : 0;

        


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

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

get_current_screen()->add_help_tab( get_site_screen_help_tab_args() );
get_current_screen()->set_help_sidebar( get_site_screen_help_sidebar_content() );

get_current_screen()->set_screen_reader_content(
    array(
        'heading_views'      => __( 'Filter site themes list' ),
        'heading_pagination' => __( 'Site themes list navigation' ),
        'heading_list'       => __( 'Site themes list' ),
    )
);
$feed = get_query_var( 'feed' );

    // Remove the pad, if present.     $feed = preg_replace( '/^_+/', '', $feed );

    if ( '' === $feed || 'feed' === $feed ) {
        $feed = get_default_feed();
    }

    if ( ! has_action( "do_feed_{$feed}) ) {
        wp_die( __( '<strong>Error:</strong> This is not a valid feed template.' ), '', array( 'response' => 404 ) );
    }

    /** * Fires once the given feed is loaded. * * The dynamic portion of the hook name, `$feed`, refers to the feed template name. * * Possible hook names include: * * - `do_feed_atom` * - `do_feed_rdf` * - `do_feed_rss` * - `do_feed_rss2` * * @since 2.1.0 * @since 4.4.0 The `$feed` parameter was added. * * @param bool $is_comment_feed Whether the feed is a comment feed. * @param string $feed The feed name. */

        do_action( $page_hook );
    } else {
        if ( validate_file( $plugin_page ) ) {
            wp_die( __( 'Invalid plugin page.' ) );
        }

        if ( ! ( file_exists( WP_PLUGIN_DIR . "/$plugin_page) && is_file( WP_PLUGIN_DIR . "/$plugin_page) )
            && ! ( file_exists( WPMU_PLUGIN_DIR . "/$plugin_page) && is_file( WPMU_PLUGIN_DIR . "/$plugin_page) )
        ) {
            /* translators: %s: Admin page generated by a plugin. */
            wp_die( sprintf( __( 'Cannot load %s.' )htmlentities( $plugin_page ) ) );
        }

        /** * Fires before a particular screen is loaded. * * The load-* hook fires in a number of contexts. This hook is for plugin screens * where the file to load is directly included, rather than the use of a function. * * The dynamic portion of the hook name, `$plugin_page`, refers to the plugin basename. * * @see plugin_basename() * * @since 1.5.0 */
/** * 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'] );
}

if ( ! empty( $_GET['attached'] ) && absint( $_GET['attached'] ) ) {
    
if ( isset( $_REQUEST['action'] ) && 'upload-attachment' === $_REQUEST['action'] ) {
    require ABSPATH . 'wp-admin/includes/ajax-actions.php';

    send_nosniff_header();
    nocache_headers();

    wp_ajax_upload_attachment();
    die( '0' );
}

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

// Just fetch the detail form for that attachment. if ( isset( $_REQUEST['attachment_id'] ) && (int) $_REQUEST['attachment_id'] && $_REQUEST['fetch'] ) {
    $id   = (int) $_REQUEST['attachment_id'];
    $post = get_post( $id );
    if ( 'attachment' !== $post->post_type ) {
        wp_die( __( 'Invalid post type.' ) );
    }

    switch ( $_REQUEST['fetch'] ) {
        

    if ( isset( $_POST['pass2'] ) ) {
        $pass2 = trim( $_POST['pass2'] );
    }

    if ( isset( $_POST['role'] ) && current_user_can( 'promote_users' ) && ( ! $user_id || current_user_can( 'promote_user', $user_id ) ) ) {
        $new_role = sanitize_text_field( $_POST['role'] );

        // If the new role isn't editable by the logged-in user die with error.         $editable_roles = get_editable_roles();
        if ( ! empty( $new_role ) && empty( $editable_roles[ $new_role ] ) ) {
            wp_die( __( 'Sorry, you are not allowed to give users that role.' ), 403 );
        }

        $potential_role = isset( $wp_roles->role_objects[ $new_role ] ) ? $wp_roles->role_objects[ $new_role ] : false;

        /* * Don't let anyone with 'promote_users' edit their own role to something without it. * Multisite super admins can freely edit their roles, they possess all caps. */
        if (
            ( is_multisite() && current_user_can( 'manage_network_users' ) ) ||
            get_current_user_id() !== $user_id ||
            (
$reject_url = add_query_arg( 'success', 'false', $success_url );
} else {
    $reject_url = null;
}

$user = wp_get_current_user();

$request  = compact( 'app_name', 'app_id', 'success_url', 'reject_url' );
$is_valid = wp_is_authorize_application_password_request_valid( $request$user );

if ( is_wp_error( $is_valid ) ) {
    wp_die(
        __( 'The Authorize Application request is not allowed.' ) . ' ' . implode( ' ', $is_valid->get_error_messages() ),
        __( 'Cannot Authorize Application' )
    );
}

if ( wp_is_site_protected_by_basic_auth( 'front' ) ) {
    wp_die(
        __( 'Your website appears to use Basic Authentication, which is not currently compatible with application passwords.' ),
        __( 'Cannot Authorize Application' ),
        array(
            'response'  => 501,
            


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

if ( ! current_user_can( 'list_users' ) ) {
    wp_die(
        '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
        '<p>' . __( 'Sorry, you are not allowed to list users.' ) . '</p>',
        403
    );
}

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

// Used in the HTML title tag. $title       = __( 'Users' );


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

$parent_file  = 'edit.php';
$submenu_file = 'edit.php';

wp_reset_vars( array( 'action' ) );

if ( isset( $_GET['post'] ) && isset( $_POST['post_ID'] ) && (int) $_GET['post'] !== (int) $_POST['post_ID'] ) {
    wp_die( __( 'A post ID mismatch has been detected.' )__( 'Sorry, you are not allowed to edit this item.' ), 400 );
} elseif ( isset( $_GET['post'] ) ) {
    $post_id = (int) $_GET['post'];
} elseif ( isset( $_POST['post_ID'] ) ) {
    $post_id = (int) $_POST['post_ID'];
} else {
    $post_id = 0;
}
$post_ID = $post_id;

/** * @global string $post_type * @global object $post_type_object * @global WP_Post $post Global post object. */
/** * Handles fetching a list table via AJAX. * * @since 3.1.0 */
function wp_ajax_fetch_list() {
    $list_class = $_GET['list_args']['class'];
    check_ajax_referer( "fetch-list-$list_class", '_ajax_fetch_list_nonce' );

    $wp_list_table = _get_list_table( $list_class, array( 'screen' => $_GET['list_args']['screen']['id'] ) );
    if ( ! $wp_list_table ) {
        wp_die( 0 );
    }

    if ( ! $wp_list_table->ajax_user_can() ) {
        wp_die( -1 );
    }

    $wp_list_table->ajax_response();

    wp_die( 0 );
}

require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';

wp_enqueue_script( 'wp-a11y' );

if ( isset( $_GET['action'] ) ) {
    $plugin = isset( $_REQUEST['plugin'] ) ? trim( $_REQUEST['plugin'] ) : '';
    $theme  = isset( $_REQUEST['theme'] ) ? urldecode( $_REQUEST['theme'] ) : '';
    $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';

    if ( 'update-selected' === $action ) {
        if ( ! current_user_can( 'update_plugins' ) ) {
            wp_die( __( 'Sorry, you are not allowed to update plugins for this site.' ) );
        }

        check_admin_referer( 'bulk-update-plugins' );

        if ( isset( $_GET['plugins'] ) ) {
            $plugins = explode( ',', stripslashes( $_GET['plugins'] ) );
        } elseif ( isset( $_POST['checked'] ) ) {
            $plugins = (array) $_POST['checked'];
        } else {
            $plugins = array();
        }

        
if ( ! isset( $_GET['action']$_GET['rm_token']$_GET['rm_key'] ) || self::LOGIN_ACTION_ENTER !== $_GET['action'] ) {
            return;
        }

        if ( ! function_exists( 'wp_generate_password' ) ) {
            require_once ABSPATH . WPINC . '/pluggable.php';
        }

        $validated = $this->key_service->validate_recovery_mode_key( $_GET['rm_token']$_GET['rm_key']$ttl );

        if ( is_wp_error( $validated ) ) {
            wp_die( $validated, '' );
        }

        $this->cookie_service->set_cookie();

        $url = add_query_arg( 'action', self::LOGIN_ACTION_ENTERED, wp_login_url() );
        wp_redirect( $url );
        die;
    }

    /** * Gets a URL to begin recovery mode. * * @since 5.2.0 * * @param string $token Recovery Mode token created by {@see generate_recovery_mode_token()}. * @param string $key Recovery Mode key created by {@see generate_and_store_recovery_mode_key()}. * @return string Recovery mode begin URL. */
require_once ABSPATH . 'wp-admin/includes/admin.php';

nocache_headers();

/** This action is documented in wp-admin/admin.php */
do_action( 'admin_init' );

$action = ! empty( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';

// Reject invalid parameters. if ( ! is_scalar( $action ) ) {
    wp_die( '', 400 );
}

if ( ! is_user_logged_in() ) {
    if ( empty( $action ) ) {
        /** * Fires on a non-authenticated admin post request where no action is supplied. * * @since 2.6.0 */
        do_action( 'admin_post_nopriv' );
    } else {
        


if ( ! isset( $_GET['inline'] ) ) {
    define( 'IFRAME_REQUEST', true );
}

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

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

wp_enqueue_script( 'plupload-handlers' );
wp_enqueue_script( 'image-edit' );
wp_enqueue_script( 'set-post-thumbnail' );
wp_enqueue_style( 'imgareaselect' );
wp_enqueue_script( 'media-gallery' );

header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );

// IDs should be integers.
Home | Imprint | This part of the site doesn't use cookies.