WP_REST_Pattern_Directory_Controller::get_transient_key() WordPress Method

The WP_REST_Pattern_Directory_Controller::get_transient_key() method is used to get the transient key for a given pattern directory. This transient key is used to store and retrieve the cached directory listing for the directory.

WP_REST_Pattern_Directory_Controller::get_transient_key( $query_args ) #


Source

File: wp-includes/rest-api/endpoints/class-wp-rest-pattern-directory-controller.php

	protected function get_transient_key( $query_args ) {

		if ( isset( $query_args['slug'] ) ) {
			// This is an additional precaution because the "sort" function expects an array.
			$query_args['slug'] = wp_parse_list( $query_args['slug'] );

			// Empty arrays should not affect the transient key.
			if ( empty( $query_args['slug'] ) ) {
				unset( $query_args['slug'] );
			} else {
				// Sort the array so that the transient key doesn't depend on the order of slugs.
				sort( $query_args['slug'] );
			}
		}

		return 'wp_remote_block_patterns_' . md5( serialize( $query_args ) );
	}

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.