diff --git a/plugins/optimization-detective/storage/data.php b/plugins/optimization-detective/storage/data.php index 83034c080..dd70995ca 100644 --- a/plugins/optimization-detective/storage/data.php +++ b/plugins/optimization-detective/storage/data.php @@ -156,31 +156,20 @@ function od_get_url_metrics_slug( array $query_vars ): string { * @return non-empty-string Current ETag. */ function od_get_current_url_metrics_etag( OD_Tag_Visitor_Registry $tag_visitor_registry, WP_Query $wp_query, $current_template ): string { - $active_theme = array( - 'template' => array( - 'name' => get_template(), - 'version' => wp_get_theme( get_template() )->get( 'Version' ), - ), - 'stylesheet' => array( - 'name' => get_stylesheet(), - 'version' => wp_get_theme()->get( 'Version' ), - ), - ); - - /** - * Filters the active theme details used for computing the current ETag. - * - * @since n.e.x.t - * - * @param array> $active_theme Active theme details. - */ - $active_theme = apply_filters( 'od_current_url_metrics_etag_active_theme', $active_theme ); - $data = array( 'tag_visitors' => array_keys( iterator_to_array( $tag_visitor_registry ) ), 'queried_object' => $wp_query->get_queried_object(), 'queried_posts' => wp_list_pluck( $wp_query->posts, 'post_modified_gmt', 'ID' ), - 'active_theme' => $active_theme, + 'active_theme' => array( + 'template' => array( + 'name' => get_template(), + 'version' => wp_get_theme( get_template() )->get( 'Version' ), + ), + 'stylesheet' => array( + 'name' => get_stylesheet(), + 'version' => wp_get_theme()->get( 'Version' ), + ), + ), 'current_template' => $current_template, ); diff --git a/plugins/optimization-detective/tests/storage/test-data.php b/plugins/optimization-detective/tests/storage/test-data.php index dc89bf73f..68ae7703e 100644 --- a/plugins/optimization-detective/tests/storage/test-data.php +++ b/plugins/optimization-detective/tests/storage/test-data.php @@ -308,9 +308,9 @@ static function ( array $data ) use ( &$captured_etag_data ) { PHP_INT_MAX ); add_filter( - 'od_current_url_metrics_etag_active_theme', - static function ( $active_theme ) { - $active_theme = array( + 'od_current_url_metrics_etag_data', + static function ( $data ) { + $data['active_theme'] = array( 'template' => array( 'name' => 'od-theme', 'version' => '1.0.0', @@ -320,7 +320,7 @@ static function ( $active_theme ) { 'version' => '1.0.0', ), ); - return $active_theme; + return $data; } ); @@ -401,11 +401,11 @@ static function ( $active_theme ) { // Modify data using filters. add_filter( - 'od_current_url_metrics_etag_active_theme', - static function ( $active_theme ) { - $active_theme['template']['version'] = '2.0.0'; - $active_theme['stylesheet']['version'] = '2.0.0'; - return $active_theme; + 'od_current_url_metrics_etag_data', + static function ( $data ) { + $data['active_theme']['template']['version'] = '2.0.0'; + $data['active_theme']['stylesheet']['version'] = '2.0.0'; + return $data; } ); $etag6 = od_get_current_url_metrics_etag( $registry, $wp_the_query, $current_template );