Making WordPress.org

Changeset 11479


Ignore:
Timestamp:
01/27/2022 04:14:37 AM (3 years ago)
Author:
dd32
Message:

Theme Directory: Move the "twenty" theme check to a better place, so that get_theme_post() can be run earlier.

This unbreaks SVN use of the theme directory.

Reverts [11474].

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  
    397397        }
    398398
     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
    399406        if ( ! $this->theme_name || ! $this->theme_slug ) {
    400407            $error = __( 'The theme has no name.', 'wporg-themes' ) . ' ';
     
    424431        }
    425432
     433        // Populate the theme post.
     434        if ( ! $this->theme_post ) {
     435            $this->theme_post = $this->get_theme_post();
     436        }
     437
    426438        // Populate author.
    427439        if ( ! $this->author ) {
     
    434446
    435447        // 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.
    437448        if ( $this->has_reserved_slug() ) {
    438449            $style_errors->add(
     
    445456                )
    446457            );
    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();
    453458        }
    454459
     
    963968     */
    964969    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_slug
    969         );
    970 
    971970        $reserved_slugs = array(
    972971            // Reserve "twenty" names for wordpressdotorg.
     
    975974            'twentytwentyone', 'twentytwentytwo', 'twentytwentythree', 'twentytwentyfour', 'twentytwentyfive',
    976975            'twentytwentysix', 'twentytwentyseven', 'twentytwentyeight', 'twentytwentynine', 'twentythirty',
     976
    977977            // Theme Showcase URL parameters.
    978978            'browse', 'tag', 'search', 'filter', 'upload', 'commercial',
     
    981981
    982982        // 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 ) ) {
    987984            return false;
    988985        }
    989 
    990         // force the slug to be correct for the twenty-x themes.
    991         $this->theme_slug = $slug;
    992986
    993987        // WordPress.org user is always allowed to upload reserved slugs.
     
    997991
    998992        // Only committers uploading a default theme *update* are left to be checked for.
    999         $theme_post = $this->get_theme_post();
    1000 
    1001993        // New default themes MUST be uploaded by `wordpressdotorg` and will fail this check.
    1002994        if (
    1003995            // Updates only.
    1004             $theme_post &&
     996            $this->theme_post &&
    1005997            // The current user is a Core Committer. [ 'user_login' => 'Trac Title', ... ]
    1006998            ! empty( $GLOBALS['committers'][ $this->author->user_login ] ) &&
    1007999            // The theme is owned by WordPress.org.
    1008             'wordpressdotorg' === get_user_by( 'id', $theme_post->post_author )->user_login
     1000            'wordpressdotorg' === get_user_by( 'id', $this->theme_post->post_author )->user_login
    10091001        ) {
    10101002            // Slug is reserved, but an update is being uploaded by a core committer.
Note: See TracChangeset for help on using the changeset viewer.