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