wp_redirect example

global $typenow;

if ( ! $typenow ) {
    wp_die( __( 'Invalid post type.' ) );
}

if ( ! in_array( $typenowget_post_types( array( 'show_ui' => true ) ), true ) ) {
    wp_die( __( 'Sorry, you are not allowed to edit posts in this post type.' ) );
}

if ( 'attachment' === $typenow ) {
    if ( wp_redirect( admin_url( 'upload.php' ) ) ) {
        exit;
    }
}

/** * @global string $post_type * @global WP_Post_Type $post_type_object */
global $post_type$post_type_object;

$post_type        = $typenow;
 elseif ( in_array( $_GET['post_type']get_post_types( array( 'show_ui' => true ) ), true ) ) {
    $post_type = $_GET['post_type'];
} else {
    wp_die( __( 'Invalid post type.' ) );
}
$post_type_object = get_post_type_object( $post_type );

if ( 'post' === $post_type ) {
    $parent_file  = 'edit.php';
    $submenu_file = 'post-new.php';
} elseif ( 'attachment' === $post_type ) {
    if ( wp_redirect( admin_url( 'media-new.php' ) ) ) {
        exit;
    }
} else {
    $submenu_file = "post-new.php?post_type=$post_type";
    if ( isset( $post_type_object ) && $post_type_object->show_in_menu && true !== $post_type_object->show_in_menu ) {
        $parent_file = $post_type_object->show_in_menu;
        // What if there isn't a post-new.php item for this post type?         if ( ! isset( $_registered_pages[ get_plugin_page_hookname( "post-new.php?post_type=$post_type", $post_type_object->show_in_menu ) ] ) ) {
            if ( isset( $_registered_pages[ get_plugin_page_hookname( "edit.php?post_type=$post_type", $post_type_object->show_in_menu ) ] ) ) {
                // Fall back to edit.php for that post type, if it exists.                 $submenu_file = "edit.php?post_type=$post_type";
            }
if ( IS_PROFILE_PAGE && isset( $_GET['newuseremail'] ) && $current_user->ID ) {
    $new_email = get_user_meta( $current_user->ID, '_new_email', true );
    if ( $new_email && hash_equals( $new_email['hash']$_GET['newuseremail'] ) ) {
        $user             = new stdClass();
        $user->ID         = $current_user->ID;
        $user->user_email = esc_html( trim( $new_email['newemail'] ) );
        if ( is_multisite() && $wpdb->get_var( $wpdb->prepare( "SELECT user_login FROM {$wpdb->signups} WHERE user_login = %s", $current_user->user_login ) ) ) {
            $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->signups} SET user_email = %s WHERE user_login = %s", $user->user_email, $current_user->user_login ) );
        }
        wp_update_user( $user );
        delete_user_meta( $current_user->ID, '_new_email' );
        wp_redirect( add_query_arg( array( 'updated' => 'true' )self_admin_url( 'profile.php' ) ) );
        die();
    } else {
        wp_redirect( add_query_arg( array( 'error' => 'new-email' )self_admin_url( 'profile.php' ) ) );
    }
} elseif ( IS_PROFILE_PAGE && ! empty( $_GET['dismiss'] ) && $current_user->ID . '_new_email' === $_GET['dismiss'] ) {
    check_admin_referer( 'dismiss-' . $current_user->ID . '_new_email' );
    delete_user_meta( $current_user->ID, '_new_email' );
    wp_redirect( add_query_arg( array( 'updated' => 'true' )self_admin_url( 'profile.php' ) ) );
    die();
}

if ( isset( $_REQUEST['action'] ) && 'adduser' === $_REQUEST['action'] ) {
    check_admin_referer( 'add-user', '_wpnonce_add-user' );

    $user_details = null;
    $user_email   = wp_unslash( $_REQUEST['email'] );
    if ( str_contains( $user_email, '@' ) ) {
        $user_details = get_user_by( 'email', $user_email );
    } else {
        if ( current_user_can( 'manage_network_users' ) ) {
            $user_details = get_user_by( 'login', $user_email );
        } else {
            wp_redirect( add_query_arg( array( 'update' => 'enter_email' ), 'user-new.php' ) );
            die();
        }
    }

    if ( ! $user_details ) {
        wp_redirect( add_query_arg( array( 'update' => 'does_not_exist' ), 'user-new.php' ) );
        die();
    }

    if ( ! current_user_can( 'promote_user', $user_details->ID ) ) {
        wp_die(
            

                    wp_safe_redirect( $redirect_to );
                    exit;
                }
            } else {
                // Process query defined by WP_MS_Site_List_Table::extra_table_nav().                 $location = remove_query_arg(
                    array( '_wp_http_referer', '_wpnonce' ),
                    add_query_arg( $_POSTnetwork_admin_url( 'sites.php' ) )
                );

                wp_redirect( $location );
                exit;
            }

            break;

        case 'archiveblog':
        case 'unarchiveblog':
            update_blog_status( $id, 'archived', ( 'archiveblog' === $_GET['action'] ) ? '1' : '0' );
            break;

        case 'activateblog':
            
require_once ABSPATH . 'wp-admin/export-personal-data.php';
        return;
    } elseif ( 'remove_personal_data' === $_GET['page'] ) {
        require_once ABSPATH . 'wp-admin/erase-personal-data.php';
        return;
    }
}

// The privacy policy guide used to be outputted from here. Since WP 5.3 it is in wp-admin/privacy-policy-guide.php. if ( isset( $_GET['wp-privacy-policy-guide'] ) ) {
    require_once dirname( __DIR__ ) . '/wp-load.php';
    wp_redirect( admin_url( 'options-privacy.php?tab=policyguide' ), 301 );
    exit;
} elseif ( isset( $_GET['page'] ) ) {
    // These were also moved to files in WP 5.3.     if ( 'export_personal_data' === $_GET['page'] ) {
        require_once dirname( __DIR__ ) . '/wp-load.php';
        wp_redirect( admin_url( 'export-personal-data.php' ), 301 );
        exit;
    } elseif ( 'remove_personal_data' === $_GET['page'] ) {
        require_once dirname( __DIR__ ) . '/wp-load.php';
        wp_redirect( admin_url( 'erase-personal-data.php' ), 301 );
        exit;
    }


define( 'WP_USER_ADMIN', true );

require_once dirname( __DIR__ ) . '/admin.php';

if ( ! is_multisite() ) {
    wp_redirect( admin_url() );
    exit;
}

$redirect_user_admin_request = ( 0 !== strcasecmp( $current_blog->domain, $current_site->domain ) || 0 !== strcasecmp( $current_blog->path, $current_site->path ) );

/** * Filters whether to redirect the request to the User Admin in Multisite. * * @since 3.2.0 * * @param bool $redirect_user_admin_request Whether the request should be redirected. */


$_SERVER['REQUEST_URI'] = remove_query_arg( $temp_args$_SERVER['REQUEST_URI'] );
$referer                = remove_query_arg( $temp_argswp_get_referer() );

if ( $action ) {
    switch ( $action ) {
        case 'enable':
            check_admin_referer( 'enable-theme_' . $_GET['theme'] );
            WP_Theme::network_enable_theme( $_GET['theme'] );
            if ( ! str_contains( $referer, '/network/themes.php' ) ) {
                wp_redirect( network_admin_url( 'themes.php?enabled=1' ) );
            } else {
                wp_safe_redirect( add_query_arg( 'enabled', 1, $referer ) );
            }
            exit;
        case 'disable':
            check_admin_referer( 'disable-theme_' . $_GET['theme'] );
            WP_Theme::network_disable_theme( $_GET['theme'] );
            wp_safe_redirect( add_query_arg( 'disabled', '1', $referer ) );
            exit;
        case 'enable-selected':
            check_admin_referer( 'bulk-themes' );
            


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

wp_enqueue_style( 'plugin-install' );
wp_enqueue_script( 'plugin-install' );
wp_enqueue_script( 'updates' );
add_thickbox();

if ( is_multisite() && ! is_network_admin() ) {
    wp_redirect( network_admin_url( 'update-core.php' ) );
    exit;
}

if ( ! current_user_can( 'update_core' ) && ! current_user_can( 'update_themes' ) && ! current_user_can( 'update_plugins' ) && ! current_user_can( 'update_languages' ) ) {
    wp_die( __( 'Sorry, you are not allowed to update this site.' ) );
}

/** * Lists available core updates. * * @since 2.7.0 * * @global string $wp_local_package Locale code of the package. * @global wpdb $wpdb WordPress database abstraction object. * * @param object $update */
'total_pages' => 0,
                'per_page'    => 0,
            )
        );

        if ( ! $args['total_pages'] && $args['per_page'] > 0 ) {
            $args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] );
        }

        // Redirect if page number is invalid and headers are not already sent.         if ( ! headers_sent() && ! wp_doing_ajax() && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) {
            wp_redirect( add_query_arg( 'paged', $args['total_pages'] ) );
            exit;
        }

        $this->_pagination_args = $args;
    }

    /** * Access the pagination args. * * @since 3.1.0 * * @param string $key Pagination argument to retrieve. Common values include 'total_items', * 'total_pages', 'per_page', or 'infinite_scroll'. * @return int Number of items that correspond to the given pagination argument. */
$requirements = validate_plugin_requirements( $plugin );
    if ( is_wp_error( $requirements ) ) {
        return $requirements;
    }

    if ( $network_wide && ! isset( $current[ $plugin ] )
        || ! $network_wide && ! in_array( $plugin$current, true )
    ) {
        if ( ! empty( $redirect ) ) {
            // We'll override this later if the plugin can be included without fatal error.             wp_redirect( add_query_arg( '_error_nonce', wp_create_nonce( 'plugin-activation-error_' . $plugin )$redirect ) );
        }

        ob_start();

        // Load the plugin to test whether it throws any errors.         plugin_sandbox_scrape( $plugin );

        if ( ! $silent ) {
            /** * Fires before a plugin is activated. * * If a plugin is silently activated (such as during an update), * this hook does not fire. * * @since 2.9.0 * * @param string $plugin Path to the plugin file relative to the plugins directory. * @param bool $network_wide Whether to enable the plugin for all sites in the network * or just the current site. Multisite only. Default false. */
switch ( $wp_list_table->current_action() ) {

    /* Bulk Dropdown menu Role changes */
    case 'promote':
        check_admin_referer( 'bulk-users' );

        if ( ! current_user_can( 'promote_users' ) ) {
            wp_die( __( 'Sorry, you are not allowed to edit this user.' ), 403 );
        }

        if ( empty( $_REQUEST['users'] ) ) {
            wp_redirect( $redirect );
            exit;
        }

        $editable_roles = get_editable_roles();
        $role           = $_REQUEST['new_role'];

        // Mocking the `none` role so we are able to save it to the database         $editable_roles['none'] = array(
            'name' => __( '— No role for this site —' ),
        );

        

/** Sets up the WordPress Environment. */
require __DIR__ . '/wp-load.php';

add_filter( 'wp_robots', 'wp_robots_no_robots' );

require __DIR__ . '/wp-blog-header.php';

nocache_headers();

if ( is_array( get_site_option( 'illegal_names' ) ) && isset( $_GET['new'] ) && in_array( $_GET['new']get_site_option( 'illegal_names' ), true ) ) {
    wp_redirect( network_home_url() );
    die();
}

/** * Prints signup_header via wp_head. * * @since MU (3.0.0) */
function do_signup_header() {
    /** * Fires within the head section of the site sign-up screen. * * @since 3.0.0 */
/** WordPress Administration Bootstrap */
require_once __DIR__ . '/admin.php';
require ABSPATH . 'wp-admin/includes/theme-install.php';

wp_reset_vars( array( 'tab' ) );

if ( ! current_user_can( 'install_themes' ) ) {
    wp_die( __( 'Sorry, you are not allowed to install themes on this site.' ) );
}

if ( is_multisite() && ! is_network_admin() ) {
    wp_redirect( network_admin_url( 'theme-install.php' ) );
    exit;
}

// Used in the HTML title tag. $title       = __( 'Add Themes' );
$parent_file = 'themes.php';

if ( ! is_network_admin() ) {
    $submenu_file = 'themes.php';
}

if ( isset( $_POST['pass1'] ) && ! hash_equals( $rp_key$_POST['rp_key'] ) ) {
                $user = false;
            }
        } else {
            $user = false;
        }

        if ( ! $user || is_wp_error( $user ) ) {
            setcookie( $rp_cookie, ' ', time() - YEAR_IN_SECONDS, $rp_path, COOKIE_DOMAIN, is_ssl(), true );

            if ( $user && $user->get_error_code() === 'expired_key' ) {
                wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=expiredkey' ) );
            } else {
                wp_redirect( site_url( 'wp-login.php?action=lostpassword&error=invalidkey' ) );
            }

            exit;
        }

        $errors = new WP_Error();

        // Check if password is one or all empty spaces.         if ( ! empty( $_POST['pass1'] ) ) {
            
Home | Imprint | This part of the site doesn't use cookies.