NF_UpgradeHandlerPage

The Ninja Forms NF UpgradeHandlerPage class.

Defined (1)

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

/deprecated/includes/admin/upgrades/upgrade-handler-page.php  
  1. class NF_UpgradeHandlerPage 
  2. public $slug = 'nf-upgrade-handler'; 
  3.  
  4. public function __construct() 
  5. add_action( 'admin_menu', array( $this, 'register' ) ); 
  6. add_action( 'admin_notices', array( $this, 'show_upgrade_notices' ) ); 
  7.  
  8. public function register() 
  9. $page = add_submenu_page( 
  10. /** Parent Slug */ NULL,  
  11. /** Page Title */ __( 'Ninja Forms Upgrade', 'ninja-forms' ),  
  12. /** Menu Title */ __( 'Upgrade', 'ninja-forms' ),  
  13. /** Capabilities */ apply_filters( 'ninja_forms_admin_menu_capabilities', 'manage_options' ),  
  14. /** Menu Slug */ $this->slug,  
  15. /** Function */ array( $this, 'display' ) 
  16. ); 
  17.  
  18. add_action( 'admin_print_styles-' . $page, array( $this, 'scripts' ) ); 
  19. add_action( 'admin_print_styles-' . $page, array( $this, 'styles' ) ); 
  20. add_action( 'admin_print_styles-' . $page, 'ninja_forms_admin_js'); 
  21.  
  22. public function display() 
  23. include 'upgrade-handler-page.html.php'; 
  24.  
  25. public function scripts() 
  26. if (defined('NINJA_FORMS_JS_DEBUG') && NINJA_FORMS_JS_DEBUG) { 
  27. $suffix = ''; 
  28. $src = 'dev'; 
  29. } else { 
  30. $suffix = '.min'; 
  31. $src = 'min'; 
  32.  
  33. wp_enqueue_script( 
  34. /** Handle */ $this->slug,  
  35. /** Source */ NF_PLUGIN_URL . 'assets/js/' . $src . '/nf-upgrade-handler' . $suffix . '.js',  
  36. /** Dependencies */ array( 'jquery', 'jquery-ui-core', 'jquery-ui-progressbar' ),  
  37. /** Version */ '0.0.1',  
  38. /** In Footer */ TRUE 
  39. ); 
  40.  
  41. $upgrades = NF_UpgradeHandler()->upgrades; 
  42. $first_upgrade = null; 
  43. foreach( $upgrades as $upgrade ) { 
  44.  
  45. if ( ! $upgrade->isComplete() ) { 
  46. $first_upgrade = $upgrade->name; 
  47. break; 
  48.  
  49.  
  50. wp_localize_script( 
  51. $this->slug,  
  52. 'nfUpgradeHandler',  
  53. array( 
  54. 'upgrade' => $first_upgrade,  
  55. 'nf_upgrade_complete_title' => __( 'Upgrades Complete', 'ninja-forms' ),  
  56. ); 
  57.  
  58.  
  59. public function styles() 
  60. wp_enqueue_style( 
  61. /** Handle */ $this->slug,  
  62. /** Source */ NF_PLUGIN_URL . 'assets/css/nf-upgrade-handler.css' 
  63. ); 
  64.  
  65. wp_enqueue_style( 
  66. /** Handle */ 'ninja-forms-admin',  
  67. /** Source */ NF_PLUGIN_URL . 'css/ninja-forms-admin.css' 
  68. ); 
  69.  
  70. wp_enqueue_style( 
  71. /** Handle */ 'ninja-forms-admin',  
  72. /** Source */ NF_PLUGIN_URL . 'assets/css/admin-modal.css' 
  73. ); 
  74.  
  75. public function show_upgrade_notices() 
  76. // Don't show notices on the upgrade handler page. 
  77. if ( isset ( $_GET['page'] ) && $this->slug == $_GET['page'] ) { 
  78. return; 
  79.  
  80. $upgrades = NF_UpgradeHandler()->upgrades; 
  81.  
  82. $upgrade_count = 0; 
  83.  
  84. foreach( $upgrades as $upgrade ) { 
  85.  
  86. if( ! $upgrade->isComplete() ) { 
  87. $upgrade_count++; 
  88.  
  89.  
  90. if( 0 < $upgrade_count ) { 
  91. printf( 
  92. '<div class="update-nag"><p>' . __('Ninja Forms needs to process %s upgrade(s). This may take a few minutes to complete. %sStart Upgrade%s', 'ninja-forms') . '</p></div>',  
  93. $upgrade_count,  
  94. '<a class="button button-primary" href="' . admin_url('admin.php?page=nf-upgrade-handler') . '">',  
  95. '</a>' 
  96. );