WP_Super_Cache_Rest_Get_Settings::prepare_item_for_response()
Prepare the item for the REST response
Method of the class: WP_Super_Cache_Rest_Get_Settings{}
No Hooks.
Return
Mixed
.
Usage
$WP_Super_Cache_Rest_Get_Settings = new WP_Super_Cache_Rest_Get_Settings(); $WP_Super_Cache_Rest_Get_Settings->prepare_item_for_response( $item, $request );
- $item(mixed) (required)
- WordPress representation of the item.
- $request(WP_REST_Request) (required)
- Request object.
WP_Super_Cache_Rest_Get_Settings::prepare_item_for_response() WP Super Cache Rest Get Settings::prepare item for response code WPSCache 1.12.4
public function prepare_item_for_response( $item, $request ) { $settings = array(); $integers = array( 'cache_max_time', 'preload_interval' ); $string_arrays = array( 'cache_stats', 'cache_acceptable_files', 'cache_rejected_uri', 'cache_rejected_user_agent', 'cache_direct_pages' ); foreach( $item as $key => $value ) { if ( is_array( $value ) && false == in_array( $key, $string_arrays ) ) { array_walk( $value, array( $this, 'make_array_bool' ) ); } elseif ( ( $value === 0 || $value === 1 ) && false == in_array( $key, $integers ) ) { $value = (bool)$value; } $settings[ $key ] = $value; } $strings_to_bool = array( 'ossdl_https', 'refresh_current_only_on_comments' ); foreach( $strings_to_bool as $key ) { if ( isset( $settings[ $key ] ) ) { $settings[ $key ] = (bool)$settings[ $key ]; } } return rest_ensure_response( $settings ); }