Move post type object capabilities to a 'cap' object. Allow them to be initialized via the 'capabilities' key (an array) when registering support for the post type. Caps are now referred to by the name of the cap as if it was a post, i.e. ->cap->edit_post. see #13358.
git-svn-id: http://svn.automattic.com/wordpress/trunk@14585 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -142,7 +142,7 @@ if ( post_type_supports($post_type, 'comments') )
|
||||
if ( ('publish' == $post->post_status || 'private' == $post->post_status) && post_type_supports($post_type, 'comments') )
|
||||
add_meta_box('commentsdiv', __('Comments'), 'post_comment_meta_box', $post_type, 'normal', 'core');
|
||||
|
||||
if ( !( 'pending' == $post->post_status && !current_user_can( $post_type_object->publish_cap ) ) )
|
||||
if ( !( 'pending' == $post->post_status && !current_user_can( $post_type_object->cap->publish_posts ) ) )
|
||||
add_meta_box('slugdiv', __('Slug'), 'post_slug_meta_box', $post_type, 'normal', 'core');
|
||||
|
||||
if ( post_type_supports($post_type, 'author') ) {
|
||||
@@ -221,7 +221,7 @@ $shortlink = wp_get_shortlink($post->ID, 'post');
|
||||
if ( !empty($shortlink) )
|
||||
$sample_permalink_html .= '<input id="shortlink" type="hidden" value="' . esc_attr($shortlink) . '" /><a href="#" class="button" onclick="prompt('URL:', jQuery(\'#shortlink\').val()); return false;">' . __('Get Shortlink') . '</a>';
|
||||
|
||||
if ( !( 'pending' == $post->post_status && !current_user_can( $post_type_object->publish_cap ) ) ) { ?>
|
||||
if ( !( 'pending' == $post->post_status && !current_user_can( $post_type_object->cap->publish_posts ) ) ) { ?>
|
||||
<div id="edit-slug-box">
|
||||
<?php
|
||||
if ( ! empty($post->ID) && ! empty($sample_permalink_html) && 'auto-draft' != $post->post_status )
|
||||
|
||||
@@ -19,7 +19,7 @@ $_GET['post_type'] = $post_type;
|
||||
|
||||
$post_type_object = get_post_type_object($post_type);
|
||||
|
||||
if ( !current_user_can($post_type_object->edit_type_cap) )
|
||||
if ( !current_user_can($post_type_object->cap->edit_posts) )
|
||||
wp_die(__('Cheatin’ uh?'));
|
||||
|
||||
// Back-compat for viewing comments of an entry
|
||||
@@ -73,7 +73,7 @@ if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delet
|
||||
case 'trash':
|
||||
$trashed = 0;
|
||||
foreach( (array) $post_ids as $post_id ) {
|
||||
if ( !current_user_can($post_type_object->delete_cap, $post_id) )
|
||||
if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
|
||||
wp_die( __('You are not allowed to move this item to the Trash.') );
|
||||
|
||||
if ( !wp_trash_post($post_id) )
|
||||
@@ -86,7 +86,7 @@ if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delet
|
||||
case 'untrash':
|
||||
$untrashed = 0;
|
||||
foreach( (array) $post_ids as $post_id ) {
|
||||
if ( !current_user_can($post_type_object->delete_cap, $post_id) )
|
||||
if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
|
||||
wp_die( __('You are not allowed to restore this item from the Trash.') );
|
||||
|
||||
if ( !wp_untrash_post($post_id) )
|
||||
@@ -101,7 +101,7 @@ if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delet
|
||||
foreach( (array) $post_ids as $post_id ) {
|
||||
$post_del = & get_post($post_id);
|
||||
|
||||
if ( !current_user_can($post_type_object->delete_cap, $post_id) )
|
||||
if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
|
||||
wp_die( __('You are not allowed to delete this item.') );
|
||||
|
||||
if ( $post_del->post_type == 'attachment' ) {
|
||||
@@ -140,7 +140,7 @@ if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delet
|
||||
wp_enqueue_script('inline-edit-post');
|
||||
|
||||
$user_posts = false;
|
||||
if ( !current_user_can($post_type_object->edit_others_cap) ) {
|
||||
if ( !current_user_can($post_type_object->cap->edit_other_posts) ) {
|
||||
$user_posts_count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(1) FROM $wpdb->posts WHERE post_type = '%s' AND post_status NOT IN ('trash', 'auto-draft') AND post_author = %d", $post_type, $current_user->ID) );
|
||||
$user_posts = true;
|
||||
if ( $user_posts_count && empty($_GET['post_status']) && empty($_GET['all_posts']) && empty($_GET['author']) )
|
||||
@@ -345,7 +345,7 @@ do_action('restrict_manage_posts');
|
||||
<input type="submit" id="post-query-submit" value="<?php esc_attr_e('Filter'); ?>" class="button-secondary" />
|
||||
<?php }
|
||||
|
||||
if ( $is_trash && current_user_can($post_type_object->edit_others_cap) ) { ?>
|
||||
if ( $is_trash && current_user_can($post_type_object->cap->edit_other_posts) ) { ?>
|
||||
<input type="submit" name="delete_all" id="delete_all" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
|
||||
<?php } ?>
|
||||
</div>
|
||||
@@ -396,7 +396,7 @@ if ( $page_links )
|
||||
<?php } ?>
|
||||
</select>
|
||||
<input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
|
||||
<?php if ( $is_trash && current_user_can($post_type_object->edit_others_cap) ) { ?>
|
||||
<?php if ( $is_trash && current_user_can($post_type_object->cap->edit_other_posts) ) { ?>
|
||||
<input type="submit" name="delete_all2" id="delete_all2" value="<?php esc_attr_e('Empty Trash'); ?>" class="button-secondary apply" />
|
||||
<?php } ?>
|
||||
<br class="clear" />
|
||||
|
||||
@@ -14,7 +14,7 @@ function post_submit_meta_box($post) {
|
||||
|
||||
$post_type = $post->post_type;
|
||||
$post_type_object = get_post_type_object($post_type);
|
||||
$can_publish = current_user_can($post_type_object->publish_cap);
|
||||
$can_publish = current_user_can($post_type_object->cap->publish_posts);
|
||||
?>
|
||||
<div class="submitbox" id="submitpost">
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ function _wp_translate_postdata( $update = false, $post_data = null ) {
|
||||
|
||||
$ptype = get_post_type_object( $post_data['post_type'] );
|
||||
if ( isset($post_data['user_ID']) && ($post_data['post_author'] != $post_data['user_ID']) ) {
|
||||
if ( !current_user_can( $ptype->edit_others_cap ) ) {
|
||||
if ( !current_user_can( $ptype->cap->edit_other_posts ) ) {
|
||||
if ( 'page' == $post_data['post_type'] ) {
|
||||
return new WP_Error( 'edit_others_pages', $update ?
|
||||
__( 'You are not allowed to edit pages as this user.' ) :
|
||||
@@ -81,7 +81,7 @@ function _wp_translate_postdata( $update = false, $post_data = null ) {
|
||||
|
||||
// Posts 'submitted for approval' present are submitted to $_POST the same as if they were being published.
|
||||
// Change status from 'publish' to 'pending' if user lacks permissions to publish or to resave published posts.
|
||||
if ( isset($post_data['post_status']) && ('publish' == $post_data['post_status'] && !current_user_can( $ptype->publish_cap )) )
|
||||
if ( isset($post_data['post_status']) && ('publish' == $post_data['post_status'] && !current_user_can( $ptype->cap->publish_posts )) )
|
||||
if ( $previous_status != 'publish' || !current_user_can( 'edit_post', $post_id ) )
|
||||
$post_data['post_status'] = 'pending';
|
||||
|
||||
@@ -138,7 +138,7 @@ function edit_post( $post_data = null ) {
|
||||
$post_ID = (int) $post_data['post_ID'];
|
||||
|
||||
$ptype = get_post_type_object($post_data['post_type']);
|
||||
if ( !current_user_can( $ptype->edit_cap, $post_ID ) ) {
|
||||
if ( !current_user_can( $ptype->cap->edit_post, $post_ID ) ) {
|
||||
if ( 'page' == $post_data['post_type'] )
|
||||
wp_die( __('You are not allowed to edit this page.' ));
|
||||
else
|
||||
@@ -237,7 +237,7 @@ function bulk_edit_posts( $post_data = null ) {
|
||||
else
|
||||
$ptype = get_post_type_object('post');
|
||||
|
||||
if ( !current_user_can( $ptype->edit_type_cap ) ) {
|
||||
if ( !current_user_can( $ptype->cap->edit_posts ) ) {
|
||||
if ( 'page' == $ptype->name )
|
||||
wp_die( __('You are not allowed to edit pages.'));
|
||||
else
|
||||
@@ -494,7 +494,7 @@ function wp_write_post() {
|
||||
else
|
||||
$ptype = get_post_type_object('post');
|
||||
|
||||
if ( !current_user_can( $ptype->edit_type_cap ) ) {
|
||||
if ( !current_user_can( $ptype->cap->edit_posts ) ) {
|
||||
if ( 'page' == $ptype->name )
|
||||
return new WP_Error( 'edit_pages', __( 'You are not allowed to create pages on this site.' ) );
|
||||
else
|
||||
|
||||
@@ -876,7 +876,7 @@ function inline_edit_row( $screen ) {
|
||||
$hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($screen) ) );
|
||||
$col_count = count($columns) - count($hidden);
|
||||
$m = ( isset($mode) && 'excerpt' == $mode ) ? 'excerpt' : 'list';
|
||||
$can_publish = current_user_can($post_type_object->publish_cap);
|
||||
$can_publish = current_user_can($post_type_object->cap->publish_posts);
|
||||
$core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );
|
||||
|
||||
?>
|
||||
@@ -1111,7 +1111,7 @@ endif; // post_type_supports comments or pings ?>
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<?php if ( 'post' == $screen->post_type && $can_publish && current_user_can( $post_type_object->edit_others_cap ) ) : ?>
|
||||
<?php if ( 'post' == $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_other_posts ) ) : ?>
|
||||
|
||||
<?php if ( $bulk ) : ?>
|
||||
|
||||
@@ -1181,7 +1181,7 @@ endif; // post_type_supports comments or pings ?>
|
||||
*/
|
||||
function get_inline_data($post) {
|
||||
$post_type_object = get_post_type_object($post->post_type);
|
||||
if ( ! current_user_can($post_type_object->edit_cap, $post->ID) )
|
||||
if ( ! current_user_can($post_type_object->cap->edit_post, $post->ID) )
|
||||
return;
|
||||
|
||||
$title = esc_attr( get_the_title( $post->ID ) );
|
||||
@@ -1298,7 +1298,7 @@ function _post_row($a_post, $pending_comments, $mode) {
|
||||
|
||||
case 'cb':
|
||||
?>
|
||||
<th scope="row" class="check-column"><?php if ( current_user_can( $post_type_object->edit_cap, $post->ID ) ) { ?><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /><?php } ?></th>
|
||||
<th scope="row" class="check-column"><?php if ( current_user_can( $post_type_object->cap->edit_post, $post->ID ) ) { ?><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /><?php } ?></th>
|
||||
<?php
|
||||
break;
|
||||
|
||||
@@ -1341,17 +1341,17 @@ function _post_row($a_post, $pending_comments, $mode) {
|
||||
case 'title':
|
||||
$attributes = 'class="post-title column-title"' . $style;
|
||||
?>
|
||||
<td <?php echo $attributes ?>><strong><?php if ( current_user_can($post_type_object->edit_cap, $post->ID) && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $title)); ?>"><?php echo $title ?></a><?php } else { echo $title; }; _post_states($post); ?></strong>
|
||||
<td <?php echo $attributes ?>><strong><?php if ( current_user_can($post_type_object->cap->edit_post, $post->ID) && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $title)); ?>"><?php echo $title ?></a><?php } else { echo $title; }; _post_states($post); ?></strong>
|
||||
<?php
|
||||
if ( 'excerpt' == $mode )
|
||||
the_excerpt();
|
||||
|
||||
$actions = array();
|
||||
if ( current_user_can($post_type_object->edit_cap, $post->ID) && 'trash' != $post->post_status ) {
|
||||
if ( current_user_can($post_type_object->cap->edit_post, $post->ID) && 'trash' != $post->post_status ) {
|
||||
$actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this post')) . '">' . __('Edit') . '</a>';
|
||||
$actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr(__('Edit this post inline')) . '">' . __('Quick Edit') . '</a>';
|
||||
}
|
||||
if ( current_user_can($post_type_object->delete_cap, $post->ID) ) {
|
||||
if ( current_user_can($post_type_object->cap->delete_post, $post->ID) ) {
|
||||
if ( 'trash' == $post->post_status )
|
||||
$actions['untrash'] = "<a title='" . esc_attr(__('Restore this post from the Trash')) . "' href='" . wp_nonce_url( admin_url( sprintf($post_type_object->_edit_link . '&action=untrash', $post->ID) ), 'untrash-' . $post->post_type . '_' . $post->ID ) . "'>" . __('Restore') . "</a>";
|
||||
elseif ( EMPTY_TRASH_DAYS )
|
||||
@@ -1360,7 +1360,7 @@ function _post_row($a_post, $pending_comments, $mode) {
|
||||
$actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this post permanently')) . "' href='" . get_delete_post_link($post->ID, '', true) . "'>" . __('Delete Permanently') . "</a>";
|
||||
}
|
||||
if ( in_array($post->post_status, array('pending', 'draft')) ) {
|
||||
if ( current_user_can($post_type_object->edit_cap, $post->ID) )
|
||||
if ( current_user_can($post_type_object->cap->edit_post, $post->ID) )
|
||||
$actions['view'] = '<a href="' . add_query_arg( 'preview', 'true', get_permalink($post->ID) ) . '" title="' . esc_attr(sprintf(__('Preview “%s”'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
|
||||
} elseif ( 'trash' != $post->post_status ) {
|
||||
$actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>';
|
||||
@@ -1443,13 +1443,13 @@ function _post_row($a_post, $pending_comments, $mode) {
|
||||
|
||||
case 'control_edit':
|
||||
?>
|
||||
<td><?php if ( current_user_can($post_type_object->edit_cap, $post->ID) ) { echo "<a href='$edit_link' class='edit'>" . __('Edit') . "</a>"; } ?></td>
|
||||
<td><?php if ( current_user_can($post_type_object->cap->edit_post, $post->ID) ) { echo "<a href='$edit_link' class='edit'>" . __('Edit') . "</a>"; } ?></td>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'control_delete':
|
||||
?>
|
||||
<td><?php if ( current_user_can($post_type_object->delete_cap, $post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&post=$id", 'delete-post_' . $post->ID) . "' class='delete'>" . __('Delete') . "</a>"; } ?></td>
|
||||
<td><?php if ( current_user_can($post_type_object->cap->delete_post, $post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&post=$id", 'delete-post_' . $post->ID) . "' class='delete'>" . __('Delete') . "</a>"; } ?></td>
|
||||
<?php
|
||||
break;
|
||||
|
||||
@@ -1566,14 +1566,14 @@ foreach ( $posts_columns as $column_name => $column_display_name ) {
|
||||
$attributes = 'class="post-title page-title column-title"' . $style;
|
||||
$edit_link = get_edit_post_link( $page->ID );
|
||||
?>
|
||||
<td <?php echo $attributes ?>><strong><?php if ( current_user_can($post_type_object->edit_cap, $page->ID) && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $title)); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states($page); echo isset($parent_name) ? ' | ' . $post_type_object->labels->parent . ' ' . esc_html($parent_name) : ''; ?></strong>
|
||||
<td <?php echo $attributes ?>><strong><?php if ( current_user_can($post_type_object->cap->edit_post, $page->ID) && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $title)); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states($page); echo isset($parent_name) ? ' | ' . $post_type_object->labels->parent . ' ' . esc_html($parent_name) : ''; ?></strong>
|
||||
<?php
|
||||
$actions = array();
|
||||
if ( current_user_can($post_type_object->edit_cap, $page->ID) && $post->post_status != 'trash' ) {
|
||||
if ( current_user_can($post_type_object->cap->edit_post, $page->ID) && $post->post_status != 'trash' ) {
|
||||
$actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr(__('Edit this page')) . '">' . __('Edit') . '</a>';
|
||||
$actions['inline'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
|
||||
}
|
||||
if ( current_user_can($post_type_object->delete_cap, $page->ID) ) {
|
||||
if ( current_user_can($post_type_object->cap->delete_post, $page->ID) ) {
|
||||
if ( $post->post_status == 'trash' )
|
||||
$actions['untrash'] = "<a title='" . esc_attr(__('Remove this page from the Trash')) . "' href='" . wp_nonce_url("post.php?post_type=$post_type&action=untrash&post=$page->ID", 'untrash-' . $post->post_type . '_' . $page->ID) . "'>" . __('Restore') . "</a>";
|
||||
elseif ( EMPTY_TRASH_DAYS )
|
||||
@@ -1582,7 +1582,7 @@ foreach ( $posts_columns as $column_name => $column_display_name ) {
|
||||
$actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this page permanently')) . "' href='" . wp_nonce_url("post.php?post_type=$post_type&action=delete&post=$page->ID", 'delete-' . $post->post_type . '_' . $page->ID) . "'>" . __('Delete Permanently') . "</a>";
|
||||
}
|
||||
if ( in_array($post->post_status, array('pending', 'draft')) ) {
|
||||
if ( current_user_can($post_type_object->edit_cap, $page->ID) )
|
||||
if ( current_user_can($post_type_object->cap->edit_post, $page->ID) )
|
||||
$actions['view'] = '<a href="' . add_query_arg( 'preview', 'true', get_permalink($page->ID) ) . '" title="' . esc_attr(sprintf(__('Preview “%s”'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
|
||||
} elseif ( $post->post_status != 'trash' ) {
|
||||
$actions['view'] = '<a href="' . get_permalink($page->ID) . '" title="' . esc_attr(sprintf(__('View “%s”'), $title)) . '" rel="permalink">' . __('View') . '</a>';
|
||||
@@ -2010,7 +2010,7 @@ function _wp_comment_row( $comment_id, $mode, $comment_status, $checkbox = true,
|
||||
$post = get_post($comment->comment_post_ID);
|
||||
$the_comment_status = wp_get_comment_status($comment->comment_ID);
|
||||
$post_type_object = get_post_type_object($post->post_type);
|
||||
$user_can = current_user_can($post_type_object->edit_cap, $post->ID);
|
||||
$user_can = current_user_can($post_type_object->cap->edit_post, $post->ID);
|
||||
|
||||
$comment_url = esc_url(get_comment_link($comment->comment_ID));
|
||||
$author_url = get_comment_author_url();
|
||||
@@ -3328,10 +3328,10 @@ function favorite_actions( $screen = null ) {
|
||||
if ( isset($post_type_object) ) {
|
||||
switch ( $screen->id ) {
|
||||
case $post_type_object->name:
|
||||
$default_action = array('edit.php?post_type=' . $post_type_object->name => array($post_type_object->labels->edit_item, $post_type_object->edit_type_cap));
|
||||
$default_action = array('edit.php?post_type=' . $post_type_object->name => array($post_type_object->labels->edit_item, $post_type_object->cap->edit_posts));
|
||||
break;
|
||||
case "edit-{$post_type_object->name}":
|
||||
$default_action = array('post-new.php?post_type=' . $post_type_object->name => array($post_type_object->labels->new_item, $post_type_object->edit_type_cap));
|
||||
$default_action = array('post-new.php?post_type=' . $post_type_object->name => array($post_type_object->labels->new_item, $post_type_object->cap->edit_posts));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,8 +249,8 @@ function get_editable_user_ids( $user_id, $exclude_zeros = true, $post_type = 'p
|
||||
$user = new WP_User( $user_id );
|
||||
$post_type_obj = get_post_type_object($post_type);
|
||||
|
||||
if ( ! $user->has_cap($post_type_obj->edit_others_cap) ) {
|
||||
if ( $user->has_cap($post_type_obj->edit_type_cap) || ! $exclude_zeros )
|
||||
if ( ! $user->has_cap($post_type_obj->cap->edit_other_posts) ) {
|
||||
if ( $user->has_cap($post_type_obj->cap->edit_posts) || ! $exclude_zeros )
|
||||
return array($user->id);
|
||||
else
|
||||
return array();
|
||||
|
||||
@@ -129,9 +129,9 @@ foreach ( (array) get_post_types( array('show_ui' => true) ) as $ptype ) {
|
||||
while ( isset($menu[$ptype_menu_position]) || in_array($ptype_menu_position, $core_menu_positions) )
|
||||
$ptype_menu_position++;
|
||||
|
||||
$menu[$ptype_menu_position] = array( esc_attr( $ptype_obj->labels->name ), $ptype_obj->edit_type_cap, "edit.php?post_type=$ptype", '', 'menu-top menu-icon-' . $ptype_class, 'menu-' . $ptype_class, $menu_icon );
|
||||
$submenu["edit.php?post_type=$ptype"][5] = array( $ptype_obj->labels->edit, $ptype_obj->edit_type_cap, "edit.php?post_type=$ptype");
|
||||
$submenu["edit.php?post_type=$ptype"][10] = array( $ptype_obj->labels->add_new, $ptype_obj->edit_type_cap, "post-new.php?post_type=$ptype" );
|
||||
$menu[$ptype_menu_position] = array( esc_attr( $ptype_obj->labels->name ), $ptype_obj->cap->edit_posts, "edit.php?post_type=$ptype", '', 'menu-top menu-icon-' . $ptype_class, 'menu-' . $ptype_class, $menu_icon );
|
||||
$submenu["edit.php?post_type=$ptype"][5] = array( $ptype_obj->labels->edit, $ptype_obj->cap->edit_posts, "edit.php?post_type=$ptype");
|
||||
$submenu["edit.php?post_type=$ptype"][10] = array( $ptype_obj->labels->add_new, $ptype_obj->cap->edit_posts, "post-new.php?post_type=$ptype" );
|
||||
|
||||
$i = 15;
|
||||
foreach ( $wp_taxonomies as $tax ) {
|
||||
|
||||
@@ -46,7 +46,7 @@ When you’re promoted, just reload this page and you’ll be able to bl
|
||||
wp_enqueue_script('autosave');
|
||||
|
||||
// Show post form.
|
||||
if ( current_user_can($post_type_object->edit_type_cap) ) {
|
||||
if ( current_user_can($post_type_object->cap->edit_posts) ) {
|
||||
$post = get_default_post_to_edit( $post_type, true );
|
||||
$post_ID = $post->ID;
|
||||
include('edit-form-advanced.php');
|
||||
|
||||
@@ -152,7 +152,7 @@ case 'edit':
|
||||
if ( empty($post->ID) )
|
||||
wp_die( __('You attempted to edit an item that doesn’t exist. Perhaps it was deleted?') );
|
||||
|
||||
if ( !current_user_can($post_type_object->edit_cap, $post_id) )
|
||||
if ( !current_user_can($post_type_object->cap->edit_post, $post_id) )
|
||||
wp_die( __('You are not allowed to edit this item.') );
|
||||
|
||||
if ( 'trash' == $post->post_status )
|
||||
@@ -217,7 +217,7 @@ case 'trash':
|
||||
|
||||
$post = & get_post($post_id);
|
||||
|
||||
if ( !current_user_can($post_type_object->delete_cap, $post_id) )
|
||||
if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
|
||||
wp_die( __('You are not allowed to move this item to the Trash.') );
|
||||
|
||||
if ( ! wp_trash_post($post_id) )
|
||||
@@ -230,7 +230,7 @@ case 'trash':
|
||||
case 'untrash':
|
||||
check_admin_referer('untrash-' . $post_type . '_' . $post_id);
|
||||
|
||||
if ( !current_user_can($post_type_object->delete_cap, $post_id) )
|
||||
if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
|
||||
wp_die( __('You are not allowed to move this item out of the Trash.') );
|
||||
|
||||
if ( ! wp_untrash_post($post_id) )
|
||||
@@ -243,7 +243,7 @@ case 'untrash':
|
||||
case 'delete':
|
||||
check_admin_referer('delete-' . $post_type . '_' . $post_id);
|
||||
|
||||
if ( !current_user_can($post_type_object->delete_cap, $post_id) )
|
||||
if ( !current_user_can($post_type_object->cap->delete_post, $post_id) )
|
||||
wp_die( __('You are not allowed to delete this item.') );
|
||||
|
||||
$force = !EMPTY_TRASH_DAYS;
|
||||
|
||||
Reference in New Issue
Block a user