Skip to content
This repository was archived by the owner on Dec 27, 2022. It is now read-only.

Commit d6885ff

Browse files
committed
Only user with customize_publish cap can publish snapshot
1 parent 856d135 commit d6885ff

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

php/class-customize-snapshot-manager.php

+4
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,10 @@ public function handle_update_snapshot_request() {
10791079
status_header( 400 );
10801080
wp_send_json_error( 'bad_status' );
10811081
}
1082+
if ( 'future' === $status && ! current_user_can( 'customize_publish' ) ) {
1083+
status_header( 400 );
1084+
wp_send_json_error( 'customize_not_allowed' );
1085+
}
10821086
$publish_date = isset( $_POST['publish_date'] ) ? $_POST['publish_date'] : '';
10831087
if ( 'future' === $status ) {
10841088
$publish_date_obj = new \DateTime( $publish_date );

php/class-post-type.php

+4
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,10 @@ public function filter_user_has_cap( $allcaps, $caps ) {
585585
$allcaps[ $granted_cap ] = current_user_can( 'customize' );
586586
}
587587

588+
if ( ! current_user_can( 'customize_publish' ) || empty( $allcaps['customize_publish'] ) ) {
589+
$allcaps[ $post_type_obj->cap->publish_posts ] = false;
590+
}
591+
588592
if ( ! current_user_can( 'edit_others_posts' ) ) {
589593
$allcaps[ $post_type_obj->cap->edit_others_posts ] = false;
590594
}

0 commit comments

Comments
 (0)