31
31
if ( $update && ! current_user_can( 'edit_post', $post_data['ID'] ) ) {
32
32
if ( 'page' == $post_data['post_type'] )
33
return new WP_Error( 'edit_others_pages', __( 'You are not allowed to edit pages as this user.' ) );
33
return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to edit pages as this user.' ) );
35
return new WP_Error( 'edit_others_posts', __( 'You are not allowed to edit posts as this user.' ) );
35
return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to edit posts as this user.' ) );
36
36
} elseif ( ! $update && ! current_user_can( $ptype->cap->create_posts ) ) {
37
37
if ( 'page' == $post_data['post_type'] )
38
return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) );
38
return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to create pages as this user.' ) );
40
return new WP_Error( 'edit_others_posts', __( 'You are not allowed to create posts as this user.' ) );
40
return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to create posts as this user.' ) );
43
43
if ( isset( $post_data['content'] ) )
68
68
&& ! current_user_can( $ptype->cap->edit_others_posts ) ) {
70
70
if ( 'page' == $post_data['post_type'] )
71
return new WP_Error( 'edit_others_pages', __( 'You are not allowed to edit pages as this user.' ) );
71
return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to edit pages as this user.' ) );
73
return new WP_Error( 'edit_others_posts', __( 'You are not allowed to edit posts as this user.' ) );
73
return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to edit posts as this user.' ) );
75
75
if ( 'page' == $post_data['post_type'] )
76
return new WP_Error( 'edit_others_pages', __( 'You are not allowed to create pages as this user.' ) );
76
return new WP_Error( 'edit_others_pages', __( 'Sorry, you are not allowed to create pages as this user.' ) );
78
return new WP_Error( 'edit_others_posts', __( 'You are not allowed to create posts as this user.' ) );
78
return new WP_Error( 'edit_others_posts', __( 'Sorry, you are not allowed to create posts as this user.' ) );
210
210
$ptype = get_post_type_object($post_data['post_type']);
211
211
if ( !current_user_can( 'edit_post', $post_ID ) ) {
212
212
if ( 'page' == $post_data['post_type'] )
213
wp_die( __('You are not allowed to edit this page.' ));
213
wp_die( __('Sorry, you are not allowed to edit this page.' ));
215
wp_die( __('You are not allowed to edit this post.' ));
215
wp_die( __('Sorry, you are not allowed to edit this post.' ));
218
218
if ( post_type_supports( $ptype->name, 'revisions' ) ) {
429
429
if ( !current_user_can( $ptype->cap->edit_posts ) ) {
430
430
if ( 'page' == $ptype->name )
431
wp_die( __('You are not allowed to edit pages.'));
431
wp_die( __('Sorry, you are not allowed to edit pages.'));
433
wp_die( __('You are not allowed to edit posts.'));
433
wp_die( __('Sorry, you are not allowed to edit posts.'));
436
436
if ( -1 == $post_data['_status'] ) {
639
639
$post->post_content = apply_filters( 'default_content', $post_content, $post );
642
* Filter the default post title initially used in the "Write Post" form.
642
* Filters the default post title initially used in the "Write Post" form.
649
649
$post->post_title = apply_filters( 'default_title', $post_title, $post );
652
* Filter the default post excerpt initially used in the "Write Post" form.
652
* Filters the default post excerpt initially used in the "Write Post" form.
722
722
if ( !current_user_can( $ptype->cap->edit_posts ) ) {
723
723
if ( 'page' == $ptype->name )
724
return new WP_Error( 'edit_pages', __( 'You are not allowed to create pages on this site.' ) );
724
return new WP_Error( 'edit_pages', __( 'Sorry, you are not allowed to create pages on this site.' ) );
726
return new WP_Error( 'edit_posts', __( 'You are not allowed to create posts or drafts on this site.' ) );
726
return new WP_Error( 'edit_posts', __( 'Sorry, you are not allowed to create posts or drafts on this site.' ) );
729
729
$_POST['post_mime_type'] = '';
1029
1029
$posts_per_page = 20;
1032
* Filter the number of items per page to show for a specific 'per_page' type.
1032
* Filters the number of items per page to show for a specific 'per_page' type.
1034
1034
* The dynamic portion of the hook name, `$post_type`, refers to the post type.
1191
* Filter the postbox classes for a specific screen and screen ID combo.
1191
* Filters the postbox classes for a specific screen and screen ID combo.
1193
1193
* The dynamic portions of the hook name, `$page` and `$id`, refer to
1194
1194
* the screen and screen ID, respectively.
1329
1329
$return .= '<span id="change-permalinks"><a href="options-permalink.php" class="button button-small" target="_blank">' . __('Change Permalinks') . "</a></span>\n";
1332
if ( function_exists( 'mb_strlen' ) ) {
1333
if ( mb_strlen( $post_name ) > 34 ) {
1334
$post_name_abridged = mb_substr( $post_name, 0, 16 ) . '…' . mb_substr( $post_name, -16 );
1336
$post_name_abridged = $post_name;
1332
if ( mb_strlen( $post_name ) > 34 ) {
1333
$post_name_abridged = mb_substr( $post_name, 0, 16 ) . '…' . mb_substr( $post_name, -16 );
1339
if ( strlen( $post_name ) > 34 ) {
1340
$post_name_abridged = substr( $post_name, 0, 16 ) . '…' . substr( $post_name, -16 );
1342
$post_name_abridged = $post_name;
1335
$post_name_abridged = $post_name;
1346
1338
$post_name_html = '<span id="editable-post-name">' . esc_html( $post_name_abridged ) . '</span>';
1383
1374
* @return string html
1385
1376
function _wp_post_thumbnail_html( $thumbnail_id = null, $post = null ) {
1386
global $content_width, $_wp_additional_image_sizes;
1377
global $_wp_additional_image_sizes;
1388
1379
$post = get_post( $post );
1389
1380
$post_type_object = get_post_type_object( $post->post_type );
1400
1391
$size = isset( $_wp_additional_image_sizes['post-thumbnail'] ) ? 'post-thumbnail' : array( 266, 266 );
1403
* Filter the size used to display the post thumbnail image in the 'Featured Image' meta box.
1394
* Filters the size used to display the post thumbnail image in the 'Featured Image' meta box.
1405
1396
* Note: When a theme adds 'post-thumbnail' support, a special 'post-thumbnail'
1406
1397
* image size is registered, which differs from the 'thumbnail' image size
1421
1412
$thumbnail_html = wp_get_attachment_image( $thumbnail_id, $size );
1423
if ( !empty( $thumbnail_html ) ) {
1424
$ajax_nonce = wp_create_nonce( 'set_post_thumbnail-' . $post->ID );
1414
if ( ! empty( $thumbnail_html ) ) {
1425
1415
$content = sprintf( $set_thumbnail_link,
1426
1416
esc_url( $upload_iframe_src ),
1427
1417
' aria-describedby="set-post-thumbnail-desc"',
1428
1418
$thumbnail_html
1430
1420
$content .= '<p class="hide-if-no-js howto" id="set-post-thumbnail-desc">' . __( 'Click the image to edit or update' ) . '</p>';
1431
$content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail" onclick="WPRemoveThumbnail(\'' . $ajax_nonce . '\');return false;">' . esc_html( $post_type_object->labels->remove_featured_image ) . '</a></p>';
1421
$content .= '<p class="hide-if-no-js"><a href="#" id="remove-post-thumbnail">' . esc_html( $post_type_object->labels->remove_featured_image ) . '</a></p>';
1425
$content .= '<input type="hidden" id="_thumbnail_id" name="_thumbnail_id" value="' . esc_attr( $thumbnail_id ? $thumbnail_id : '-1' ) . '" />';
1436
* Filter the admin post thumbnail HTML markup to return.
1428
* Filters the admin post thumbnail HTML markup to return.
1431
* @since 3.5.0 Added the `$post_id` parameter.
1432
* @since 4.6.0 Added the `$thumbnail_id` parameter.
1440
* @param string $content Admin post thumbnail HTML markup.
1441
* @param int $post_id Post ID.
1434
* @param string $content Admin post thumbnail HTML markup.
1435
* @param int $post_id Post ID.
1436
* @param int $thumbnail_id Thumbnail ID.
1443
return apply_filters( 'admin_post_thumbnail_html', $content, $post->ID );
1438
return apply_filters( 'admin_post_thumbnail_html', $content, $post->ID, $thumbnail_id );
1561
1556
$preview_link = get_preview_post_link( $post->ID, $query_args );
1564
* Filter whether to allow the post lock to be overridden.
1559
* Filters whether to allow the post lock to be overridden.
1566
1561
* Returning a falsey value to the filter will disable the ability
1567
1562
* to override the post lock.
1721
1716
$_POST['ID'] = $post_ID;
1723
1718
if ( ! $post = get_post( $post_ID ) ) {
1724
wp_die( __( 'You are not allowed to edit this post.' ) );
1719
wp_die( __( 'Sorry, you are not allowed to edit this post.' ) );
1727
1722
if ( ! current_user_can( 'edit_post', $post->ID ) ) {
1728
wp_die( __( 'You are not allowed to edit this post.' ) );
1723
wp_die( __( 'Sorry, you are not allowed to edit this post.' ) );
1731
1726
$is_autosave = false;
1750
1745
$query_args['preview_id'] = $post->ID;
1751
1746
$query_args['preview_nonce'] = wp_create_nonce( 'post_preview_' . $post->ID );
1753
if ( isset( $_POST['post_format'] ) )
1748
if ( isset( $_POST['post_format'] ) ) {
1754
1749
$query_args['post_format'] = empty( $_POST['post_format'] ) ? 'standard' : sanitize_key( $_POST['post_format'] );
1752
if ( isset( $_POST['_thumbnail_id'] ) ) {
1753
$query_args['_thumbnail_id'] = ( intval( $_POST['_thumbnail_id'] ) <= 0 ) ? '-1' : intval( $_POST['_thumbnail_id'] );
1757
1757
return get_preview_post_link( $post, $query_args );
1783
1783
$post = get_post( $post_id );
1785
1785
if ( ! current_user_can( 'edit_post', $post->ID ) ) {
1786
return new WP_Error( 'edit_posts', __( 'You are not allowed to edit this item.' ) );
1786
return new WP_Error( 'edit_posts', __( 'Sorry, you are not allowed to edit this item.' ) );
1789
1789
if ( 'auto-draft' == $post->post_status )