Skip to content

Commit

Permalink
Update the filter.
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenDufresne committed Jun 27, 2024
1 parent 07ba397 commit df0c176
Showing 1 changed file with 15 additions and 28 deletions.
43 changes: 15 additions & 28 deletions source/wp-content/themes/wporg-themes-2024/inc/block-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

use WP_HTML_Tag_Processor, WP_Block_Supports;
use const WordPressdotorg\Theme\Theme_Directory_2024\THEME_POST_TYPE;
use function WordPressdotorg\Theme\Theme_Directory_2024\{ get_query_tags, wporg_themes_get_feature_list };
use function WordPressdotorg\Theme\Theme_Directory_2024\{ get_query_tags, get_support_url, get_theme_information, wporg_themes_get_feature_list };
use function WordPressdotorg\Theme\Theme_Directory_2024\SEO_Social_Meta\{get_archive_title};

add_filter( 'wporg_query_total_label', __NAMESPACE__ . '\update_query_total_label', 10, 2 );
Expand All @@ -16,8 +16,7 @@
add_filter( 'wporg_query_filter_options_subjects', __NAMESPACE__ . '\get_subjects_options' );
add_action( 'wporg_query_filter_in_form', __NAMESPACE__ . '\inject_other_filters', 10, 2 );
add_filter( 'wporg_block_navigation_menus', __NAMESPACE__ . '\add_site_navigation_menus' );
add_filter( 'wporg_block_ratings_stars', __NAMESPACE__ . '\set_rating_stars' );
add_filter( 'wporg_block_ratings_bars', __NAMESPACE__ . '\set_rating_bars' );
add_filter( 'wporg_ratings_data', __NAMESPACE__ . '\set_rating_data', 10, 2 );
add_filter( 'render_block_wporg/link-wrapper', __NAMESPACE__ . '\inject_permalink_link_wrapper' );
add_filter( 'render_block_wporg/language-suggest', __NAMESPACE__ . '\inject_language_suggest_endpoint' );
add_filter( 'render_block_core/search', __NAMESPACE__ . '\inject_browse_search_block' );
Expand Down Expand Up @@ -363,35 +362,23 @@ function filter_language_suggest_block( $block_content ) {
}

/**
* Update block attributes with real rating data.
* Update ratings blocks with real rating data.
*
* @param array $attributes Block attributes.
* @return array
*/
function set_rating_stars( $attributes ) {
global $post;

$theme = wporg_themes_theme_information( $post->post_name );

return array_merge( $attributes, array(
'rating' => $theme->rating,
) );
}

/**
* Update block attributes with real rating data.
* @param array $data Rating data.
* @param int $post_id Current post.
*
* @param array $attributes Block attributes.
* @return array
*/
function set_rating_bars( $attributes ) {
global $post;

$theme = wporg_themes_theme_information( $post->post_name );
function set_rating_data( $data, $post_id ) {
$theme = get_theme_information( $post_id );
if ( ! $theme ) {
return $data;
}

return array_merge( $attributes, array(
'num_ratings' => $theme->num_ratings,
return array(
'rating' => $theme->rating,
'ratingsCount' => $theme->num_ratings,
'ratings' => $theme->ratings,
'slug' => $theme->slug,
) );
'supportUrl' => get_support_url( $theme->slug . '/reviews/' ),
);
}

0 comments on commit df0c176

Please sign in to comment.