|
7 | 7 |
|
8 | 8 | use WP_HTML_Tag_Processor, WP_Block_Supports;
|
9 | 9 | use const WordPressdotorg\Theme\Theme_Directory_2024\THEME_POST_TYPE;
|
10 |
| -use function WordPressdotorg\Theme\Theme_Directory_2024\{ get_query_tags, wporg_themes_get_feature_list }; |
| 10 | +use function WordPressdotorg\Theme\Theme_Directory_2024\{ get_query_tags, get_support_url, get_theme_information, wporg_themes_get_feature_list }; |
11 | 11 | use function WordPressdotorg\Theme\Theme_Directory_2024\SEO_Social_Meta\{get_archive_title};
|
12 | 12 |
|
13 | 13 | add_filter( 'wporg_query_total_label', __NAMESPACE__ . '\update_query_total_label', 10, 2 );
|
|
16 | 16 | add_filter( 'wporg_query_filter_options_subjects', __NAMESPACE__ . '\get_subjects_options' );
|
17 | 17 | add_action( 'wporg_query_filter_in_form', __NAMESPACE__ . '\inject_other_filters', 10, 2 );
|
18 | 18 | add_filter( 'wporg_block_navigation_menus', __NAMESPACE__ . '\add_site_navigation_menus' );
|
19 |
| -add_filter( 'wporg_block_ratings_stars', __NAMESPACE__ . '\set_rating_stars' ); |
20 |
| -add_filter( 'wporg_block_ratings_bars', __NAMESPACE__ . '\set_rating_bars' ); |
| 19 | +add_filter( 'wporg_ratings_data', __NAMESPACE__ . '\set_rating_data', 10, 2 ); |
21 | 20 | add_filter( 'render_block_wporg/link-wrapper', __NAMESPACE__ . '\inject_permalink_link_wrapper' );
|
22 | 21 | add_filter( 'render_block_wporg/language-suggest', __NAMESPACE__ . '\inject_language_suggest_endpoint' );
|
23 | 22 | add_filter( 'render_block_core/search', __NAMESPACE__ . '\inject_browse_search_block' );
|
@@ -363,35 +362,23 @@ function filter_language_suggest_block( $block_content ) {
|
363 | 362 | }
|
364 | 363 |
|
365 | 364 | /**
|
366 |
| - * Update block attributes with real rating data. |
| 365 | + * Update ratings blocks with real rating data. |
367 | 366 | *
|
368 |
| - * @param array $attributes Block attributes. |
369 |
| - * @return array |
370 |
| - */ |
371 |
| -function set_rating_stars( $attributes ) { |
372 |
| - global $post; |
373 |
| - |
374 |
| - $theme = wporg_themes_theme_information( $post->post_name ); |
375 |
| - |
376 |
| - return array_merge( $attributes, array( |
377 |
| - 'rating' => $theme->rating, |
378 |
| - ) ); |
379 |
| -} |
380 |
| - |
381 |
| -/** |
382 |
| - * Update block attributes with real rating data. |
| 367 | + * @param array $data Rating data. |
| 368 | + * @param int $post_id Current post. |
383 | 369 | *
|
384 |
| - * @param array $attributes Block attributes. |
385 | 370 | * @return array
|
386 | 371 | */
|
387 |
| -function set_rating_bars( $attributes ) { |
388 |
| - global $post; |
389 |
| - |
390 |
| - $theme = wporg_themes_theme_information( $post->post_name ); |
| 372 | +function set_rating_data( $data, $post_id ) { |
| 373 | + $theme = get_theme_information( $post_id ); |
| 374 | + if ( ! $theme ) { |
| 375 | + return $data; |
| 376 | + } |
391 | 377 |
|
392 |
| - return array_merge( $attributes, array( |
393 |
| - 'num_ratings' => $theme->num_ratings, |
| 378 | + return array( |
| 379 | + 'rating' => $theme->rating, |
| 380 | + 'ratingsCount' => $theme->num_ratings, |
394 | 381 | 'ratings' => $theme->ratings,
|
395 |
| - 'slug' => $theme->slug, |
396 |
| - ) ); |
| 382 | + 'supportUrl' => get_support_url( $theme->slug . '/reviews/' ), |
| 383 | + ); |
397 | 384 | }
|
0 commit comments