Making WordPress.org


Ignore:
Timestamp:
07/03/2020 04:10:55 AM (6 years ago)
Author:
tellyworth
Message:

Block directory: initial UI improvements for block validator.

Props ryelle.
See #5303.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-block-validator.php

    r9993 r10003  
    77
    88        /**
    9          * Displays a form to validate block plugins.   
     9         * Displays a form to validate block plugins.
    1010         */
    1111        public static function display() {
     12                $plugin_url = $_REQUEST['plugin_url'] ?? '';
    1213                ?>
    1314                <div class="wrap">
    14 <?php
    15                 if ( $_POST && wp_verify_nonce( $_POST['block-nonce'], 'validate-block-plugin' ) ) {
    16 
    17                                 self::validate_block( $_POST['plugin_url'] );
    18                         }
    19 
    20                         $plugin_url      = $_REQUEST['plugin_url'] ?? '';
    21                         ?>
    22 
    2315                        <form method="post" action="">
    2416                                <p>
    25                                         <input type="text" name="plugin_url" size="70" placeholder="https://plugins.svn.wordpress.org/" value="<?php echo esc_url( $plugin_url ); ?>" />
     17                                        <label for="plugin_url"><?php _e( 'Plugin repo URL', 'wporg-plugins' ); ?></label>
     18                                </p>
     19                                <p>
     20                                        <input type="text" id="plugin_url" name="plugin_url" size="70" placeholder="https://plugins.svn.wordpress.org/" value="<?php echo esc_url( $plugin_url ); ?>" />
    2621                                        <input type="submit" class="button button-secondary" value="<?php esc_attr_e( 'Validate!', 'wporg-plugins' ); ?>" />
    2722                                        <?php wp_nonce_field( 'validate-block-plugin', 'block-nonce' ); ?>
     
    2924                        </form>
    3025
     26                        <?php
     27                        if ( $_POST && wp_verify_nonce( $_POST['block-nonce'], 'validate-block-plugin' ) ) {
     28                                self::validate_block( $_POST['plugin_url'] );
     29                        }
     30                        ?>
    3131                </div>
    3232                <?php
     
    3535        /**
    3636         * Validates readme.txt contents and adds feedback.
     37         *
     38         * @param string $plugin_url The URL of a Subversion or GitHub repository.
    3739         */
    3840        protected static function validate_block( $plugin_url ) {
     
    4143                $results = $checker->run_check_plugin_repo( $plugin_url );
    4244
     45                echo '<h2>' . __( 'Results', 'wporg-plugins' ) . '</h2>';
     46
    4347                if ( $checker->repo_url && $checker->repo_revision ) {
    44                         echo '<h2>Validating..</h2>';
    45                         echo '<p>Results for ' . esc_url( $checker->repo_url ) . ' revision ' . esc_html( $checker->repo_revision ) . '</p>';
     48                        echo '<p>';
     49                        printf(
     50                                'Results for %1$s revision %2$s',
     51                                '<code>' . esc_url( $checker->repo_url ) . '</code>',
     52                                esc_html( $checker->repo_revision )
     53                        );
     54                        echo '</p>';
    4655                }
    4756
     
    5059                        $results_by_type[ $item->type ][] = $item;
    5160                }
    52 
    5361
    5462                $output = '';
     
    6068                );
    6169                foreach ( $error_types as $type => $warning_label ) {
     70                        if ( empty( $results_by_type[ $type ] ) ) {
     71                                continue;
     72                        }
    6273
    63                                 if ( empty( $results_by_type[ $type ] ) )
    64                                         continue;
    65 
    66                                 $output .= "<h3>{$warning_label}</h3>\n";
    67                                 $output .= "<div class='notice notice-{$type} notice-alt'>\n";
    68                                 $output .= "<ul class='{$type}'>\n";
    69                                 foreach ( $results_by_type[ $type ] as $item ) {
    70                                         $output .= "<li title='{$item->check_name}'><a href='/hypothetical/doc/page#{$item->check_name}'><span class='dashicons dashicons-info'></span></a> {$item->message}</li>\n";
     74                        $output .= "<h3>{$warning_label}</h3>\n";
     75                        $output .= "<div class='notice notice-{$type} notice-alt'>\n";
     76                        $output .= "<ul class='{$type}'>\n";
     77                        foreach ( $results_by_type[ $type ] as $item ) {
     78                                $docs_link = '';
     79                                if ( 'check' === substr( $item->check_name, 0, 5 ) ) {
     80                                        $docs_link = "<a href='/hypothetical/doc/page#{$item->check_name}'>" . __( 'More about this.', 'wporg-plugins' ) . '</a>';
    7181                                }
    72                                 $output .= "</ul>\n";
    73                                 $output .= "</div>\n";
     82                                $output .= "<li class='{$item->check_name}'>{$item->message} {$docs_link}</li>\n";
     83                        }
     84                        $output .= "</ul>\n";
     85                        $output .= "</div>\n";
    7486                }
    7587
Note: See TracChangeset for help on using the changeset viewer.