*/ public static function read( $id ) { $all = get_option( self::OPTION, array() ); return is_array( $all ) && isset( $all[ $id ] ) && is_array( $all[ $id ] ) ? $all[ $id ] : array(); } /** * Store one connection's credentials — the FULL row, replaced whole. A * partial write would leave a caller guessing which fields survived; the * connect path always holds the complete grant, so it always writes it. * * @param string $id Connection id. * @param array $fields The complete credential row. */ public static function store( $id, array $fields ) { $all = get_option( self::OPTION, array() ); $all = is_array( $all ) ? $all : array(); $all[ $id ] = $fields; update_option( self::OPTION, $all, false ); } /** * Whether a connection exists — all any status surface may admit about a * credential. * * @param string $id Connection id. * @return bool */ public static function exists( $id ) { return array() !== self::read( $id ); } /** * Drop one connection — the disconnect path for every use it powers. The * neighbours' rows stand; the option itself leaves with its last row. * * @param string $id Connection id. */ public static function forget( $id ) { $all = get_option( self::OPTION, array() ); if ( is_array( $all ) && isset( $all[ $id ] ) ) { unset( $all[ $id ] ); if ( empty( $all ) ) { delete_option( self::OPTION ); } else { update_option( self::OPTION, $all, false ); } } } }