public function unset_stale_options( $ghu_options_keys, $ghu_tokens ) {
		$running_servers = $this->get_running_git_servers();
		$ghu_unset_keys  = array_diff_key( static::$options, $ghu_options_keys );
		$always_unset    = [
			'db_version',
			'branch_switch',
			'github_access_token',
			'github_enterprise_token',
		];

		if ( in_array( 'bitbucket', $running_servers, true ) ) {
			$always_unset = array_merge(
				$always_unset,
				[
					'bitbucket_username',
					'bitbucket_password',
				]
			);
		}

		if ( in_array( 'bbserver', $running_servers, true ) ) {
			$always_unset = array_merge(
				$always_unset,
				[
					'bitbucket_server_username',
					'bitbucket_server_password',
				]
			);
		}

		array_map(
			function ( $e ) use ( &$ghu_unset_keys ) {
				unset( $ghu_unset_keys[ $e ] );
			},
			$always_unset
		);

		$auth_required       = static::$auth_required;
		$auth_required_unset = [
			'github_enterprise' => 'github_enterprise_token',
			'gitlab'            => 'gitlab_access_token',
			'gitlab_enterprise' => 'gitlab_enterprise_token',
			'gitea'             => 'gitea_access_token',
		];

		array_map(
			function ( $e ) use ( &$ghu_unset_keys, $auth_required, $auth_required_unset ) {
				$key = array_search( $e, $auth_required_unset, true );
				if ( $auth_required[ $key ] ) {
					unset( $ghu_unset_keys[ $e ] );
				}
			},
			$auth_required_unset
		);

		// Unset if current_branch AND if associated with repo.
		array_map(
			function ( $e ) use ( &$ghu_unset_keys, $ghu_tokens, &$reset_keys ) {
				$key  = array_search( $e, $ghu_unset_keys, true );
				$repo = str_replace( 'current_branch_', '', $key );
				if ( array_key_exists( $key, $ghu_unset_keys )
				&& false !== strpos( $key, 'current_branch' )
				) {
					unset( $ghu_unset_keys[ $key ] );
				}
				if ( ! array_key_exists( $repo, $ghu_tokens ) ) {
					$reset_keys[ $key ] = $e;
				}
			},
			$ghu_unset_keys
		);
		$ghu_unset_keys = array_merge( $ghu_unset_keys, (array) $reset_keys );

		if ( ! empty( $ghu_unset_keys ) ) {
			foreach ( $ghu_unset_keys as $key => $value ) {
				unset( static::$options[ $key ] );
			}
			update_site_option( 'github_updater', static::$options );
		}
	}
public function unset_stale_options( $ghu_options_keys, $ghu_tokens ) {
		$running_servers = $this->get_running_git_servers();
		$ghu_unset_keys  = array_diff_key( static::$options, $ghu_options_keys );
		$always_unset    = [
			'db_version',
			'branch_switch',
			'github_access_token',
			'github_enterprise_token',
		];

		if ( in_array( 'bitbucket', $running_servers, true ) ) {
			$always_unset = array_merge(
				$always_unset,
				[
					'bitbucket_username',
					'bitbucket_password',
				]
			);
		}

		if ( in_array( 'bbserver', $running_servers, true ) ) {
			$always_unset = array_merge(
				$always_unset,
				[
					'bitbucket_server_username',
					'bitbucket_server_password',
				]
			);
		}

		array_map(
			function ( $e ) use ( &$ghu_unset_keys ) {
				unset( $ghu_unset_keys[ $e ] );
			},
			$always_unset
		);

		$auth_required       = static::$auth_required;
		$auth_required_unset = [
			'github_enterprise' => 'github_enterprise_token',
			'gitlab'            => 'gitlab_access_token',
			'gitlab_enterprise' => 'gitlab_enterprise_token',
			'gitea'             => 'gitea_access_token',
		];

		array_map(
			function ( $e ) use ( &$ghu_unset_keys, $auth_required, $auth_required_unset ) {
				$key = array_search( $e, $auth_required_unset, true );
				if ( $auth_required[ $key ] ) {
					unset( $ghu_unset_keys[ $e ] );
				}
			},
			$auth_required_unset
		);

		// Unset if current_branch AND if associated with repo.
		array_map(
			function ( $e ) use ( &$ghu_unset_keys, $ghu_tokens, &$reset_keys ) {
				$key  = array_search( $e, $ghu_unset_keys, true );
				$repo = str_replace( 'current_branch_', '', $key );
				if ( array_key_exists( $key, $ghu_unset_keys )
				&& false !== strpos( $key, 'current_branch' )
				) {
					unset( $ghu_unset_keys[ $key ] );
				}
				if ( ! array_key_exists( $repo, $ghu_tokens ) ) {
					$reset_keys[ $key ] = $e;
				}
			},
			$ghu_unset_keys
		);
		$ghu_unset_keys = array_merge( $ghu_unset_keys, (array) $reset_keys );

		if ( ! empty( $ghu_unset_keys ) ) {
			foreach ( $ghu_unset_keys as $key => $value ) {
				unset( static::$options[ $key ] );
			}
			update_site_option( 'github_updater', static::$options );
		}
	}
public function unset_stale_options ( $ ghu_options_keys , $ ghu_tokens ) { $ running_servers = $ this -> get_running_git_servers ( ) ; $ ghu_unset_keys = array_diff_key ( static :: $ options , $ ghu_options_keys ) ; $ always_unset = [ 'db_version' , 'branch_switch' , 'github_access_token' , 'github_enterprise_token' , ] ; if ( in_array ( 'bitbucket' , $ running_servers , true ) ) { $ always_unset = array_merge ( $ always_unset , [ 'bitbucket_username' , 'bitbucket_password' , ] ) ; } if ( in_array ( 'bbserver' , $ running_servers , true ) ) { $ always_unset = array_merge ( $ always_unset , [ 'bitbucket_server_username' , 'bitbucket_server_password' , ] ) ; } array_map ( function ( $ e ) use ( & $ ghu_unset_keys ) { unset ( $ ghu_unset_keys [ $ e ] ) ; } , $ always_unset ) ; $ auth_required = static :: $ auth_required ; $ auth_required_unset = [ 'github_enterprise' => 'github_enterprise_token' , 'gitlab' => 'gitlab_access_token' , 'gitlab_enterprise' => 'gitlab_enterprise_token' , 'gitea' => 'gitea_access_token' , ] ; array_map ( function ( $ e ) use ( & $ ghu_unset_keys , $ auth_required , $ auth_required_unset ) { $ key = array_search ( $ e , $ auth_required_unset , true ) ; if ( $ auth_required [ $ key ] ) { unset ( $ ghu_unset_keys [ $ e ] ) ; } } , $ auth_required_unset ) ; // Unset if current_branch AND if associated with repo. array_map ( function ( $ e ) use ( & $ ghu_unset_keys , $ ghu_tokens , & $ reset_keys ) { $ key = array_search ( $ e , $ ghu_unset_keys , true ) ; $ repo = str_replace ( 'current_branch_' , '' , $ key ) ; if ( array_key_exists ( $ key , $ ghu_unset_keys ) && false !== strpos ( $ key , 'current_branch' ) ) { unset ( $ ghu_unset_keys [ $ key ] ) ; } if ( ! array_key_exists ( $ repo , $ ghu_tokens ) ) { $ reset_keys [ $ key ] = $ e ; } } , $ ghu_unset_keys ) ; $ ghu_unset_keys = array_merge ( $ ghu_unset_keys , ( array ) $ reset_keys ) ; if ( ! empty ( $ ghu_unset_keys ) ) { foreach ( $ ghu_unset_keys as $ key => $ value ) { unset ( static :: $ options [ $ key ] ) ; } update_site_option ( 'github_updater' , static :: $ options ) ; } }
Check current saved options and unset if repos not present.

@param array $ghu_options_keys
@param array $ghu_tokens
Check current saved options and unset if repos not present .