upgrades.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php if ( ! defined( 'ABSPATH' ) ) exit;
  2. /**
  3. * Upgrade Screen
  4. *
  5. * @package Ninja Forms
  6. * @subpackage Admin/Upgrades
  7. * @copyright Copyright (c) 2014, WP Ninjas
  8. * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
  9. * @since 2.7
  10. */
  11. // Exit if accessed directly
  12. if ( !defined( 'ABSPATH' ) ) exit;
  13. /**
  14. * Render Upgrades Screen
  15. *
  16. * @since 2.7
  17. * @return void
  18. */
  19. function nf_upgrades_screen() {
  20. $action = isset( $_GET['nf-upgrade'] ) ? sanitize_text_field( $_GET['nf-upgrade'] ) : '';
  21. $step = isset( $_GET['step'] ) ? absint( $_GET['step'] ) : 1;
  22. $total = isset( $_GET['total'] ) ? absint( $_GET['total'] ) : false;
  23. $custom = isset( $_GET['custom'] ) ? $_GET['custom'] : 0;
  24. $form_id = isset( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : 0;
  25. if ( is_string( $custom ) ) {
  26. $custom = urlencode( $custom );
  27. }
  28. ?>
  29. <div class="wrap">
  30. <h2><?php _e( 'Ninja Forms - Processing', 'ninja-forms' ); ?></h2>
  31. <?php if( ! empty( $action ) ) : ?>
  32. <div id="nf-upgrade-status">
  33. <p><?php _e( 'The process has started, please be patient. This could take several minutes. You will be automatically redirected when the process is finished.', 'ninja-forms' ); ?></p>
  34. <?php if( ! empty( $total ) ) : ?>
  35. <p><strong><?php printf( __( 'Step %d of approximately %d running', 'ninja-forms' ), $step, $total + 1 ); ?></strong>
  36. <span class="spinner" id="nf-upgrade-loader"/></span></p>
  37. <?php endif; ?>
  38. </div>
  39. <script type="text/javascript">
  40. document.location.href = "index.php?nf_action=<?php echo $action; ?>&step=<?php echo $step; ?>&total=<?php echo $total; ?>&custom=<?php echo $custom; ?>&form_id=<?php echo $form_id; ?>";
  41. </script>
  42. <?php else : ?>
  43. <div id="nf-upgrade-status">
  44. <p>
  45. <?php _e( 'The process has started, please be patient. This could take several minutes. You will be automatically redirected when the process is finished.', 'edd' ); ?>
  46. <span class="spinner" id="nf-upgrade-loader"/></span>
  47. </p>
  48. </div>
  49. <script type="text/javascript">
  50. jQuery( document ).ready( function() {
  51. // Trigger upgrades on page load
  52. var data = { action: 'edd_trigger_upgrades' };
  53. jQuery.post( ajaxurl, data, function (response) {
  54. if( response == 'complete' ) {
  55. jQuery('#nf-upgrade-loader').hide();
  56. //document.location.href = 'index.php?page=edd-about'; // Redirect to the welcome page
  57. }
  58. });
  59. });
  60. </script>
  61. <?php endif; ?>
  62. </div>
  63. <?php
  64. }