Making WordPress.org

Changeset 10872


Ignore:
Timestamp:
04/06/2021 06:33:45 AM (5 years ago)
Author:
dd32
Message:

Theme Directory: Ensure that theme slugs are always ascii for best compatibility by converting any accented characters to non-accented and removing any that cannot be

There are no current published themes that have accented characters in their slugs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/class-wporg-themes-upload.php

    r10807 r10872  
    207207
    208208        // Let's check some theme headers, shall we?
    209 
    210         if ( ! $this->theme_name = $this->theme->get( 'Name' ) ) {
     209        $this->theme_name = $this->theme->get( 'Name' );
     210
     211        // Determine the theme slug (ascii only for compatibility) based on the name of the theme in the stylesheet
     212        $this->theme_slug = remove_accents( $this->theme_name );
     213        $this->theme_slug = preg_replace( '/%[a-f0-9]{2}/i', '', $this->theme_slug );
     214        $this->theme_slug = sanitize_title_with_dashes( $this->theme_slug );
     215
     216        if ( ! $this->theme_name || ! $this->theme_slug ) {
    211217            $error = __( 'The theme has no name.', 'wporg-themes' ) . ' ';
    212218
     
    220226            return $error;
    221227        }
    222 
    223         // determine the theme slug based on the name of the theme in the stylesheet
    224         $this->theme_slug = sanitize_title_with_dashes( $this->theme_name );
    225228
    226229        // Do not allow themes with WordPress and Theme in the theme name.
Note: See TracChangeset for help on using the changeset viewer.