Make WordPress Core


Ignore:
Timestamp:
10/06/2015 04:34:03 AM (11 years ago)
Author:
DrewAPicture
Message:

Multisite: Introduce get_subdirectory_reserved_names(), which returns a filterable list of reserved subdirectory site names.

The function encapsulates the existing subdirectory_reserved_names filter and reduces the maintenance burden of keeping the value of (currently) two instances of the same hook in sync.

See #33615.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ms-functions.php

    r34853 r34854  
    556556         */
    557557        if ( ! is_subdomain_install() ) {
    558                 $illegal_names = array_merge(
    559                         $illegal_names,
    560                         /**
    561                          * Filter reserved site names on a sub-directory Multisite install.
    562                          *
    563                          * @since 3.0.0
    564                          * @since 4.4.0 'wp-admin', 'wp-content', 'wp-includes', 'wp-json', and 'embed' were added
    565                          *              to the reserved names list.
    566                          *
    567                          * @param array $subdirectory_reserved_names Array of reserved names.
    568                          */
    569                         apply_filters( 'subdirectory_reserved_names', array( 'page', 'comments', 'blog', 'files', 'feed', 'wp-admin', 'wp-content', 'wp-includes', 'wp-json', 'embed' ) )
    570                 );
     558                $illegal_names = array_merge( $illegal_names, get_subdirectory_reserved_names() );
    571559        }
    572560
     
    24692457        return $site_results;
    24702458}
     2459
     2460/**
     2461 * Retrieves a list of reserved site on a sub-directory Multisite install.
     2462 *
     2463 * @since 4.4.0
     2464 *
     2465 * @return array $names Array of reserved subdirectory names.
     2466 */
     2467function get_subdirectory_reserved_names() {
     2468        $names = array(
     2469                'page', 'comments', 'blog', 'files', 'feed', 'wp-admin',
     2470                'wp-content', 'wp-includes', 'wp-json', 'embed'
     2471        );
     2472
     2473        /**
     2474         * Filter reserved site names on a sub-directory Multisite install.
     2475         *
     2476         * @since 3.0.0
     2477         * @since 4.4.0 'wp-admin', 'wp-content', 'wp-includes', 'wp-json', and 'embed' were added
     2478         *              to the reserved names list.
     2479         *
     2480         * @param array $subdirectory_reserved_names Array of reserved names.
     2481         */
     2482        return apply_filters( 'subdirectory_reserved_names', $names );
     2483}
Note: See TracChangeset for help on using the changeset viewer.