NF_Upgrade

Class NF_Upgrade.

Defined (1)

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

/deprecated/includes/admin/upgrades/class-upgrade.php  
  1. abstract class NF_Upgrade 
  2. /** 
  3. * @var name 
  4. * The name is the unique identifier for the upgrade. 
  5. */ 
  6. public $name; 
  7.  
  8.  
  9.  
  10. /** 
  11. * @var priority 
  12. * The priority determines the oder in which the upgrades are run. 
  13. * Priorities are compared as version numbers that corresponds to when they were introduced. 
  14. */ 
  15. public $priority; 
  16.  
  17.  
  18.  
  19. /** 
  20. * @var decription 
  21. * The description will be displayed for the user in the Upgrade Handler admin screen. 
  22. */ 
  23. public $description; 
  24.  
  25.  
  26.  
  27. /** 
  28. * @var total_steps 
  29. * The total number of steps that need to be processed. 
  30. */ 
  31. public $total_steps; 
  32.  
  33.  
  34.  
  35. /** 
  36. * @var args 
  37. * The args variable is passes between calls. 
  38. */ 
  39. public $args = array(); 
  40.  
  41.  
  42.  
  43. /** 
  44. * @var errors 
  45. * The errors property is used to store errors for the Upgrade Handler to reference. 
  46. */ 
  47. public $errors = array(); 
  48.  
  49.  
  50.  
  51. /** 
  52. * Constructor 
  53. */ 
  54. public function __construct() 
  55. $this->nice_name = ucwords( str_replace( '_', ' ', $this->name) ); 
  56. $this->description = __( $this->description, 'ninja-forms' ); 
  57.  
  58.  
  59.  
  60. /** 
  61. * Loading 
  62. * The loading method is used to setup the upgrade and is called by the Upgrade Handler. 
  63. */ 
  64. abstract function loading(); 
  65.  
  66.  
  67.  
  68. /** 
  69. * Step 
  70. * @param $step 
  71. * The step method will be called by the parent _step method. 
  72. */ 
  73. abstract public function step( $step ); 
  74.  
  75.  
  76.  
  77. /** 
  78. * Complete 
  79. * The complete method will be called by the Upgrade Handler when all steps are complete. 
  80. */ 
  81. abstract public function complete(); 
  82.  
  83.  
  84.  
  85. /** 
  86. * Is Complete 
  87. * The isComplete method checks to see if the upgrade has already been completed. 
  88. */ 
  89. abstract public function isComplete(); 
  90.  
  91.  
  92.  
  93. /** 
  94. * _Step 
  95. * @param $step 
  96. * The _step method is called by the Upgrade Handler and is a middleman for step. 
  97. */ 
  98. public function _step( $step ) 
  99. $last_step = $this->getLastStep(); 
  100.  
  101. if( $step < $last_step ) { 
  102. $step = $last_step; 
  103.  
  104. $this->_beforeStep( $step ); 
  105. $this->step( $step ); 
  106. $this->_afterStep( $step ); 
  107. $this->setLastStep( $step ); 
  108.  
  109.  
  110.  
  111. /** 
  112. * Before Step 
  113. * @param $step 
  114. * The _beforeStep method is called by the _step method before calling the extended step method. 
  115. */ 
  116. public function _beforeStep( $step ) 
  117. // This method is optionally extended and is intentionally left blank. 
  118.  
  119.  
  120.  
  121. /** 
  122. * After Step 
  123. * @param $step 
  124. * The _afterStep method is called by the _step method after calling the extended step method. 
  125. */ 
  126. public function _afterStep( $step ) 
  127. // This method is optionally extended and is intentionally left blank. 
  128.  
  129.  
  130.  
  131. /** 
  132. * Get Last Step 
  133. * Gets the last step processed from the wp_options table. 
  134. * @return mixed 
  135. */ 
  136. public function getLastStep() 
  137. return get_option( 'nf_upgrade_' . $this->name . '_last_step', 0 ); 
  138.  
  139.  
  140.  
  141. /** 
  142. * Set Last Step 
  143. * Updates the value in the wp_options table with the last step processed. 
  144. * @param $step 
  145. */ 
  146. public function setLastStep( $step ) 
  147. update_option( 'nf_upgrade_' . $this->name . '_last_step', $step ); 
  148.