Changeset 10003 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/shortcodes/class-block-validator.php
- Timestamp:
- 07/03/2020 04:10:55 AM (6 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
r9993 r10003 7 7 8 8 /** 9 * Displays a form to validate block plugins. 9 * Displays a form to validate block plugins. 10 10 */ 11 11 public static function display() { 12 $plugin_url = $_REQUEST['plugin_url'] ?? ''; 12 13 ?> 13 14 <div class="wrap"> 14 <?php15 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 23 15 <form method="post" action=""> 24 16 <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 ); ?>" /> 26 21 <input type="submit" class="button button-secondary" value="<?php esc_attr_e( 'Validate!', 'wporg-plugins' ); ?>" /> 27 22 <?php wp_nonce_field( 'validate-block-plugin', 'block-nonce' ); ?> … … 29 24 </form> 30 25 26 <?php 27 if ( $_POST && wp_verify_nonce( $_POST['block-nonce'], 'validate-block-plugin' ) ) { 28 self::validate_block( $_POST['plugin_url'] ); 29 } 30 ?> 31 31 </div> 32 32 <?php … … 35 35 /** 36 36 * Validates readme.txt contents and adds feedback. 37 * 38 * @param string $plugin_url The URL of a Subversion or GitHub repository. 37 39 */ 38 40 protected static function validate_block( $plugin_url ) { … … 41 43 $results = $checker->run_check_plugin_repo( $plugin_url ); 42 44 45 echo '<h2>' . __( 'Results', 'wporg-plugins' ) . '</h2>'; 46 43 47 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>'; 46 55 } 47 56 … … 50 59 $results_by_type[ $item->type ][] = $item; 51 60 } 52 53 61 54 62 $output = ''; … … 60 68 ); 61 69 foreach ( $error_types as $type => $warning_label ) { 70 if ( empty( $results_by_type[ $type ] ) ) { 71 continue; 72 } 62 73 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>'; 71 81 } 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"; 74 86 } 75 87
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)