Guest User

Untitled

a guest
Oct 20th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. private $options_default = array(
  2. 'beta_version' => false,
  3. 'db_version' => 4,
  4. 'convertion_time' => 0
  5. );
  6.  
  7. public function __construct() {
  8. // init
  9. add_action( 'init', array( $this, 'options_upgrade' ) );
  10. }
  11.  
  12. function options_upgrade() {
  13. $options_old = get_option( 'your_plugins_name' );
  14. if ( $options_old[ 'db_version' ] < $this->options_default[ 'db_version' ] ) {
  15. $options_old_usable = array_intersect_key( $options_old, $this->options_default );
  16. $options_new = array_merge( $this->options_default, $options_old_usable );
  17. $options_new[ 'db_version' ] = $this->options_default[ 'db_version' ];
  18. update_option( 'your_plugins_name', $options_new );
  19. }
  20. }
Add Comment
Please, Sign In to add comment