Changeset 7049
- Timestamp:
- 04/06/2018 05:04:54 AM (6 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-parser.php
r7021 r7049 89 89 90 90 /** 91 * Flag to specify that a Contributor was ignored.92 * 93 * @var bool94 */ 95 public $ contributor_ignored = false;91 * Warning flags which indicate specific parsing failures have occured. 92 * 93 * @var array 94 */ 95 public $warnings = array(); 96 96 97 97 /** … … 244 244 } 245 245 if ( ! empty( $headers['requires_php'] ) ) { 246 $this->requires_php = $ headers['requires_php'];246 $this->requires_php = $this->sanitize_requires_php( $headers['requires_php'] ); 247 247 } 248 248 if ( ! empty( $headers['contributors'] ) ) { … … 551 551 if ( ! $user ) { 552 552 unset( $users[ $i ] ); 553 $this-> contributor_ignored= true;553 $this->warnings['contributor_ignored'] = true; 554 554 continue; 555 555 } … … 580 580 581 581 return $stable_tag; 582 } 583 584 /** 585 * Sanitizes the Requires PHP header to ensure that it's a valid version header. 586 * 587 * @param string $version 588 * @return string The sanitized $version 589 */ 590 protected function sanitize_requires_php( $version ) { 591 $version = trim( $version ); 592 593 // x.y or x.y.z 594 if ( $version && ! preg_match( '!^\d+(\.\d+){1,2}$!', $version ) ) { 595 $this->warnings['requires_php_ignored'] = true; 596 // Ignore the readme value. 597 $version = ''; 598 } 599 600 return $version; 582 601 } 583 602 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-validator.php
r7023 r7049 77 77 $warnings[] = sprintf( __( '%s field is missing.', 'wporg-plugins' ), '<code>Tested up to</code>' ); 78 78 } 79 if ( empty( $readme->requires_php ) ) { 79 if ( isset( $readme->warnings['requires_php_ignored'] ) ) { 80 /* translators: 1: plugin header tag; 2: Example version 5.2.4. 3: Example version 7.0. */ 81 $warnings[] = sprintf( __( 'The Requires PHP field was ignored. %1$s field should only contain a PHP version such as %2$s or %3$s.', 'wporg-plugins' ), '<code>Requires PHP</code>', '<code>5.2.4</code>', '<code>7.0</code>' ); 82 } elseif ( empty( $readme->requires_php ) ) { 80 83 /* translators: %s: plugin header tag */ 81 84 $warnings[] = sprintf( __( '%s field is missing.', 'wporg-plugins' ), '<code>Requires PHP</code>' ); … … 89 92 $warnings[] = sprintf( __( '%s field is missing.', 'wporg-plugins' ), '<code>Contributors</code>' ); 90 93 } 91 if ( $readme->contributor_ignored) {94 if ( isset( $readme->warnings['contributor_ignored'] ) ) { 92 95 /* translators: %s: plugin header tag */ 93 96 $warnings[] = sprintf( __( 'One or more contributors listed were ignored. %s field should only contain WordPress.org usernames.', 'wporg-plugins' ), '<code>Contributors</code>' );
Note: See TracChangeset
for help on using the changeset viewer.