39 private static $default_themes = array( |
39 private static $default_themes = array( |
40 'classic' => 'WordPress Classic', |
40 'classic' => 'WordPress Classic', |
41 'default' => 'WordPress Default', |
41 'default' => 'WordPress Default', |
42 'twentyten' => 'Twenty Ten', |
42 'twentyten' => 'Twenty Ten', |
43 'twentyeleven' => 'Twenty Eleven', |
43 'twentyeleven' => 'Twenty Eleven', |
|
44 'twentytwelve' => 'Twenty Twelve', |
44 ); |
45 ); |
45 |
46 |
46 /** |
47 /** |
47 * Absolute path to the theme root, usually wp-content/themes |
48 * Absolute path to the theme root, usually wp-content/themes |
48 * |
49 * |
251 $theme_root_template = $directories[ $this->template ]['theme_root']; |
252 $theme_root_template = $directories[ $this->template ]['theme_root']; |
252 } else { |
253 } else { |
253 // Parent theme is missing. |
254 // Parent theme is missing. |
254 $this->errors = new WP_Error( 'theme_no_parent', sprintf( __( 'The parent theme is missing. Please install the "%s" parent theme.' ), $this->template ) ); |
255 $this->errors = new WP_Error( 'theme_no_parent', sprintf( __( 'The parent theme is missing. Please install the "%s" parent theme.' ), $this->template ) ); |
255 $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) ); |
256 $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) ); |
|
257 $this->parent = new WP_Theme( $this->template, $this->theme_root, $this ); |
256 return; |
258 return; |
257 } |
259 } |
258 } |
260 } |
259 |
261 |
260 // Set the parent, if we're a child theme. |
262 // Set the parent, if we're a child theme. |
1100 * @return array Array of stylesheet names. |
1102 * @return array Array of stylesheet names. |
1101 */ |
1103 */ |
1102 public static function get_allowed_on_site( $blog_id = null ) { |
1104 public static function get_allowed_on_site( $blog_id = null ) { |
1103 static $allowed_themes = array(); |
1105 static $allowed_themes = array(); |
1104 |
1106 |
1105 if ( ! $blog_id ) |
1107 if ( ! $blog_id || ! is_multisite() ) |
1106 $blog_id = get_current_blog_id(); |
1108 $blog_id = get_current_blog_id(); |
1107 |
1109 |
1108 if ( isset( $allowed_themes[ $blog_id ] ) ) |
1110 if ( isset( $allowed_themes[ $blog_id ] ) ) |
1109 return $allowed_themes[ $blog_id ]; |
1111 return $allowed_themes[ $blog_id ]; |
1110 |
1112 |
1111 $current = $blog_id == get_current_blog_id(); |
1113 $current = $blog_id == get_current_blog_id(); |
1112 |
1114 |
1113 if ( $current ) |
1115 if ( $current ) { |
1114 $allowed_themes[ $blog_id ] = get_option( 'allowedthemes' ); |
1116 $allowed_themes[ $blog_id ] = get_option( 'allowedthemes' ); |
1115 else |
1117 } else { |
1116 $allowed_themes[ $blog_id ] = get_blog_option( $blog_id, 'allowedthemes' ); |
1118 switch_to_blog( $blog_id ); |
|
1119 $allowed_themes[ $blog_id ] = get_option( 'allowedthemes' ); |
|
1120 restore_current_blog(); |
|
1121 } |
1117 |
1122 |
1118 // This is all super old MU back compat joy. |
1123 // This is all super old MU back compat joy. |
1119 // 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name. |
1124 // 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name. |
1120 if ( false === $allowed_themes[ $blog_id ] ) { |
1125 if ( false === $allowed_themes[ $blog_id ] ) { |
1121 if ( $current ) |
1126 if ( $current ) { |
1122 $allowed_themes[ $blog_id ] = get_option( 'allowed_themes' ); |
1127 $allowed_themes[ $blog_id ] = get_option( 'allowed_themes' ); |
1123 else |
1128 } else { |
1124 $allowed_themes[ $blog_id ] = get_blog_option( $blog_id, 'allowed_themes' ); |
1129 switch_to_blog( $blog_id ); |
|
1130 $allowed_themes[ $blog_id ] = get_option( 'allowed_themes' ); |
|
1131 restore_current_blog(); |
|
1132 } |
1125 |
1133 |
1126 if ( ! is_array( $allowed_themes[ $blog_id ] ) || empty( $allowed_themes[ $blog_id ] ) ) { |
1134 if ( ! is_array( $allowed_themes[ $blog_id ] ) || empty( $allowed_themes[ $blog_id ] ) ) { |
1127 $allowed_themes[ $blog_id ] = array(); |
1135 $allowed_themes[ $blog_id ] = array(); |
1128 } else { |
1136 } else { |
1129 $converted = array(); |
1137 $converted = array(); |
1138 if ( is_admin() && $allowed_themes[ $blog_id ] ) { |
1146 if ( is_admin() && $allowed_themes[ $blog_id ] ) { |
1139 if ( $current ) { |
1147 if ( $current ) { |
1140 update_option( 'allowedthemes', $allowed_themes[ $blog_id ] ); |
1148 update_option( 'allowedthemes', $allowed_themes[ $blog_id ] ); |
1141 delete_option( 'allowed_themes' ); |
1149 delete_option( 'allowed_themes' ); |
1142 } else { |
1150 } else { |
1143 update_blog_option( $blog_id, 'allowedthemes', $allowed_themes[ $blog_id ] ); |
1151 switch_to_blog( $blog_id ); |
1144 delete_blog_option( $blog_id, 'allowed_themes' ); |
1152 update_option( 'allowedthemes', $allowed_themes[ $blog_id ] ); |
|
1153 delete_option( 'allowed_themes' ); |
|
1154 restore_current_blog(); |
1145 } |
1155 } |
1146 } |
1156 } |
1147 } |
1157 } |
1148 |
1158 |
1149 return (array) $allowed_themes[ $blog_id ]; |
1159 return (array) $allowed_themes[ $blog_id ]; |