Changeset 4483
- Timestamp:
- 12/04/2016 10:10:02 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/class-wporg-themes-upload.php
r4482 r4483 282 282 '<a href="mailto:themes@wordpress.org">themes@wordpress.org</a>' 283 283 ); 284 }285 286 /*287 * Add a comment to the trac ticket with the results of the theme check, if any exists.288 */289 if ( !empty( $GLOBALS['themechecks'] ) ) {290 $tc_errors = $tc_results = array();291 foreach ( $GLOBALS['themechecks'] as $check ) {292 if ( $check instanceof \themecheck ) {293 $error = (array) $check->getError();294 if ( $error ) {295 $tc_errors = array_unique( array_merge( $tc_errors, $error ) );296 }297 }298 }299 if ( $tc_errors ) {300 foreach ( $tc_errors as $e ) {301 $trac_left = array( '<strong>', '</strong>' );302 $trac_right= array( "'''", "'''" );303 $html_link = '/<a\s?href\s?=\s?[\'|"]([^"|\']*)[\'|"]>([^<]*)<\/a>/i';304 $html_new = '[$1 $2]';305 $e = preg_replace( $html_link, $html_new, $e );306 $e = str_replace( $trac_left, $trac_right, $e );307 $e = preg_replace( '/<pre.*?>/', "\r\n{{{\r\n", $e );308 $e = str_replace( '</pre>', "\r\n}}}\r\n", $e );309 310 $e = preg_replace( '!<span class="[^"]+">([^<]+)</span>!', '$1', $e );311 312 if ( 'INFO' !== substr( $e, 0, 4 ) ) {313 $tc_results[] = '* ' . $e;314 }315 }316 }317 318 if ( $tc_results ) {319 $tc_results = implode( "\n", $tc_results );320 321 $this->trac->ticket_update(322 $ticket_id,323 "Theme Check Results:\n" . $tc_results324 );325 }326 284 } 327 285 … … 603 561 [[Image(https://themes.svn.wordpress.org/{$this->theme_slug}/{$this->theme->display( 'Version' )}/{$this->theme->screenshot}, width=640)]] 604 562 TICKET; 605 } 563 564 $theme_check_results = $this->generate_themecheck_results_for_trac(); 565 if ( $theme_check_results ) { 566 $this->trac_ticket->description .= "\nTheme Check Results:\n" . $theme_check_results; 567 } 568 569 } 570 571 /* 572 * Add a comment to the trac ticket with the results of the theme check, if any exists. 573 */ 574 public function generate_themecheck_results_for_trac() { 575 global $themechecks; 576 if ( empty( $themechecks ) ) { 577 return ''; 578 } 579 580 $tc_errors = $tc_results = array(); 581 foreach ( $themechecks as $check ) { 582 if ( $check instanceof \themecheck ) { 583 $error = (array) $check->getError(); 584 if ( $error ) { 585 $tc_errors = array_unique( array_merge( $tc_errors, $error ) ); 586 } 587 } 588 } 589 590 if ( $tc_errors ) { 591 foreach ( $tc_errors as $e ) { 592 $trac_left = array( '<strong>', '</strong>' ); 593 $trac_right= array( "'''", "'''" ); 594 $html_link = '/<a\s?href\s?=\s?[\'|"]([^"|\']*)[\'|"]>([^<]*)<\/a>/i'; 595 $html_new = '[$1 $2]'; 596 $e = preg_replace( $html_link, $html_new, $e ); 597 $e = str_replace( $trac_left, $trac_right, $e ); 598 $e = preg_replace( '/<pre.*?>/', "\r\n{{{\r\n", $e ); 599 $e = str_replace( '</pre>', "\r\n}}}\r\n", $e ); 600 $e = preg_replace( '!<span class="[^"]+">([^<]+)</span>!', '$1', $e ); 601 602 if ( 'INFO' !== substr( $e, 0, 4 ) ) { 603 $tc_results[] = '* ' . $e; 604 } 605 } 606 } 607 608 if ( ! $tc_results ) { 609 return ''; 610 } 611 612 return implode( "\n", $tc_results ); 613 } 614 606 615 607 616 /**
Note: See TracChangeset
for help on using the changeset viewer.