File "edit.php"
Full Path: /home/fashionbridge/public_html/wp-admin/network/edit.php
File size: 4 KB
MIME-type: text/x-php
Charset: utf-8
<?php
/**
* Edit Posts Administration Screen.
*
* @package WordPress
* @subpackage Administration
*/
/** WordPress Administration Bootstrap */
require_once __DIR__ . '/admin.php';
/**
* @global string $typenow The post type of the current screen.
*/
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 string $post_type Global post type.
* @global WP_Post_Type $post_type_object Global post type object.
*/
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(
'<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
'<p>' . __( 'Sorry, you are not allowed to edit posts in this post type.' ) . '</p>',
403
);
}
$wp_list_table = _get_list_table( 'WP_Posts_List_Table' );
$pagenum = $wp_list_table->get_pagenum();
// Back-compat for viewing comments of an entry.
foreach ( array( 'p', 'attachment_id', 'page_id' ) as $_redirect ) {
if ( ! empty( $_REQUEST[ $_redirect ] ) ) {
wp_redirect( admin_url( 'edit-comments.php?p=' . absint( $_REQUEST[ $_redirect ] ) ) );
exit;
}
}
unset( $_redirect );
if ( 'post' !== $post_type ) {
$parent_file = "edit.php?post_type=$post_type";
$submenu_file = "edit.php?post_type=$post_type";
$post_new_file = "post-new.php?post_type=$post_type";
} else {
$parent_file = 'edit.php';
$submenu_file = 'edit.php';
$post_new_file = 'post-new.php';
}
$doaction = $wp_list_table->current_action();
if ( $doaction ) {
check_admin_referer( 'bulk-posts' );
$sendback = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'locked', 'ids' ), wp_get_referer() );
if ( ! $sendback ) {
$sendback = admin_url( $parent_file );
}
$sendback = add_query_arg( 'paged', $pagenum, $sendback );
if ( str_contains( $sendback, 'post.php' ) ) {
$sendback = admin_url( $post_new_file );
}
$post_ids = array();
if ( 'delete_all' === $doaction ) {
// Prepare for deletion of all posts with a specified post status (i.e. Empty Trash).
$post_status = preg_replace( '/[^a-z0-9_-]+/i', '', $_REQUEST['post_status'] );
// Validate the post status exists.
if ( get_post_status_object( $post_status ) ) {
/**
* @global wpdb $wpdb WordPress database abstraction object.
*/
global $wpdb;
$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type=%s AND post_status = %s", $post_type, $post_status ) );
}
$doaction = 'delete';
} elseif ( isset( $_REQUEST['media'] ) ) {
$post_ids = $_REQUEST['media'];
} elseif ( isset( $_REQUEST['ids'] ) ) {
$post_ids = explode( ',', $_REQUEST['ids'] );
} elseif ( ! empty( $_REQUEST['post'] ) ) {
$post_ids = array_map( 'intval', $_REQUEST['post'] );
}
if ( empty( $post_ids ) ) {
wp_redirect( $sendback );
exit;
}
switch ( $doaction ) {
case 'trash':
$trashed = 0;
$locked = 0;
foreach ( (array) $post_ids as $post_id ) {
if ( ! current_user_can( 'delete_post', $post_id ) ) {
wp_die( __( 'Sorry, you are not allowed to move this item to the Trash.' ) );
}
if ( wp_check_post_lock( $post_id ) ) {
++$locked;
continue;
}
if ( ! wp_trash_post( $post_id ) ) {
wp_die( __( 'Error in moving the item to Trash.' ) );
}
++$trashed;
}
$sendback = add_query_arg(
array(
'trashed' => $trashed,
'ids' => implode( ',', $post_ids ),
'locked' => $locked,
),
$sendback
);
break;
case 'untrash':
$untrashed = 0;
if ( isset( $_GET['doaction'] ) && ( 'undo' === $_GET['doaction'] ) ) {
add_filter( 'wp_untrash_post_status', 'wp_untrash_post_set_previous_status'