gpr_upgrades_screen

Render Upgrades Screen.

Description

gpr_upgrades_screen(); 

Usage

  1. if ( !function_exists( 'gpr_upgrades_screen' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-places-reviews/inc/upgrades/upgrades.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = gpr_upgrades_screen(); 
  7.  

Defined (1)

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

/inc/upgrades/upgrades.php  
  1. function gpr_upgrades_screen() { 
  2. $action = isset( $_GET['gpr-upgrade'] ) ? sanitize_text_field( $_GET['gpr-upgrade'] ) : ''; 
  3. $step = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1; 
  4. $total = isset( $_GET['total'] ) ? absint( $_GET['total'] ) : false; 
  5. $custom = isset( $_GET['custom'] ) ? absint( $_GET['custom'] ) : 0; 
  6. $number = isset( $_GET['number'] ) ? absint( $_GET['number'] ) : 100; 
  7. $steps = round( ( $total / $number ), 0 ); 
  8.  
  9. $doing_upgrade_args = array( 
  10. 'page' => 'gpr-upgrades',  
  11. 'gpr-upgrade' => $action,  
  12. 'step' => $step,  
  13. 'total' => $total,  
  14. 'custom' => $custom,  
  15. 'steps' => $steps 
  16. ); 
  17. update_option( 'gpr_doing_upgrade', $doing_upgrade_args ); 
  18. if ( $step > $steps ) { 
  19. // Prevent a weird case where the estimate was off. Usually only a couple. 
  20. $steps = $step; 
  21. ?> 
  22. <div class="wrap"> 
  23. <h2><?php _e( 'Google Places Review - Upgrade', 'google-places-reviews' ); ?></h2> 
  24.  
  25. <?php if ( ! empty( $action ) ) : ?> 
  26.  
  27. <div id="gpr-upgrade-status"> 
  28. <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-places-reviews' ); ?></p> 
  29.  
  30. <?php if ( ! empty( $total ) ) : ?> 
  31. <p> 
  32. <strong><?php printf( __( 'Step %d of approximately %d running', 'google-places-reviews' ), $step, $steps ); ?></strong> 
  33. </p> 
  34. <?php endif; ?> 
  35. </div> 
  36. <script type="text/javascript"> 
  37. setTimeout( function () { 
  38. document.location.href = "index.php?gpr_action=<?php echo $action; ?>&step=<?php echo $step; ?>&total=<?php echo $total; ?>&custom=<?php echo $custom; ?>"; 
  39. }, 250 ); 
  40. </script> 
  41.  
  42. <?php else : ?> 
  43.  
  44. <div id="gpr-upgrade-status" class="updated"> 
  45. <p> 
  46. <?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-places-reviews' ); ?> 
  47. <img src="<?php echo GPR_PLUGIN_URL . '/assets/images/loading.gif'; ?>" id="gpr-upgrade-loader" /> 
  48. </p> 
  49. </div> 
  50. <script type="text/javascript"> 
  51. jQuery( document ).ready( function () { 
  52. // Trigger upgrades on page load 
  53. var data = {action: 'gpr_trigger_upgrades'}; 
  54. var el_upgrade_status = jQuery( '#gpr-upgrade-status' ); 
  55.  
  56. jQuery.post( ajaxurl, data, function ( response ) { 
  57.  
  58. if ( response == 'complete' ) { 
  59.  
  60. el_upgrade_status.hide(); 
  61. el_upgrade_status.after( '<div class="updated"><p>Yippee! The upgrade process has completed successfully. Please check your widgets to ensure they appear as you expect. You will now be redirected back to your previous page.</p></div>' ); 
  62.  
  63. //Send user back to prev page 
  64. setTimeout(function() {history.back();}, 4000); 
  65.  
  66. } ); 
  67. } ); 
  68. </script> 
  69.  
  70. <?php endif; ?> 
  71.  
  72. </div> 
  73. <?php