Making WordPress.org

Ticket #5306: reviewer-ui.diff

File reviewer-ui.diff, 2.5 KB (added by ryelle, 3 years ago)
  • shortcodes/class-block-validator.php

     
    8888                        echo '</p>';
    8989                }
    9090
     91                $results_by_type = array();
     92                foreach ( $results as $item ) {
     93                        $results_by_type[ $item->type ][] = $item;
     94                }
     95
    9196                if ( $checker->slug ) {
    9297                        $plugin = Plugin_Directory::get_plugin_post( $checker->slug );
    9398                        if ( current_user_can( 'edit_post', $plugin->ID ) ) {
    9499                                echo '<form method="post">';
    95                                 echo '<fieldset>';
    96                                 echo '<legend>' . __( 'Plugin Review Tools', 'wporg-plugins' ) . '</legend>';
     100                                echo '<h3>' . __( 'Plugin Review Tools', 'wporg-plugins' ) . '</h3>';
    97101                                echo wp_nonce_field( 'block-directory-edit-' . $plugin->ID, 'block-directory-nonce' );
    98102                                echo '<input type="hidden" name="plugin-id" value="' . esc_attr( $plugin->ID ) . '" />';
    99                                 if ( self::plugin_is_in_block_directory( $checker->slug ) ) {
    100                                         echo '<button type="submit" name="block-directory-edit" value="remove">' . __( 'Remove from Block Directory', 'wporg-plugins' ) . '</button>';
     103                                echo '<p>';
     104                                if ( ! empty( $results_by_type['error'] ) ) {
     105                                        printf( __( "%s can't be added to the block directory, due to errors in validation.", 'wporg-plugins' ), $plugin->post_title );
     106                                } else if ( self::plugin_is_in_block_directory( $checker->slug ) ) {
     107                                        echo '<button type="submit" name="block-directory-edit" value="remove">' . sprintf( __( 'Remove %s from Block Directory', 'wporg-plugins' ), $plugin->post_title ) . '</button>';
    101108                                } else {
    102                                         echo '<button type="submit" name="block-directory-edit" value="add">' . __( 'Add to Block Directory', 'wporg-plugins' ) . '</button>';
     109                                        echo '<button type="submit" name="block-directory-edit" value="add">' . sprintf( __( 'Add %s to Block Directory', 'wporg-plugins' ), $plugin->post_title ) . '</button>';
    103110                                }
     111                                echo '</p>';
    104112       
    105113                                echo '<ul><li><a href="' . get_edit_post_link( $plugin->ID ) . '">' . __( 'Edit plugin', 'wporg-plugins' ) . '</a></li>';
    106114                                echo '<li><a href="' . esc_url( 'https://plugins.trac.wordpress.org/browser/' . $checker->slug . '/trunk' ) .'">' . __( 'Trac browser', 'wporg-plugins' ) . '</a></li></ul>';
    107                                 echo '</fieldset>';
    108115                                echo '</form>';
    109116                        }
    110117                }
    111118
    112                 $results_by_type = array();
    113                 foreach ( $results as $item ) {
    114                         $results_by_type[ $item->type ][] = $item;
    115                 }
    116 
    117119                $output = '';
    118120
    119121                if ( empty( $results_by_type['error'] ) ) {