diff --git a/src/wp-includes/capabilities.php b/src/wp-includes/capabilities.php
index 0c40c7e384..09a133b88f 100644
a
|
b
|
function map_meta_cap( $cap, $user_id, ...$args ) { |
381 | 381 | } |
382 | 382 | |
383 | 383 | $post = get_post( $comment->comment_post_ID ); |
| 384 | $author = $comment->user_id; |
384 | 385 | |
| 386 | if ( ! (int) $author === 0 ) { |
| 387 | $caps[] = 'do_not_allow'; |
| 388 | break; |
| 389 | } |
385 | 390 | /* |
386 | 391 | * If the post doesn't exist, we have an orphaned comment. |
387 | 392 | * Fall back to the edit_posts capability, instead. |
… |
… |
function map_meta_cap( $cap, $user_id, ...$args ) { |
391 | 396 | } else { |
392 | 397 | $caps = map_meta_cap( 'edit_posts', $user_id ); |
393 | 398 | } |
| 399 | if ( (int) $author === $user_id ) { |
| 400 | $caps = [$cap]; |
| 401 | } |
394 | 402 | break; |
395 | 403 | case 'unfiltered_upload': |
396 | 404 | if ( defined( 'ALLOW_UNFILTERED_UPLOADS' ) && ALLOW_UNFILTERED_UPLOADS && ( ! is_multisite() || is_super_admin( $user_id ) ) ) { |
… |
… |
function wp_maybe_grant_site_health_caps( $allcaps, $caps, $args, $user ) { |
1047 | 1055 | return $allcaps; |
1048 | 1056 | } |
1049 | 1057 | |
| 1058 | /** |
| 1059 | * Filters the user capabilities to grant the 'edit_comment' capability as necessary. |
| 1060 | * |
| 1061 | * @since 5.4 |
| 1062 | * |
| 1063 | * @param bool[] $allcaps An array of all the user's capabilities. |
| 1064 | * @param string[] $caps Required primitive capabilities for the requested capability. |
| 1065 | * @param array $args { |
| 1066 | * Arguments that accompany the requested capability check. |
| 1067 | * |
| 1068 | * @type string $0 Requested capability. |
| 1069 | * @type int $1 Concerned user ID. |
| 1070 | * @type mixed ...$2 Optional second and further parameters, typically object ID. |
| 1071 | * } |
| 1072 | * @param WP_User $user The user object. |
| 1073 | * @return bool[] Filtered array of the user's capabilities. |
| 1074 | */ |
| 1075 | function wp_maybe_grant_edit_comment($allcaps, $caps, $args, $user ) { |
| 1076 | if( in_array('edit_comment', $caps) ) { |
| 1077 | $allcaps['edit_comment'] = true; |
| 1078 | } |
| 1079 | |
| 1080 | return $allcaps; |
| 1081 | } |
| 1082 | |
1050 | 1083 | return; |
1051 | 1084 | |
1052 | 1085 | // Dummy gettext calls to get strings in the catalog. |
diff --git a/src/wp-includes/default-filters.php b/src/wp-includes/default-filters.php
index 26cdfeba20..662bab6ac4 100644
a
|
b
|
add_filter( 'pre_oembed_result', 'wp_filter_pre_oembed_result', 10, 3 ); |
582 | 582 | add_filter( 'user_has_cap', 'wp_maybe_grant_install_languages_cap', 1 ); |
583 | 583 | add_filter( 'user_has_cap', 'wp_maybe_grant_resume_extensions_caps', 1 ); |
584 | 584 | add_filter( 'user_has_cap', 'wp_maybe_grant_site_health_caps', 1, 4 ); |
| 585 | add_filter( 'user_has_cap', 'wp_maybe_grant_edit_comment', 1, 5); |
585 | 586 | |
586 | 587 | unset( $filter, $action ); |