<?php

/**
 * Management of the Lockee plugin updates
 */
class Lockee_Update extends Lockee_Singleton
{
  /**
   * Initialize the update functionality
   */
  protected function init() {}

  /**
   * Handle the plugin update process
   */
  public function handle_update($upgrader_object, $options)
  {
    if ($options['action'] === 'update' && $options['type'] === 'plugin') {
      foreach ($options['plugins'] as $plugin) {
        if ($plugin === plugin_basename(dirname(__FILE__, 2))) {
          require_once plugin_dir_path(__FILE__) . 'class-lockee-post-types.php';
          Lockee_Post_Types::maybe_migrate_lock_to_lockee_lock();
          Lockee_Post_Types::update_rewrite_rules_static();
          break;
        }
      }
    }
  }
}
