Changeset 12186
- Timestamp:
- 11/02/2022 03:16:40 AM (2 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
r11641 r12186 445 445 } 446 446 447 // Default Theme handling. 448 if ( 449 // Reserved slugs include twenty* and other terms 450 $this->has_reserved_slug() && 451 // ...so limit to twenty* only 452 str_starts_with( $this->theme_slug, 'twenty' ) && 453 // The current user is a Core Committer. [ 'user_login' => 'Trac Title', ... ] 454 ! empty( $GLOBALS['committers'][ $this->author->user_login ] ) && 455 ( 456 // New theme submission 457 ! $this->theme_post 458 || 459 // OR an Update and the theme is owned by WordPress.org. 460 'wordpressdotorg' === get_user_by( 'id', $this->theme_post->post_author )->user_login 461 ) 462 ) { 463 // Set the author to WordPress.org 464 $this->author = get_user_by( 'login', 'wordpressdotorg' ); 465 466 // WordPress.org is allowed to bypass Theme Check, see further down. 467 } 468 447 469 // Make sure it doesn't use a slug deemed not to be used by the public. 448 470 if ( $this->has_reserved_slug() ) { … … 559 581 $this->theme_post->post_author != $this->author->ID 560 582 ) { 561 562 $is_allowed_to_upload_for_theme = false; 563 if ( 564 // The theme is owned by WordPress.org. 565 'wordpressdotorg' === get_user_by( 'id', $this->theme_post->post_author )->user_nicename && 566 // The current user is a Core Committer. [ 'user_login' => 'Trac Title', ... ] 567 ! empty( $GLOBALS['committers'][ $this->author->user_login ] ) 568 ) { 569 // Allow core committers to update default themes (as authored by @wordpressdotorg) 570 $is_allowed_to_upload_for_theme = true; 571 } 572 573 if ( ! $is_allowed_to_upload_for_theme ) { 574 $style_errors->add( 575 'cannot_upload_theme', 576 sprintf( 577 /* translators: 1: theme slug, 2: style.css */ 578 __( 'There is already a theme called %1$s by a different author. Please change the name of your theme in %2$s and upload it again.', 'wporg-themes' ), 579 '<code>' . $this->theme_slug . '</code>', 580 '<code>style.css</code>' 581 ) . $are_you_in_the_right_place 582 ); 583 } 583 $style_errors->add( 584 'cannot_upload_theme', 585 sprintf( 586 /* translators: 1: theme slug, 2: style.css */ 587 __( 'There is already a theme called %1$s by a different author. Please change the name of your theme in %2$s and upload it again.', 'wporg-themes' ), 588 '<code>' . $this->theme_slug . '</code>', 589 '<code>style.css</code>' 590 ) . $are_you_in_the_right_place 591 ); 584 592 } 585 593 … … 652 660 } 653 661 654 // Don't block special themes based on Theme Check.662 // Don't block special themes or default themes based on Theme Check. 655 663 if ( has_category( 'special-case-theme', $this->theme_post ) ) { 664 $args['block_on_themecheck'] = false; 665 } elseif ( 'wordpressdotorg' === get_user_by( 'id', $this->theme_post->post_author )->user_login ) { 656 666 $args['block_on_themecheck'] = false; 657 667 } … … 990 1000 } 991 1001 992 // Only committers uploading a default theme *update* are left to be checked for.993 // New default themes MUST be uploaded by `wordpressdotorg` and will fail this check.994 if (995 // Updates only.996 $this->theme_post &&997 // The current user is a Core Committer. [ 'user_login' => 'Trac Title', ... ]998 ! empty( $GLOBALS['committers'][ $this->author->user_login ] ) &&999 // The theme is owned by WordPress.org.1000 'wordpressdotorg' === get_user_by( 'id', $this->theme_post->post_author )->user_login1001 ) {1002 // Slug is reserved, but an update is being uploaded by a core committer.1003 return false;1004 }1005 1006 1002 // Slug is reserved, user is not authorized. 1007 1003 return true; … … 1199 1195 } 1200 1196 1197 /* 1198 * Trac reporter is always the authenticated user, unless it's not-auth'd in which case it's the Theme Author. 1199 * 1200 * This allows for Committers to upload Default themes under 'WordPress.org' but it still be to noted on Trac who uploaded it. 1201 * This also allows for SVN imports where the current user is not set. 1202 */ 1203 $trac_ticket_reporter = wp_get_current_user()->user_login ?? $this->author->user_login; 1204 1201 1205 // If there's a previous version and the most current version's status is `new`, we update. 1202 1206 if ( … … 1215 1219 'type' => 'theme', 1216 1220 'keywords' => implode( ' ', $this->trac_ticket->keywords ), 1217 'reporter' => $t his->author->user_login,1221 'reporter' => $trac_ticket_reporter, 1218 1222 'cc' => $this->author->user_email, 1219 1223 'priority' => $this->trac_ticket->priority, … … 1227 1231 'type' => 'theme', 1228 1232 'keywords' => implode( ' ', $this->trac_ticket->keywords ), 1229 'reporter' => $t his->author->user_login,1233 'reporter' => $trac_ticket_reporter, 1230 1234 'cc' => $this->author->user_email, 1231 1235 'priority' => $this->trac_ticket->priority, … … 1534 1538 } 1535 1539 1536 $emails = [ 1540 // Email the Theme Author(s). The uploader & theme author may differ in special cases (default themes). 1541 $emails = array_filter( array_unique( [ 1542 // The theme author 1537 1543 $this->author->user_email, 1538 ]; 1539 1540 // If the uploader and the author are different, email them both. 1541 // This only happens under special circumstances. 1542 if ( 1543 ! empty( $this->theme_post ) && 1544 $this->theme_post->post_author != $this->author->ID 1545 ) { 1546 $emails[] = get_user_by( 'id', $this->theme_post->post_author )->user_email; 1547 } 1544 // The theme Author (usually the same) 1545 get_user_by( 'id', $this->theme_post->post_author )->user_email ?? false, 1546 // The current user (also, usually the same) 1547 wp_get_current_user()->user_email 1548 ] ) ); 1548 1549 1549 1550 wp_mail( $emails, $email_subject, $email_content, 'From: "WordPress Theme Directory" <themes@wordpress.org>' );
Note: See TracChangeset
for help on using the changeset viewer.