bp_docs_do_upgrade

Upgrade class.

Description

bp_docs_do_upgrade(); 

Usage

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

Defined (1)

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

/includes/upgrade.php  
  1. function bp_docs_do_upgrade() { 
  2. $upgrade_status = bp_get_option( 'bp_docs_upgrade' ); 
  3. if ( '' == $upgrade_status ) { 
  4. $upgrade_status = array( 
  5. 'upgrades' => array(),  
  6. 'refresh_url' => '',  
  7. 'message' => '',  
  8. ); 
  9. $upgrades = bp_docs_upgrade_check(); 
  10.  
  11. foreach ( $upgrades as $upgrade ) { 
  12. $func = 'bp_docs_upgrade_' . str_replace( '.', '_', $upgrade ); 
  13. if ( function_exists( $func ) ) { 
  14. $upgrade_status['upgrades'][ $func ] = array( 
  15. 'last' => 0,  
  16. 'done' => 0,  
  17. 'total' => 0,  
  18. ); 
  19.  
  20. // Grab the next available upgrade 
  21. foreach ( $upgrade_status['upgrades'] as $ufunc => $udata ) { 
  22. $the_ufunc = $ufunc; 
  23. $the_udata = $udata; 
  24. break; 
  25.  
  26. if ( isset( $ufunc ) && isset( $udata ) ) { 
  27. if ( intval( $udata['done'] ) <= intval( $udata['total'] ) ) { 
  28. $new_udata = call_user_func_array( $ufunc, array( $udata ) ); 
  29. $upgrade_status['upgrades'][ $ufunc ] = $new_udata; 
  30.  
  31. if ( isset( $new_udata['message'] ) ) { 
  32. $upgrade_status['message'] = $new_udata['message']; 
  33.  
  34. if ( isset( $new_udata['refresh_url'] ) ) { 
  35. $upgrade_status['refresh_url'] = $new_udata['refresh_url']; 
  36. } else { 
  37. unset( $upgrade_status['upgrades'][ $ufunc ] ); 
  38.  
  39. } else { 
  40. $upgrade_status['refresh_url'] = add_query_arg( array( 
  41. 'bp_docs_upgraded' => 1,  
  42. ), admin_url() ); 
  43.  
  44. bp_update_option( 'bp_docs_upgrade', $upgrade_status );