mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 09:07:59 +01:00
Use the create_posts capability in more places.
In get_post_type_capabilities(), make sure create_posts reflects customizations to the edit_posts capability when create_posts is not specifically set. git-svn-id: http://core.svn.wordpress.org/trunk@22291 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a0e6687f56
commit
a550a6d489
@ -274,7 +274,11 @@ require_once('./admin-header.php');
|
||||
|
||||
<div class="wrap">
|
||||
<?php screen_icon(); ?>
|
||||
<h2><?php echo esc_html( $title ); ?><?php if ( isset( $post_new_file ) ) : ?> <a href="<?php echo esc_url( $post_new_file ) ?>" class="add-new-h2"><?php echo esc_html($post_type_object->labels->add_new); ?></a><?php endif; ?></h2>
|
||||
<h2><?php
|
||||
echo esc_html( $title );
|
||||
if ( isset( $post_new_file ) && current_user_can( $post_type_object->cap->create_posts ) )
|
||||
echo ' <a href="' . esc_url( $post_new_file ) . '" class="add-new-h2">' . esc_html( $post_type_object->labels->add_new ) . '</a>';
|
||||
?></h2>
|
||||
<?php if ( $notice ) : ?>
|
||||
<div id="notice" class="error"><p><?php echo $notice ?></p></div>
|
||||
<?php endif; ?>
|
||||
|
@ -221,10 +221,13 @@ require_once('./admin-header.php');
|
||||
?>
|
||||
<div class="wrap">
|
||||
<?php screen_icon(); ?>
|
||||
<h2><?php echo esc_html( $post_type_object->labels->name ); ?> <a href="<?php echo $post_new_file ?>" class="add-new-h2"><?php echo esc_html($post_type_object->labels->add_new); ?></a> <?php
|
||||
<h2><?php
|
||||
echo esc_html( $post_type_object->labels->name );
|
||||
if ( current_user_can( $post_type_object->cap->create_posts ) )
|
||||
echo ' <a href="' . esc_url( $post_new_file ) . '" class="add-new-h2">' . esc_html( $post_type_object->labels->add_new ) . '</a>';
|
||||
if ( ! empty( $_REQUEST['s'] ) )
|
||||
printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', get_search_query() ); ?>
|
||||
</h2>
|
||||
printf( ' <span class="subtitle">' . __('Search results for “%s”') . '</span>', get_search_query() );
|
||||
?></h2>
|
||||
|
||||
<?php if ( isset( $_REQUEST['locked'] ) || isset( $_REQUEST['updated'] ) || isset( $_REQUEST['deleted'] ) || isset( $_REQUEST['trashed'] ) || isset( $_REQUEST['untrashed'] ) ) {
|
||||
$messages = array();
|
||||
|
@ -76,7 +76,7 @@ if ( current_user_can( 'moderate_comments' ) )
|
||||
$help .= '<p>' . __('<strong>Recent Comments</strong> - Shows the most recent comments on your posts (configurable, up to 30) and allows you to moderate them.') . '</p>';
|
||||
if ( current_user_can( 'publish_posts' ) )
|
||||
$help .= '<p>' . __('<strong>Incoming Links</strong> - Shows links to your site found by Google Blog Search.') . '</p>';
|
||||
if ( current_user_can( 'edit_posts' ) ) {
|
||||
if ( current_user_can( 'create_posts' ) ) {
|
||||
$help .= '<p>' . __('<strong>QuickPress</strong> - Allows you to create a new post and either publish it or save it as a draft.') . '</p>';
|
||||
$help .= '<p>' . __('<strong>Recent Drafts</strong> - Displays links to the 5 most recent draft posts you’ve started.') . '</p>';
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ $title = $post_type_object->labels->add_new_item;
|
||||
|
||||
$editing = true;
|
||||
|
||||
if ( ! current_user_can( $post_type_object->cap->edit_posts ) )
|
||||
if ( ! current_user_can( $post_type_object->cap->edit_posts ) || ! current_user_can( $post_type_object->cap->create_posts ) )
|
||||
wp_die( __( 'Cheatin’ uh?' ) );
|
||||
|
||||
// Schedule auto-draft cleanup
|
||||
|
@ -13,7 +13,7 @@ require_once('./admin.php');
|
||||
|
||||
header('Content-Type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
|
||||
|
||||
if ( ! current_user_can('edit_posts') )
|
||||
if ( ! current_user_can( 'edit_posts' ) || ! current_user_can( 'create_posts' ) )
|
||||
wp_die( __( 'Cheatin’ uh?' ) );
|
||||
|
||||
/**
|
||||
|
@ -1411,8 +1411,6 @@ function get_post_type_capabilities( $args ) {
|
||||
'edit_others_posts' => 'edit_others_' . $plural_base,
|
||||
'publish_posts' => 'publish_' . $plural_base,
|
||||
'read_private_posts' => 'read_private_' . $plural_base,
|
||||
// Post creation capability simply maps to edit_posts by default:
|
||||
'create_posts' => 'edit_' . $plural_base,
|
||||
);
|
||||
|
||||
// Primitive capabilities used within map_meta_cap():
|
||||
@ -1431,6 +1429,10 @@ function get_post_type_capabilities( $args ) {
|
||||
|
||||
$capabilities = array_merge( $default_capabilities, $args->capabilities );
|
||||
|
||||
// Post creation capability simply maps to edit_posts by default:
|
||||
if ( ! isset( $capabilities['create_posts'] ) )
|
||||
$capabilities['create_posts'] = $capabilities['edit_posts'];
|
||||
|
||||
// Remember meta capabilities for future reference.
|
||||
if ( $args->map_meta_cap )
|
||||
_post_type_meta_capabilities( $capabilities );
|
||||
|
Loading…
Reference in New Issue
Block a user