Skip to content

Commit 4c2eb62

Browse files
committed
Plugin Directory: Allow Featured/Beta plugin owners to manage the committers and allow all committers to toggle public preview.
This relaxes a security change introduced with #5654, so adding/removing committers of these plugins now also triggers the plugins team to be CC'd for review. Closes WordPress#561. Fixes #8206. git-svn-id: https://meta.svn.wordpress.org/sites/trunk@14718 74240141-8908-4e6f-9713-ba540dce6ec7
1 parent e2b170e commit 4c2eb62

3 files changed

Lines changed: 59 additions & 19 deletions

File tree

wordpress.org/public_html/wp-content/plugins/plugin-directory/class-capabilities.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,18 @@ public static function map_meta_cap( $required_caps, $cap, $user_id, $context )
9090
}
9191

9292
// If a plugin is in the Beta or Featured views, they're not able to self-manage certain things. Require reviewer.
93+
$is_beta = is_object_in_term( $post->ID, 'plugin_section', 'beta' );
94+
$is_featured = is_object_in_term( $post->ID, 'plugin_section', 'featured' );
95+
9396
if (
97+
( $is_beta || $is_featured ) &&
9498
in_array(
9599
$cap,
96100
array(
97101
'plugin_self_close',
98102
'plugin_self_transfer',
99-
'plugin_toggle_public_preview',
100-
'plugin_add_committer',
101-
'plugin_remove_committer',
102103
)
103-
) &&
104-
is_object_in_term( $post->ID, 'plugin_section', array( 'beta', 'featured' ) )
104+
)
105105
) {
106106
$required_caps[] = 'plugin_review';
107107
}
@@ -111,6 +111,15 @@ public static function map_meta_cap( $required_caps, $cap, $user_id, $context )
111111
$required_caps[] = 'do_not_allow';
112112
}
113113

114+
// For featured/beta plugins, only the owner can manage committers.
115+
if (
116+
( $is_featured || $is_beta ) &&
117+
$user_id != $post->post_author &&
118+
in_array( $cap, array( 'plugin_add_committer', 'plugin_remove_committer' ) )
119+
) {
120+
$required_caps[] = 'plugin_review';
121+
}
122+
114123
// Committers
115124
$committers = Tools::get_plugin_committers( $post->post_name );
116125
// If there are no committers, use the plugin author if the plugin is published.

wordpress.org/public_html/wp-content/plugins/plugin-directory/email/class-committer-added.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@
66
class Committer_Added extends Base {
77
protected $required_args = [ 'committer' ];
88

9+
public function __construct( $plugin, $users = [], $args = [] ) {
10+
parent::__construct( $plugin, $users, $args );
11+
12+
// Notify the plugins team of committer changes on featured plugins as a safety-net.
13+
if ( $this->plugin && is_object_in_term( $this->plugin->ID, 'plugin_section', array( 'featured', 'beta' ) ) ) {
14+
$plugins_team = get_user_by( 'email', PLUGIN_TEAM_EMAIL );
15+
if ( $plugins_team ) {
16+
$this->users[] = $plugins_team;
17+
}
18+
}
19+
}
20+
921
function subject() {
1022
return sprintf(
1123
/* translators: 1: Plugin Name */

wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/inc/template-tags.php

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -265,26 +265,45 @@ function the_unconfirmed_releases_notice() {
265265
function the_no_self_management_notice() {
266266
$post = get_post();
267267

268-
// Check if they can access plugin management, but can't add committers.
269-
// This means the plugin has limited self-management functionalities, for security.
268+
$is_beta = is_object_in_term( $post->ID, 'plugin_section', 'beta' );
269+
$is_featured = is_object_in_term( $post->ID, 'plugin_section', 'featured' );
270+
271+
// Check if the plugin is in a section with limited self-management, and the user can manage it.
270272
if (
271-
(
272-
current_user_can( 'plugin_admin_edit', $post ) &&
273-
! current_user_can( 'plugin_add_committer', $post )
274-
) || (
275-
// Show the notice to plugin reviewers when it's limited. See class-capabilities.php.
276-
is_object_in_term( $post->ID, 'plugin_section', array( 'beta', 'featured' ) ) &&
273+
! ( $is_beta || $is_featured ) ||
274+
! (
275+
current_user_can( 'plugin_admin_edit', $post ) ||
277276
current_user_can( 'plugin_review' )
278277
)
279278
) {
280-
printf(
281-
'<div class="plugin-notice notice notice-warning notice-alt"><p>%s</p></div>',
282-
sprintf(
283-
__( 'Management of this plugin has been limited for security reasons. Please contact the <a href="mailto:%1$s">plugins team (%1$s)</a> for assistance to add/remove committers, or to perform other actions that are unavailable.', 'wporg-plugins' ),
284-
'plugins@wordpress.org'
285-
)
279+
return;
280+
}
281+
282+
$section = $is_beta ? __( 'Beta', 'wporg-plugins' ) : __( 'Featured', 'wporg-plugins' );
283+
$is_owner = get_current_user_id() == $post->post_author;
284+
285+
if ( $is_owner ) {
286+
$message = sprintf(
287+
/* translators: 1: section name (Beta/Featured), 2: plugins team email address */
288+
__( 'This plugin is listed in the %1$s section. Some management features have been limited for security reasons. Please contact the <a href="mailto:%2$s">plugins team (%2$s)</a> for assistance with closing or transferring this plugin.', 'wporg-plugins' ),
289+
$section,
290+
'plugins@wordpress.org'
291+
);
292+
} else {
293+
$owner = get_user_by( 'ID', $post->post_author );
294+
$message = sprintf(
295+
/* translators: 1: section name (Beta/Featured), 2: plugin owner display name, 3: plugins team email address */
296+
__( 'This plugin is listed in the %1$s section. Some management features have been limited for security reasons. Only the plugin owner (%2$s) can manage committers. Please contact the <a href="mailto:%3$s">plugins team (%3$s)</a> for assistance with closing or transferring this plugin.', 'wporg-plugins' ),
297+
$section,
298+
esc_html( $owner->display_name ),
299+
'plugins@wordpress.org'
286300
);
287301
}
302+
303+
printf(
304+
'<div class="plugin-notice notice notice-warning notice-alt"><p>%s</p></div>',
305+
$message
306+
);
288307
}
289308

290309
/**

0 commit comments

Comments
 (0)