ngg_upgrade

Upgrade the NextCellent database.

Description

ngg_upgrade(); 

Usage

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

Defined (1)

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

/admin/upgrade.php  
  1. function ngg_upgrade() { 
  2.  
  3. global $wpdb, $user_ID; 
  4.  
  5. // get the current user ID 
  6. get_currentuserinfo(); 
  7.  
  8. // in multisite environment the pointer $wpdb->nggpictures need to be set again 
  9. $wpdb->nggpictures = $wpdb->prefix . 'ngg_pictures'; 
  10. $wpdb->nggallery = $wpdb->prefix . 'ngg_gallery'; 
  11. $wpdb->nggalbum = $wpdb->prefix . 'ngg_album'; 
  12.  
  13. // Be sure that the tables exist, avoid case sensitive : http://dev.mysql.com/doc/refman/5.1/en/identifier-case-sensitivity.html 
  14. if ( $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->nggpictures'" ) ) { 
  15.  
  16. $wpdb->show_errors(); 
  17.  
  18. $installed_ver = get_option( 'ngg_db_version' ); 
  19. $ngg_options = get_option( ngg_options ); 
  20.  
  21. // v1.8.1 -> v1.8.2 
  22. if ( version_compare( $installed_ver, '1.8.2', '<' ) ) { 
  23.  
  24. //update them 
  25. $ngg_options['CSSfile'] = NGGALLERY_ABSPATH . 'css/nggallery.css'; 
  26.  
  27. //save them 
  28. update_option( ngg_options, $ngg_options ); 
  29.  
  30. // v1.8.2 -> v1.8.3 
  31. if ( version_compare( $installed_ver, '1.8.3', '<' ) ) { 
  32.  
  33. $booleans = array( 
  34. 'deleteImg',  
  35. 'swfUpload',  
  36. 'usePermalinks',  
  37. 'useMediaRSS',  
  38. 'usePicLens',  
  39. 'activateTags',  
  40. 'thumbfix',  
  41. 'imgBackup',  
  42. 'imgAutoResize',  
  43. 'galImages',  
  44. 'galShowSlide',  
  45. 'galNoPages',  
  46. 'galImgBrowser',  
  47. 'galHiddenImg',  
  48. 'galAjaxNav' 
  49. ); 
  50.  
  51. foreach ( $booleans as $value ) { 
  52. //Convert strings to primitive types in database to booleans 
  53. if ( $ngg_options[ $value ] === "1" ) { 
  54. $ngg_options[ $value ] = true; 
  55.  
  56. $ngg_options['galImages'] = (int) $ngg_options['galImages']; 
  57.  
  58.  
  59. //Add new slideshow parameters 
  60. $ngg_options['irLoop'] = true; 
  61. $ngg_options['irDrag'] = true; 
  62. $ngg_options['irNavigation'] = false; 
  63. $ngg_options['irNavigationDots'] = false; 
  64. $ngg_options['irAutoplay'] = true; 
  65. $ngg_options['irAutoDim'] = false; 
  66. $ngg_options['irAutoplayHover'] = true; 
  67. $ngg_options['irNumber'] = 20; 
  68. $ngg_options['irClick'] = true; 
  69. $ngg_options['silentUpgrade'] = false; 
  70.  
  71. //Convert color 
  72. $ngg_options['wmColor'] = '#' . $ngg_options['wmColor']; 
  73.  
  74. //Delete the old ones 
  75. unset( $ngg_options['enableIR'], $ngg_options['irURL'], $ngg_options['irXHTMLvalid'], $ngg_options['irAudio'], $ngg_options['irShuffle'], $ngg_options['irLinkfromdisplay'], $ngg_options['irShownavigation'], $ngg_options['irShowicons'], $ngg_options['irWatermark'], $ngg_options['irOverstretch'], $ngg_options['irTransition'], $ngg_options['irKenburns'], $ngg_options['irBackcolor'], $ngg_options['irFrontcolor'], $ngg_options['irLightcolor'], $ngg_options['irScreencolor'] ); 
  76.  
  77. //Update the options. 
  78. update_option( ngg_options, $ngg_options ); 
  79.  
  80.  
  81. // update the database version 
  82. update_option( "ngg_db_version", NGG_DBVERSION ); 
  83.  
  84. } else { 
  85. throw new Exception( __( 'Could not find NextCellent Gallery database tables, upgrade failed!', 'nggallery' ) );