Changeset 11479
- Timestamp:
- 01/27/2022 04:14:37 AM (3 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
r11474 r11479 397 397 } 398 398 399 // Account for "twenty" themes, these themes have slugs that do not match the normal conventions. 400 $this->theme_slug = str_replace( 401 array( 'twenty-ten', 'twenty-eleven', 'twenty-twelve', 'twenty-thirteen', 'twenty-fourteen', 'twenty-fifteen', 'twenty-sixteen', 'twenty-seventeen', 'twenty-eighteen', 'twenty-nineteen', 'twenty-twenty-one', 'twenty-twenty-two', 'twenty-twenty-three', 'twenty-twenty-four', 'twenty-twenty-five', 'twenty-twenty-six', 'twenty-twenty-seven', 'twenty-twenty-eight', 'twenty-twenty-nine', 'twenty-thirty', 'twenty-twenty'), 402 array( 'twentyten', 'twentyeleven', 'twentytwelve', 'twentythirteen', 'twentyfourteen', 'twentyfifteen', 'twentysixteen', 'twentyseventeen', 'twentyeighteen', 'twentynineteen', 'twentytwentyone', 'twentytwentytwo', 'twentytwentythree', 'twentytwentyfour', 'twentytwentyfive', 'twentytwentysix', 'twentytwentyseven', 'twentytwentyeight', 'twentytwentynine', 'twentythirty', 'twentytwenty' ), 403 $this->theme_slug 404 ); 405 399 406 if ( ! $this->theme_name || ! $this->theme_slug ) { 400 407 $error = __( 'The theme has no name.', 'wporg-themes' ) . ' '; … … 424 431 } 425 432 433 // Populate the theme post. 434 if ( ! $this->theme_post ) { 435 $this->theme_post = $this->get_theme_post(); 436 } 437 426 438 // Populate author. 427 439 if ( ! $this->author ) { … … 434 446 435 447 // Make sure it doesn't use a slug deemed not to be used by the public. 436 // This check must be run before `get_theme_post()` to account for "twenty" themes.437 448 if ( $this->has_reserved_slug() ) { 438 449 $style_errors->add( … … 445 456 ) 446 457 ); 447 }448 449 // Populate the theme post.450 // Like it says above, the has_reserved_slug() function *must* run before this.451 if ( ! $this->theme_post ) {452 $this->theme_post = $this->get_theme_post();453 458 } 454 459 … … 963 968 */ 964 969 public function has_reserved_slug() { 965 $slug = str_replace(966 array( 'twenty-ten', 'twenty-eleven', 'twenty-twelve', 'twenty-thirteen', 'twenty-fourteen', 'twenty-fifteen', 'twenty-sixteen', 'twenty-seventeen', 'twenty-eighteen', 'twenty-nineteen', 'twenty-twenty-one', 'twenty-twenty-two', 'twenty-twenty-three', 'twenty-twenty-four', 'twenty-twenty-five', 'twenty-twenty-six', 'twenty-twenty-seven', 'twenty-twenty-eight', 'twenty-twenty-nine', 'twenty-thirty', 'twenty-twenty'),967 array( 'twentyten', 'twentyeleven', 'twentytwelve', 'twentythirteen', 'twentyfourteen', 'twentyfifteen', 'twentysixteen', 'twentyseventeen', 'twentyeighteen', 'twentynineteen', 'twentytwentyone', 'twentytwentytwo', 'twentytwentythree', 'twentytwentyfour', 'twentytwentyfive', 'twentytwentysix', 'twentytwentyseven', 'twentytwentyeight', 'twentytwentynine', 'twentythirty', 'twentytwenty' ),968 $this->theme_slug969 );970 971 970 $reserved_slugs = array( 972 971 // Reserve "twenty" names for wordpressdotorg. … … 975 974 'twentytwentyone', 'twentytwentytwo', 'twentytwentythree', 'twentytwentyfour', 'twentytwentyfive', 976 975 'twentytwentysix', 'twentytwentyseven', 'twentytwentyeight', 'twentytwentynine', 'twentythirty', 976 977 977 // Theme Showcase URL parameters. 978 978 'browse', 'tag', 'search', 'filter', 'upload', 'commercial', … … 981 981 982 982 // If it's not a reserved slug, they can have it. 983 if ( 984 ! in_array( $slug, $reserved_slugs, true ) && 985 ! in_array( $this->theme_slug, $reserved_slugs, true ) 986 ) { 983 if ( ! in_array( $this->theme_slug, $reserved_slugs, true ) ) { 987 984 return false; 988 985 } 989 990 // force the slug to be correct for the twenty-x themes.991 $this->theme_slug = $slug;992 986 993 987 // WordPress.org user is always allowed to upload reserved slugs. … … 997 991 998 992 // Only committers uploading a default theme *update* are left to be checked for. 999 $theme_post = $this->get_theme_post();1000 1001 993 // New default themes MUST be uploaded by `wordpressdotorg` and will fail this check. 1002 994 if ( 1003 995 // Updates only. 1004 $th eme_post &&996 $this->theme_post && 1005 997 // The current user is a Core Committer. [ 'user_login' => 'Trac Title', ... ] 1006 998 ! empty( $GLOBALS['committers'][ $this->author->user_login ] ) && 1007 999 // The theme is owned by WordPress.org. 1008 'wordpressdotorg' === get_user_by( 'id', $th eme_post->post_author )->user_login1000 'wordpressdotorg' === get_user_by( 'id', $this->theme_post->post_author )->user_login 1009 1001 ) { 1010 1002 // Slug is reserved, but an update is being uploaded by a core committer.
Note: See TracChangeset
for help on using the changeset viewer.