menu.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?php if ( ! defined( 'ABSPATH' ) ) exit;
  2. /**
  3. * Register our step processing admin page.
  4. *
  5. * @since 2.7.6
  6. * @return void
  7. */
  8. function nf_register_step_processing_page() {
  9. // Register our admin page
  10. $admin_page = add_submenu_page( NULL, __( 'Ninja Forms Processing', 'ninja-forms' ), __( 'Processing', 'ninja-forms' ), apply_filters( 'ninja_forms_admin_menu_capabilities', 'manage_options' ), 'nf-processing', 'nf_output_step_processing_page' );
  11. add_action( 'admin_print_styles-' . $admin_page, 'nf_step_processing_css' );
  12. add_action( 'admin_print_styles-' . $admin_page, 'nf_step_processing_js' );
  13. }
  14. add_action( 'admin_menu', 'nf_register_step_processing_page' );
  15. /**
  16. * Enqueue our step processing CSS.
  17. *
  18. * @since 2.7.6
  19. * @return void
  20. */
  21. function nf_step_processing_css() {
  22. wp_enqueue_style( 'jquery-smoothness', Ninja_Forms::$url .'deprecated/css/smoothness/jquery-smoothness.css');
  23. }
  24. /**
  25. * Enqueue our step processing JS.
  26. *
  27. * @since 2.7.6
  28. * @return void
  29. */
  30. function nf_step_processing_js() {
  31. wp_enqueue_script( 'nf-processing',
  32. Ninja_Forms::$url . 'deprecated/assets/js/dev/step-processing.js',
  33. array( 'jquery', 'jquery-ui-core', 'jquery-ui-sortable', 'jquery-ui-datepicker', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-progressbar' ) );
  34. $step_labels = apply_filters( 'nf_step_processing_labels', array(
  35. 'Lacing Our Tabis',
  36. 'Cleaning The Dojo',
  37. 'Doing Splits',
  38. 'Buffing Bo Staff',
  39. 'Intimidating Gaze',
  40. 'Sparring',
  41. 'Packing Smoke Bombs',
  42. 'Polishing Shuriken',
  43. 'Throwing Sais',
  44. 'Calling Our Mom',
  45. 'Practicing Katas',
  46. 'Swinging Nunchucks',
  47. 'Sharpening Swords',
  48. 'Ironing Ninja Gi',
  49. 'Eating Breakfast',
  50. 'Cutting Stuff',
  51. 'Doing Dishes',
  52. 'Climbing Walls'
  53. ) );
  54. wp_localize_script( 'nf-processing', 'nf_processing', array( 'step_labels' => $step_labels ) );
  55. }
  56. /**
  57. * Output our step processing admin page.
  58. *
  59. * @since 2.7.6
  60. * @return void
  61. */
  62. function nf_output_step_processing_page() {
  63. $page_title = isset ( $_REQUEST['title'] ) ? urldecode( esc_html ( $_REQUEST['title'] ) ) : __( 'Ninja Forms - Processing', 'ninja-forms' );
  64. ?>
  65. <style>
  66. .ui-progressbar {
  67. position: relative;
  68. width: 800px;
  69. max-width: 100%;
  70. height: 20px;
  71. }
  72. .progress-label {
  73. line-height: 12px;
  74. position: absolute;
  75. left: 40%;
  76. top: 4px;
  77. font-weight: bold;
  78. text-shadow: 1px 1px 0 #fff;
  79. }
  80. .ui-progressbar-value {
  81. /*background-size: 100% auto;*/
  82. background-color: #FFF;
  83. background-repeat: repeat;
  84. background-image: url(<?php echo NF_PLUGIN_URL . 'assets/img/pbar-ani.gif'; ?>);
  85. }
  86. </style>
  87. <script type="text/javascript">
  88. <?php
  89. if ( isset ( $_REQUEST['action'] ) && ! empty ( $_REQUEST['action'] ) ) {
  90. $action = __( 'Loading...', 'ninja-forms' );
  91. ?>
  92. var nfProcessingAction = 'nf_<?php echo esc_html( $_REQUEST['action'] ); ?>';
  93. <?php
  94. } else {
  95. $action = __( 'No Action Specified...', 'ninja-forms' );
  96. ?>
  97. var nfProcessingAction = 'none';
  98. <?php
  99. }
  100. $tmp_array = array();
  101. $url_params = parse_url( esc_url_raw( add_query_arg( array() ) ) );
  102. $query = $url_params['query'];
  103. $query = parse_str( $query, $tmp_array );
  104. unset ( $tmp_array['action'] );
  105. unset ( $tmp_array['page'] );
  106. ?>
  107. var nfProcessingArgs = <?php echo json_encode( $tmp_array ); ?>
  108. </script>
  109. <?php
  110. ?>
  111. <div class="wrap">
  112. <h2><?php echo $page_title ?></h2>
  113. <div id="nf-upgrade-status">
  114. <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>
  115. <div id="progressbar">
  116. <div class="progress-label">
  117. <?php echo $action; ?>
  118. </div>
  119. </div>
  120. </div>
  121. </div>
  122. <!-- DISPLAY ERRORS -->
  123. <div id="nf-upgrade-errors" class="hidden nf-upgrade-errors">
  124. <h3 class="nf-upgrade-errors-header">Error Log</h3>
  125. <ul class="nf-upgrade-errors-list"></ul>
  126. </div>
  127. <?php
  128. }