Changeset 18821
- Timestamp:
- 09/29/2011 09:41:22 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/upgrade.php
r18643 r18821 452 452 upgrade_300(); 453 453 454 if ( $wp_current_db_version < 11548 ) 455 upgrade_old_widgets_order_array(); 456 454 457 maybe_disable_automattic_widgets(); 455 458 … … 1130 1133 } 1131 1134 1135 } 1136 1137 /** 1138 * Convert the old style widgets order array from 2.2. 1139 * 1140 * @since 3.3.0 1141 */ 1142 function upgrade_old_widgets_order_array() { 1143 global $wp_registered_widgets, $sidebars_widgets; 1144 1145 $sidebars_widgets = get_option( 'sidebars_widgets', array() ); 1146 $_sidebars_widgets = array(); 1147 1148 if ( isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets) ) 1149 $sidebars_widgets['array_version'] = 3; 1150 elseif ( !isset($sidebars_widgets['array_version']) ) 1151 $sidebars_widgets['array_version'] = 1; 1152 1153 switch ( $sidebars_widgets['array_version'] ) { 1154 case 1 : 1155 foreach ( (array) $sidebars_widgets as $index => $sidebar ) 1156 if ( is_array($sidebar) ) 1157 foreach ( (array) $sidebar as $i => $name ) { 1158 $id = strtolower($name); 1159 if ( isset($wp_registered_widgets[$id]) ) { 1160 $_sidebars_widgets[$index][$i] = $id; 1161 continue; 1162 } 1163 $id = sanitize_title($name); 1164 if ( isset($wp_registered_widgets[$id]) ) { 1165 $_sidebars_widgets[$index][$i] = $id; 1166 continue; 1167 } 1168 1169 $found = false; 1170 1171 foreach ( $wp_registered_widgets as $widget_id => $widget ) { 1172 if ( strtolower($widget['name']) == strtolower($name) ) { 1173 $_sidebars_widgets[$index][$i] = $widget['id']; 1174 $found = true; 1175 break; 1176 } elseif ( sanitize_title($widget['name']) == sanitize_title($name) ) { 1177 $_sidebars_widgets[$index][$i] = $widget['id']; 1178 $found = true; 1179 break; 1180 } 1181 } 1182 1183 if ( $found ) 1184 continue; 1185 1186 unset($_sidebars_widgets[$index][$i]); 1187 } 1188 $_sidebars_widgets['array_version'] = 2; 1189 $sidebars_widgets = $_sidebars_widgets; 1190 unset($_sidebars_widgets); 1191 1192 case 2 : 1193 $sidebars_widgets = retrieve_widgets(); 1194 $sidebars_widgets['array_version'] = 3; 1195 update_option( 'sidebars_widgets', $sidebars_widgets ); 1196 } 1132 1197 } 1133 1198 -
trunk/wp-includes/theme.php
r18720 r18821 1249 1249 global $wp_theme_directories, $sidebars_widgets; 1250 1250 1251 if ( ! is_array( $sidebars_widgets ) ) 1252 $sidebars_widgets = wp_get_sidebars_widgets(); 1253 set_theme_mod( 'sidebars_widgets', array( 'time' => time(), 'data' => $sidebars_widgets ) ); 1251 if ( is_array( $sidebars_widgets ) ) 1252 set_theme_mod( 'sidebars_widgets', array( 'time' => time(), 'data' => $sidebars_widgets ) ); 1254 1253 1255 1254 $old_theme = get_current_theme(); -
trunk/wp-includes/widgets.php
r18678 r18821 999 999 _deprecated_argument( __FUNCTION__, '2.8.1' ); 1000 1000 1001 global $wp_registered_widgets, $ wp_registered_sidebars, $_wp_sidebars_widgets;1001 global $wp_registered_widgets, $_wp_sidebars_widgets, $sidebars_widgets; 1002 1002 1003 1003 // If loading from front page, consult $_wp_sidebars_widgets rather than options … … 1010 1010 } else { 1011 1011 $sidebars_widgets = get_option('sidebars_widgets', array()); 1012 $_sidebars_widgets = array();1013 1014 if ( isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets) )1015 $sidebars_widgets['array_version'] = 3;1016 elseif ( !isset($sidebars_widgets['array_version']) )1017 $sidebars_widgets['array_version'] = 1;1018 1019 switch ( $sidebars_widgets['array_version'] ) {1020 case 1 :1021 foreach ( (array) $sidebars_widgets as $index => $sidebar )1022 if ( is_array($sidebar) )1023 foreach ( (array) $sidebar as $i => $name ) {1024 $id = strtolower($name);1025 if ( isset($wp_registered_widgets[$id]) ) {1026 $_sidebars_widgets[$index][$i] = $id;1027 continue;1028 }1029 $id = sanitize_title($name);1030 if ( isset($wp_registered_widgets[$id]) ) {1031 $_sidebars_widgets[$index][$i] = $id;1032 continue;1033 }1034 1035 $found = false;1036 1037 foreach ( $wp_registered_widgets as $widget_id => $widget ) {1038 if ( strtolower($widget['name']) == strtolower($name) ) {1039 $_sidebars_widgets[$index][$i] = $widget['id'];1040 $found = true;1041 break;1042 } elseif ( sanitize_title($widget['name']) == sanitize_title($name) ) {1043 $_sidebars_widgets[$index][$i] = $widget['id'];1044 $found = true;1045 break;1046 }1047 }1048 1049 if ( $found )1050 continue;1051 1052 unset($_sidebars_widgets[$index][$i]);1053 }1054 $_sidebars_widgets['array_version'] = 2;1055 $sidebars_widgets = $_sidebars_widgets;1056 unset($_sidebars_widgets);1057 1058 case 2 :1059 $sidebars_widgets = retrieve_widgets();1060 }1061 1012 } 1062 1013 … … 1220 1171 remove_theme_mod( 'sidebars_widgets' ); 1221 1172 } else { 1222 if ( ! is_array( $sidebars_widgets ) )1223 $sidebars_widgets = wp_get_sidebars_widgets();1173 if ( empty( $sidebars_widgets ) ) 1174 return; 1224 1175 1225 1176 $sidebars = array_keys($wp_registered_sidebars); … … 1235 1186 1236 1187 $_sidebars_widgets = array( 1237 'wp_inactive_widgets' => $sidebars_widgets['wp_inactive_widgets']1188 'wp_inactive_widgets' => !empty( $sidebars_widgets['wp_inactive_widgets'] ) ? $sidebars_widgets['wp_inactive_widgets'] : array() 1238 1189 ); 1239 1190 1240 1191 unset( $sidebars_widgets['wp_inactive_widgets'] ); 1241 1192 1242 foreach ( $wp_registered_sidebars as $id => $settings ) { 1243 if ( ! empty( $sidebars_widgets ) ) 1244 $_sidebars_widgets[$id] = array_shift( $sidebars_widgets ); 1245 } 1246 1247 if ( !empty($sidebars_widgets) ) { 1248 $orphaned = 0; 1249 1250 foreach ( $sidebars_widgets as $val ) { 1251 if ( is_array($val) && ! empty( $val ) ) 1252 $_sidebars_widgets['orphaned_widgets_' . ++$orphaned] = $val; 1253 } 1193 foreach ( $wp_registered_sidebars as $id => $settings ) 1194 $_sidebars_widgets[$id] = array_shift( $sidebars_widgets ); 1195 1196 $orphaned = 0; 1197 1198 foreach ( $sidebars_widgets as $val ) { 1199 if ( is_array($val) && ! empty( $val ) ) 1200 $_sidebars_widgets['orphaned_widgets_' . ++$orphaned] = $val; 1254 1201 } 1255 1202 }
Note: See TracChangeset
for help on using the changeset viewer.