/**
	 * private construct to enforce singleton
	 */
	private function __construct() {
		$this->update_settings();

		/**
		 * Include the base provider class here, so that other plugins can also extend it.
		 */
		require_once( 'providers/class.two-factor-provider.php' );

		/**
		 * Include the application passwords system.
		 */
		require_once( 'class.application-passwords.php' );
		Application_Passwords::add_hooks();

		if ( is_admin() ) {
			// Always instantiate enabled providers in admin for use in settings, etc
			add_action( 'init', array( $this, 'get_enabled_provider_instances' ) );
		} else {
			add_action( 'init', array( $this, 'get_all_providers' ) );
		}

		// Sanitize options
		add_filter( "sanitize_option_{$this->_setting_name}", array( $this, 'sanitize_module_input' ) );

		// Reload options after they are saved
		add_action( "add_option_{$this->_setting_name}",         array( $this, 'update_settings' ), null, 0 );
		add_action( "update_option_{$this->_setting_name}",      array( $this, 'update_settings' ), null, 0 );
		add_action( "update_site_option_{$this->_setting_name}", array( $this, 'update_settings' ), null, 0 );

	}
 /**
  * Generates content for a single row of the table.
  *
  * @since 0.1-dev
  *
  * @param object $item The current item.
  */
 public function single_row($item)
 {
     echo '<tr data-slug="' . esc_attr(Application_Passwords::password_unique_slug($item)) . '">';
     $this->single_row_columns($item);
     echo '</tr>';
 }
<?php

/**
 * Plugin Name: Application Passwords
 * Plugin URI: http://github.com/georgestephanis/application-passwords/
 * Description: A prototype framework to add application passwords to core.
 * Author: George Stephanis
 * Version: 0.1-dev
 * Author URI: http://stephanis.info
 */
/**
 * Include the application passwords system.
 */
require_once dirname(__FILE__) . '/class.application-passwords.php';
Application_Passwords::add_hooks();
		/**
		 * Execute module upgrade
		 *
		 * @return void
		 */
		public function execute_upgrade( $old, $new ) {
			// Upgrade to new provider module system
			if ( $old < 4038 ) {

				global $wpdb;
				$settings = get_site_option( 'itsec_two_factor' );
				// If two-factor wasn't enabled or already has providers for some reason, don't worry about upgrading it
				if ( ! isset( $settings['enabled'] ) || ! $settings['enabled'] || ! empty( $settings['enabled-providers'] ) ) {
					return;
				}
				$settings = array(
					'enabled' => true,
					'enabled-providers' => array(
						'Two_Factor_Totp',
						'Two_Factor_Backup_Codes'
					)
				);
				update_site_option( 'itsec_two_factor', $settings );
				// Instantiate enabled providers so we can handle all the updating
				$helper = ITSEC_Two_Factor_Helper::get_instance();
				$helper->get_enabled_provider_instances( true );

				/**
				 * Migrate all app passes to new system
				 */
				$meta_results = $wpdb->get_results( "SELECT * FROM `{$wpdb->usermeta}` WHERE `meta_key` = 'itsec_two_factor_app_pass'" );

				foreach ( $meta_results as $user_meta ) {
					// New Style Passwords, in case any exist from other compatible plugins
					$passwords = Application_Passwords::get_user_application_passwords( $user_meta->user_id );
					if ( ! $passwords ) {
						$passwords = array();
					}

					$app_passwords = maybe_unserialize( $user_meta->meta_value );
					if ( is_array( $app_passwords ) ) {
						foreach ( $app_passwords as $name => $app_password ) {
							$passwords[]  = array(
								'name'      => $name,
								'password'  => $app_password,
								'created'   => time(),
								'last_used' => null,
								'last_ip'   => null,
							);
						}
					}
					// Store them all
					Application_Passwords::set_user_application_passwords( $user_meta->user_id, $passwords );
					delete_user_meta( $user_meta->user_id, 'itsec_two_factor_app_pass' );

				}

				/**
				 * Enable the TOTP provider for any user that is already using two-factor
				 */
				$meta_results = $wpdb->get_results( "SELECT * FROM `{$wpdb->usermeta}` WHERE `meta_key` = 'itsec_two_factor_enabled'" );
				foreach ( $meta_results as $user_meta ) {
					// Out with the old
					delete_user_meta( $user_meta->user_id, 'itsec_two_factor_enabled' );
					// Enable TOTP
					update_usermeta( $user_meta->user_id, '_two_factor_enabled_providers', array( 'Two_Factor_Totp' ) );
					// Make TOTP default
					update_usermeta( $user_meta->user_id, '_two_factor_provider', 'Two_Factor_Totp' );
				}

				// Change meta key from old 'itsec_two_factor_key' to new '_two_factor_totp_key'
				$wpdb->update( $wpdb->usermeta, array( 'meta_key' => '_two_factor_totp_key' ), array( 'meta_key' => 'itsec_two_factor_key' ) );
			}

		}
<?php

/**
 * Plugin Name: Application Passwords
 * Plugin URI: http://github.com/georgestephanis/application-passwords/
 * Description: A prototype framework to add application passwords to core.
 * Author: George Stephanis
 * Version: 0.1-dev
 * Author URI: http://stephanis.info
 */
/**
 * Include the application passwords system.
 */
require_once dirname(__FILE__) . '/class.application-passwords.php';
Application_Passwords::add_hooks(plugin_basename(__FILE__));