Ticket #45471: cache-key.patch
File cache-key.patch, 1.1 KB (added by , 6 years ago) |
---|
-
wp-includes/blocks.php
210 210 * 211 211 * @since 5.0.0 212 212 * 213 * @param string $content Post content. 213 * @param string $content Post content. 214 * @param string|bool $cache_key The cache key to use for the parsed blocks. 215 * 214 216 * @return array Array of parsed block objects. 215 217 */ 216 function parse_blocks( $content ) { 218 function parse_blocks( $content, $cache_key = false ) { 219 if ( $cache_key ) { 220 $parse_result = wp_cache_get( $cache_key, 'parsed_blocks' ); 221 if ( $parse_result ) { 222 return $parse_result; 223 } 224 } 225 217 226 /** 218 227 * Filter to allow plugins to replace the server-side block parser 219 228 * … … 224 233 $parser_class = apply_filters( 'block_parser_class', 'WP_Block_Parser' ); 225 234 226 235 $parser = new $parser_class(); 227 return $parser->parse( $content ); 236 $parse_result = $parser->parse( $content ); 237 if ( $cache_key ) { 238 wp_cache_add( $cache_key, $parse_result,'parsed_blocks' ); 239 } 240 return $parse_result; 228 241 } 229 242 230 243 /**