cache ) { $stored = get_option( Settings::OPTION, array() ); $this->cache = Settings::from_array( is_array( $stored ) ? $stored : array() ); } return $this->cache; } /** * Write the configuration. * * @param Settings $settings Settings to persist. * @return bool True when the stored value changed or already matched. */ public function save( Settings $settings ): bool { $values = $settings->to_array(); // A value fixed by a wp-config constant is not ours to store. Writing it back would put the // server key into the database that the constant exists to keep it out of, and would leave a // stale copy behind on the day the constant changes. foreach ( array_keys( Settings::defaults() ) as $key ) { if ( $settings->is_locked( $key ) ) { $values[ $key ] = ''; } } $this->cache = null; // update_option() returns false when the value is unchanged, which is not a failure; the caller // only wants to know that the stored state now matches what it asked for. $saved = update_option( Settings::OPTION, $values, true ); return $saved || get_option( Settings::OPTION ) === $values; } /** * Forget the per-request copy. * * @return void */ public function flush(): void { $this->cache = null; } }