Changeset 10051
- Timestamp:
- 07/10/2020 03:49:36 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-block-validator.php
r10049 r10051 4 4 use WordPressdotorg\Plugin_Directory\CLI\Block_Plugin_Checker; 5 5 use WordPressdotorg\Plugin_Directory\Plugin_Directory; 6 use WordPressdotorg\Plugin_Directory\Tools; 6 7 7 8 class Block_Validator { … … 33 34 $post = get_post( intval( $_POST['plugin-id'] ) ); 34 35 if ( $post && wp_verify_nonce( $_POST['block-directory-nonce'], 'block-directory-edit-' . $post->ID ) ) { 35 if ( current_user_can( 'edit_post', $post->ID ) ) {36 if ( current_user_can( 'edit_post', $post->ID ) || current_user_can( 'plugin_admin_edit', $post->ID ) ) { 36 37 $terms = wp_list_pluck( get_the_terms( $post->ID, 'plugin_section' ), 'slug' ); 37 38 if ( 'add' === $_POST['block-directory-edit'] ) { … … 101 102 $plugin = Plugin_Directory::get_plugin_post( $checker->slug ); 102 103 if ( current_user_can( 'edit_post', $plugin->ID ) ) { 104 // Plugin reviewers etc 103 105 echo '<form method="post">'; 104 106 echo '<h3>' . __( 'Plugin Review Tools', 'wporg-plugins' ) . '</h3>'; … … 121 123 echo '<li><a href="' . esc_url( 'https://plugins.trac.wordpress.org/browser/' . $checker->slug . '/trunk' ) . '">' . __( 'Trac browser', 'wporg-plugins' ) . '</a></li></ul>'; 122 124 echo '</form>'; 125 } elseif ( current_user_can( 'plugin_admin_edit', $plugin->ID ) ) { 126 // Plugin committers 127 echo '<form method="post">'; 128 echo '<h3>' . __( 'Committer Tools', 'wporg-plugins' ) . '</h3>'; 129 echo wp_nonce_field( 'block-directory-edit-' . $plugin->ID, 'block-directory-nonce' ); 130 echo '<input type="hidden" name="plugin-id" value="' . esc_attr( $plugin->ID ) . '" />'; 131 echo '<p>'; 132 if ( ! empty( $results_by_type['error'] ) ) { 133 // translators: %s plugin title. 134 printf( __( "%s can't be added to the block directory, due to errors in validation.", 'wporg-plugins' ), $plugin->post_title ); 135 } else if ( self::plugin_is_in_block_directory( $checker->slug ) ) { 136 // translators: %s plugin title. 137 echo '<button type="submit" name="block-directory-edit" value="remove">' . sprintf( __( 'Remove %s from Block Directory', 'wporg-plugins' ), $plugin->post_title ) . '</button>'; 138 } else { 139 // translators: %s plugin title. 140 echo '<button type="submit" name="block-directory-edit" value="add">' . sprintf( __( 'Add %s to Block Directory', 'wporg-plugins' ), $plugin->post_title ) . '</button>'; 141 } 142 echo '</p>'; 143 123 144 } 124 145 }
Note: See TracChangeset
for help on using the changeset viewer.