upgrade_330

Execute changes made in WordPress 3.3.

Description

upgrade_330(); 

Usage

  1. if ( !function_exists( 'upgrade_330' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/upgrade.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = upgrade_330(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/upgrade.php  
  1. function upgrade_330() { 
  2. global $wp_current_db_version, $wpdb, $wp_registered_widgets, $sidebars_widgets; 
  3.  
  4. if ( $wp_current_db_version < 19061 && wp_should_upgrade_global_tables() ) { 
  5. $wpdb->query( "DELETE FROM $wpdb->usermeta WHERE meta_key IN ('show_admin_bar_admin', 'plugins_last_view')" ); 
  6.  
  7. if ( $wp_current_db_version >= 11548 ) 
  8. return; 
  9.  
  10. $sidebars_widgets = get_option( 'sidebars_widgets', array() ); 
  11. $_sidebars_widgets = array(); 
  12.  
  13. if ( isset($sidebars_widgets['wp_inactive_widgets']) || empty($sidebars_widgets) ) 
  14. $sidebars_widgets['array_version'] = 3; 
  15. elseif ( !isset($sidebars_widgets['array_version']) ) 
  16. $sidebars_widgets['array_version'] = 1; 
  17.  
  18. switch ( $sidebars_widgets['array_version'] ) { 
  19. case 1 : 
  20. foreach ( (array) $sidebars_widgets as $index => $sidebar ) 
  21. if ( is_array($sidebar) ) 
  22. foreach ( (array) $sidebar as $i => $name ) { 
  23. $id = strtolower($name); 
  24. if ( isset($wp_registered_widgets[$id]) ) { 
  25. $_sidebars_widgets[$index][$i] = $id; 
  26. continue; 
  27. $id = sanitize_title($name); 
  28. if ( isset($wp_registered_widgets[$id]) ) { 
  29. $_sidebars_widgets[$index][$i] = $id; 
  30. continue; 
  31.  
  32. $found = false; 
  33.  
  34. foreach ( $wp_registered_widgets as $widget_id => $widget ) { 
  35. if ( strtolower($widget['name']) == strtolower($name) ) { 
  36. $_sidebars_widgets[$index][$i] = $widget['id']; 
  37. $found = true; 
  38. break; 
  39. } elseif ( sanitize_title($widget['name']) == sanitize_title($name) ) { 
  40. $_sidebars_widgets[$index][$i] = $widget['id']; 
  41. $found = true; 
  42. break; 
  43.  
  44. if ( $found ) 
  45. continue; 
  46.  
  47. unset($_sidebars_widgets[$index][$i]); 
  48. $_sidebars_widgets['array_version'] = 2; 
  49. $sidebars_widgets = $_sidebars_widgets; 
  50. unset($_sidebars_widgets); 
  51.  
  52. case 2 : 
  53. $sidebars_widgets = retrieve_widgets(); 
  54. $sidebars_widgets['array_version'] = 3; 
  55. update_option( 'sidebars_widgets', $sidebars_widgets );