<?php
require_once __DIR__ . '/admin.php';
global $typenow;
if ( ! $typenow ) {
wp_die( __( 'Invalid post type.' ) );
}
if ( ! in_array( $typenow, get_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 $post_type, $post_type_object;
$post_type = $typenow;
$post_type_object = get_post_type_object( $post_type );
if ( ! $post_type_object ) {
wp_die( __( 'Invalid post type.' ) );
}
if ( ! current_user_can( $post_type_object->cap->edit_posts ) ) {
wp_die(