diff --git src/wp-includes/class-wp-theme.php src/wp-includes/class-wp-theme.php
index 523c733..3b80657 100644
|
|
final class WP_Theme implements ArrayAccess { |
1104 | 1104 | /** |
1105 | 1105 | * Filter the array of themes allowed on the site or network. |
1106 | 1106 | * |
1107 | | * @since MU |
| 1107 | * @since 4.2 |
1108 | 1108 | * |
1109 | 1109 | * @param array $allowed_themes An array of theme stylesheet names. |
1110 | 1110 | */ |
1111 | | $network = (array) apply_filters( 'allowed_themes', self::get_allowed_on_network() ); |
| 1111 | $network = (array) apply_filters( 'allowed_themes_combined', self::get_allowed_on_network(), $blog_id ); |
1112 | 1112 | return $network + self::get_allowed_on_site( $blog_id ); |
1113 | 1113 | } |
1114 | 1114 | |
… |
… |
final class WP_Theme implements ArrayAccess { |
1122 | 1122 | */ |
1123 | 1123 | public static function get_allowed_on_network() { |
1124 | 1124 | static $allowed_themes; |
1125 | | if ( ! isset( $allowed_themes ) ) |
1126 | | $allowed_themes = (array) get_site_option( 'allowedthemes' ); |
| 1125 | if ( ! isset( $allowed_themes ) ) { |
| 1126 | /** |
| 1127 | * Filter the array of themes allowed on the network. |
| 1128 | * |
| 1129 | * @since 4.2 |
| 1130 | * |
| 1131 | * @param array $allowed_themes An array of theme stylesheet names. |
| 1132 | */ |
| 1133 | $allowed_themes = (array) apply_filters( 'allowed_themes', get_site_option( 'allowedthemes' ) ); |
| 1134 | } |
1127 | 1135 | return $allowed_themes; |
1128 | 1136 | } |
1129 | 1137 | |
… |
… |
final class WP_Theme implements ArrayAccess { |
1191 | 1199 | } |
1192 | 1200 | } |
1193 | 1201 | |
1194 | | return (array) $allowed_themes[ $blog_id ]; |
| 1202 | /** |
| 1203 | * Filter the array of themes allowed on the site. |
| 1204 | * |
| 1205 | * @since 4.2 |
| 1206 | * |
| 1207 | * @param array $allowed_themes An array of theme stylesheet names. |
| 1208 | */ |
| 1209 | $allowed_themes = (array) apply_filters( 'allowed_themes_site', $allowed_themes[ $blog_id ], $blog_id ); |
| 1210 | return $allowed_themes; |
1195 | 1211 | } |
1196 | 1212 | |
1197 | 1213 | /** |
diff --git tests/phpunit/tests/multisite/theme.php tests/phpunit/tests/multisite/theme.php
new file mode 100644
index 0000000..a8944dd
-
|
+
|
|
| 1 | <?php |
| 2 | |
| 3 | if ( is_multisite() ) : /** |
| 4 | * Tests specific to networks in multisite. |
| 5 | * |
| 6 | * @group ms-network |
| 7 | * @group multisite |
| 8 | */ { |
| 9 | class Tests_Multisite_Theme extends WP_UnitTestCase { |
| 10 | |
| 11 | function setUp() { |
| 12 | global $wpdb; |
| 13 | parent::setUp(); |
| 14 | $this->suppress = $wpdb->suppress_errors(); |
| 15 | |
| 16 | $_SERVER['REMOTE_ADDR'] = ''; |
| 17 | } |
| 18 | |
| 19 | function tearDown() { |
| 20 | global $wpdb; |
| 21 | $wpdb->suppress_errors( $this->suppress ); |
| 22 | parent::tearDown(); |
| 23 | } |
| 24 | |
| 25 | function test_nav_menu_theme_filter_sends_blog_id() { |
| 26 | $args = [ ]; |
| 27 | |
| 28 | add_filter( 'allowed_themes_combined', function () use ( &$args ) { |
| 29 | $args = func_get_args(); |
| 30 | }, 10, 2 ); |
| 31 | |
| 32 | $blog_id = 2; |
| 33 | |
| 34 | WP_Theme::get_allowed( $blog_id ); |
| 35 | |
| 36 | $this->assertNotEmpty( $args ); |
| 37 | $this->assertEquals( 2, count( $args ) ); |
| 38 | $this->assertEquals( $blog_id, $args[1] ); |
| 39 | } |
| 40 | |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | endif; |