* Complete the cache directory.
public function cache_dir_complete() {
if ( ! $this->updated ) {
wpforms_create_upload_dir_htaccess_file();
wpforms_create_cache_dir_htaccess_file();
wpforms_create_index_html_file( $this->cache_dir );
wpforms_create_index_php_file( $this->cache_dir );
public function invalidate_cache() {
Transient::delete( $this->cache_key );
* Prepare data to store in a local cache.
* @param array|mixed $data Raw data received by the remote request.
* @return array Prepared data for caching.
protected function prepare_cache_data( $data ): array {
if ( empty( $data ) || ! is_array( $data ) ) {
* Maybe update transient duration time.
* Allows updating transient duration time if it's less than expiration time.
* To do this, overwrite this method in child classes.
* @param array $data Data received by the remote request.
protected function maybe_update_transient( array $data ) {