Changeset 20144
- Timestamp:
- 03/07/2012 11:32:06 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/class-wp-theme.php
r20132 r20144 1083 1083 public static function get_allowed_on_network() { 1084 1084 static $allowed_themes; 1085 if ( ! isset( $allowed_themes ) ) 1086 $allowed_themes = (array) get_site_option( 'allowedthemes' ); 1085 if ( isset( $allowed_themes ) ) 1086 return $allowed_themes; 1087 1088 $allowed_themes = get_site_option( 'allowedthemes' ); 1089 1090 // This is all super old MU back compat joy. 1091 // 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name. 1092 if ( false === $allowed_themes ) { 1093 $allowed_themes = get_site_option( 'allowed_themes' ); 1094 if ( ! is_array( $allowed_themes ) || empty( $allowed_themes ) ) { 1095 $allowed_themes = array(); 1096 } else { 1097 $converted = array(); 1098 $themes = wp_get_themes(); 1099 foreach ( $themes as $stylesheet => $theme_data ) { 1100 if ( isset( $allowed_themes[ $theme_data->get('Name') ] ) ) 1101 $converted[ $stylesheet ] = true; 1102 } 1103 $allowed_themes = $converted; 1104 } 1105 // Set the option so we never have to go through this pain again. 1106 if ( is_admin() ) { 1107 update_site_option( 'allowedthemes', $allowed_themes ); 1108 delete_site_option( 'allowed_themes' ); 1109 } 1110 } 1111 1087 1112 return $allowed_themes; 1088 1113 } … … 1099 1124 public static function get_allowed_on_site( $blog_id = null ) { 1100 1125 static $allowed_themes = array(); 1126 1101 1127 if ( ! $blog_id ) 1102 1128 $blog_id = get_current_blog_id(); 1103 1129 1104 if ( ! isset( $allowed_themes[ $blog_id ] ) ) { 1105 if ( $blog_id == get_current_blog_id() ) 1106 $allowed_themes[ $blog_id ] = (array) get_option( 'allowedthemes' ); 1130 if ( isset( $allowed_themes[ $blog_id ] ) ) 1131 return $allowed_themes[ $blog_id ]; 1132 1133 $current = $blog_id == get_current_blog_id(); 1134 1135 if ( $current ) 1136 $allowed_themes[ $blog_id ] = get_option( 'allowedthemes' ); 1137 else 1138 $allowed_themes[ $blog_id ] = get_blog_option( $blog_id, 'allowedthemes' ); 1139 1140 // This is all super old MU back compat joy. 1141 // 'allowedthemes' keys things by stylesheet. 'allowed_themes' keyed things by name. 1142 if ( false === $allowed_themes[ $blog_id ] ) { 1143 if ( $current ) 1144 $allowed_themes[ $blog_id ] = get_option( 'allowed_themes' ); 1107 1145 else 1108 $allowed_themes[ $blog_id ] = (array) get_blog_option( $blog_id, 'allowedthemes' ); 1146 $allowed_themes[ $blog_id ] = get_blog_option( $blog_id, 'allowed_themes' ); 1147 1148 if ( ! is_array( $allowed_themes[ $blog_id ] ) || empty( $allowed_themes[ $blog_id ] ) ) { 1149 $allowed_themes[ $blog_id ] = array(); 1150 } else { 1151 $converted = array(); 1152 $themes = wp_get_themes(); 1153 foreach ( $themes as $stylesheet => $theme_data ) { 1154 if ( isset( $allowed_themes[ $blog_id ][ $theme_data->get('Name') ] ) ) 1155 $converted[ $stylesheet ] = true; 1156 } 1157 $allowed_themes[ $blog_id ] = $converted; 1158 } 1159 // Set the option so we never have to go through this pain again. 1160 if ( is_admin() ) { 1161 if ( $current ) { 1162 update_option( 'allowedthemes', $allowed_themes[ $blog_id ] ); 1163 delete_option( 'allowed_themes' ); 1164 } else { 1165 update_blog_option( $blog_id, 'allowedthemes', $allowed_themes[ $blog_id ] ); 1166 delete_blog_option( $blog_id, 'allowed_themes' ); 1167 } 1168 } 1109 1169 } 1110 1170
Note: See TracChangeset
for help on using the changeset viewer.