Make WordPress Core


Ignore:
Timestamp:
01/16/2024 12:10:47 PM (3 years ago)
Author:
swissspidy
Message:

I18N: Do not use trailingslashit in WP_Textdomain_Registry.

This usage of trailingslashit(), introduced in [57287], is not only redundant, but also discouraged in order to avoid formatting.php dependency (which might not always be loaded).

Props SergeyBiryukov.
See #58919.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-textdomain-registry.php

    r57287 r57290  
    162162         */
    163163        public function get_language_files_from_path( $path ) {
    164                 $path = trailingslashit( $path );
     164                $path = rtrim( $path, '/' ) . '/';
    165165
    166166                /**
    … …  
    238238                        switch ( $type ) {
    239239                                case 'plugin':
    240                                         wp_cache_delete( 'cached_mo_files_' . md5( trailingslashit( WP_LANG_DIR ) . '/plugins/' ), 'translations' );
     240                                        wp_cache_delete( 'cached_mo_files_' . md5( WP_LANG_DIR . '/plugins' ), 'translations' );
    241241                                        break;
    242242                                case 'theme':
    243                                         wp_cache_delete( 'cached_mo_files_' . md5( trailingslashit( WP_LANG_DIR ) . '/themes/' ), 'translations' );
     243                                        wp_cache_delete( 'cached_mo_files_' . md5( WP_LANG_DIR . '/themes' ), 'translations' );
    244244                                        break;
    245245                                default:
    246                                         wp_cache_delete( 'cached_mo_files_' . md5( trailingslashit( WP_LANG_DIR ) ), 'translations' );
     246                                        wp_cache_delete( 'cached_mo_files_' . md5( WP_LANG_DIR ), 'translations' );
    247247                                        break;
    248248                        }
Note: See TracChangeset for help on using the changeset viewer.