gmb_upgrades_screen

Render Upgrades Screen.

Description

gmb_upgrades_screen(); 

Usage

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

Defined (2)

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

/includes/admin/upgrades/upgrades.php  
  1. function gmb_upgrades_screen() { 
  2.  
  3. $action = isset( $_GET['gmb-upgrade'] ) ? sanitize_text_field( $_GET['gmb-upgrade'] ) : ''; 
  4. $step = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1; 
  5. $total = isset( $_GET['total'] ) ? absint( $_GET['total'] ) : false; 
  6. $custom = isset( $_GET['custom'] ) ? absint( $_GET['custom'] ) : 0; 
  7. $number = isset( $_GET['number'] ) ? absint( $_GET['number'] ) : 100; 
  8. $steps = round( ( $total / $number ), 0 ); 
  9.  
  10. $doing_upgrade_args = array( 
  11. 'page' => 'gmb-upgrades',  
  12. 'gmb-upgrade' => $action,  
  13. 'step' => $step,  
  14. 'total' => $total,  
  15. 'custom' => $custom,  
  16. 'steps' => $steps 
  17. ); 
  18. update_option( 'gmb_doing_upgrade', $doing_upgrade_args ); 
  19. if ( $step > $steps ) { 
  20. // Prevent a weird case where the estimate was off. Usually only a couple. 
  21. $steps = $step; 
  22. ?> 
  23. <div class="wrap"> 
  24. <h2><?php _e( 'Maps Builder - Upgrade', 'gmb' ); ?></h2> 
  25.  
  26. <?php if ( ! empty( $action ) ) : ?> 
  27.  
  28. <div id="gmb-upgrade-status"> 
  29. <p><?php _e( 'The upgrade process has started, please be patient. This could take several minutes. You will be automatically redirected when the upgrade is finished.', 'gmb' ); ?></p> 
  30.  
  31. <?php if ( ! empty( $total ) ) : ?> 
  32. <p> 
  33. <strong><?php printf( __( 'Step %d of approximately %d running', 'gmb' ), $step, $steps ); ?></strong> 
  34. </p> 
  35. <?php endif; ?> 
  36. </div> 
  37. <script type="text/javascript"> 
  38. setTimeout( function () { 
  39. document.location.href = "index.php?gmb_action=<?php echo $action; ?>&step=<?php echo $step; ?>&total=<?php echo $total; ?>&custom=<?php echo $custom; ?>"; 
  40. }, 250 ); 
  41. </script> 
  42.  
  43. <?php else : ?> 
  44.  
  45. <div id="gmb-upgrade-status" class="updated" style="margin-top:15px;"> 
  46. <p style="margin-bottom:8px;"> 
  47. <?php _e( 'The upgrade process has started, please do not close yourbrowseror refresh. This could take several minutes. You will be automatically redirected when the upgrade has finished.', 'gmb' ); ?> 
  48. <img src="<?php echo GMB_PLUGIN_URL . '/assets/img/loading.gif'; ?>" id="gmb-upgrade-loader" style="position:relative; top:3px;" /> 
  49. </p> 
  50. </div> 
  51. <script type="text/javascript"> 
  52. jQuery( document ).ready( function () { 
  53. // Trigger upgrades on page load 
  54. var data = {action: 'gmb_trigger_upgrades'}; 
  55. var el_upgrade_status = jQuery( '#gmb-upgrade-status' ); 
  56.  
  57. //Trigger via AJAX 
  58. jQuery.post( ajaxurl, data, function ( response ) { 
  59.  
  60. //Uncomment for debugging 
  61. // jQuery( '#gmb-upgrade-status' ).after( response ); 
  62.  
  63. //Success Message 
  64. if ( response == 'complete' ) { 
  65.  
  66. el_upgrade_status.hide(); 
  67. el_upgrade_status.after( '<div class="updated"><p>The upgrade process has completed successfully. Hooray! You will now be redirected back to your previous page.</p></div>' ); 
  68.  
  69. //Send user back to prev page 
  70. setTimeout( function () { 
  71. history.back(); 
  72. }, 4000 ); 
  73.  
  74. } ); 
  75. } ); 
  76. </script> 
  77.  
  78. <?php endif; ?> 
  79.  
  80. </div> 
  81. <?php 
/vendor/wordimpress/maps-builder-core/includes/admin/upgrades/upgrade-functions.php  
  1. function gmb_upgrades_screen() { 
  2.  
  3. $action = isset( $_GET['gmb-upgrade'] ) ? sanitize_text_field( $_GET['gmb-upgrade'] ) : ''; 
  4. $step = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1; 
  5. $total = isset( $_GET['total'] ) ? absint( $_GET['total'] ) : false; 
  6. $custom = isset( $_GET['custom'] ) ? absint( $_GET['custom'] ) : 0; 
  7. $number = isset( $_GET['number'] ) ? absint( $_GET['number'] ) : 100; 
  8. $steps = round( ( $total / $number ), 0 ); 
  9.  
  10.  
  11. $doing_upgrade_args = array( 
  12. 'page' => 'gmb-upgrades',  
  13. 'gmb-upgrade' => $action,  
  14. 'step' => $step,  
  15. 'total' => $total,  
  16. 'custom' => $custom,  
  17. 'steps' => $steps 
  18. ); 
  19. update_option( 'gmb_doing_upgrade', $doing_upgrade_args ); 
  20. if ( $step > $steps ) { 
  21. // Prevent a weird case where the estimate was off. Usually only a couple. 
  22. $steps = $step; 
  23. } ?> 
  24. <div class="wrap"> 
  25. <h2><?php _e( 'Maps Builder - Upgrade', 'google-maps-builder' ); ?></h2> 
  26.  
  27. <?php if ( ! empty( $action ) ) : ?> 
  28.  
  29. <div id="gmb-upgrade-status"> 
  30. <p><?php _e( 'The upgrade process has started, please be patient. This could take several minutes. You will be automatically redirected when the upgrade is finished.', 'google-maps-builder' ); ?></p> 
  31.  
  32. <?php if ( ! empty( $total ) ) : ?> 
  33. <p> 
  34. <strong><?php printf( __( 'Step %d of approximately %d running', 'google-maps-builder' ), $step, $steps ); ?></strong> 
  35. </p> 
  36. <?php endif; ?> 
  37. </div> 
  38. <script type="text/javascript"> 
  39. setTimeout(function () { 
  40. document.location.href = "index.php?gmb_action=<?php echo $action; ?>&step=<?php echo $step; ?>&total=<?php echo $total; ?>&custom=<?php echo $custom; ?>"; 
  41. }, 250); 
  42. </script> 
  43.  
  44. <?php else : ?> 
  45.  
  46. <div id="gmb-upgrade-status" class="updated" style="margin-top:15px;"> 
  47. <p style="margin-bottom:8px;"> 
  48. <?php _e( 'The upgrade process has started, please do not close yourbrowseror refresh. This could take several minutes. You will be automatically redirected when the upgrade has finished.', 'google-maps-builder' ); ?> 
  49. <img src="<?php echo GMB_PLUGIN_URL . '/assets/img/loading.gif'; ?>" id="gmb-upgrade-loader" style="position:relative; top:3px;"/> 
  50. </p> 
  51. </div> 
  52. <script type="text/javascript"> 
  53. jQuery(document).ready(function () { 
  54. // Trigger upgrades on page load 
  55. var data = {action: 'gmb_trigger_upgrades'}; 
  56. var el_upgrade_status = jQuery('#gmb-upgrade-status'); 
  57.  
  58. //Trigger via AJAX 
  59. jQuery.post(ajaxurl, data, function (response) { 
  60.  
  61. //Uncomment for debugging 
  62. // jQuery( '#gmb-upgrade-status' ).after( response ); 
  63.  
  64. //Success Message 
  65. if (response == 'complete') { 
  66.  
  67. el_upgrade_status.hide(); 
  68. el_upgrade_status.after('<div class="updated"><p><strong><?php _e( 'Upgrade Successful:', 'google-maps-builder' ); ?></strong> <?php _e( 'The upgrade process has completed successfully. You will now be redirected to your admin dashboard.', 'google-maps-builder' ); ?></p></div>'); 
  69.  
  70. //Send user back to prev page 
  71. setTimeout(function () { 
  72. window.location = '<?php echo admin_url(); ?>'; 
  73. }, 4000); 
  74.  
  75. }); 
  76. }); 
  77. </script> 
  78.  
  79. <?php endif; ?> 
  80.  
  81. </div> 
  82. <?php