Skip to content

Commit

Permalink
Blocks: Remove ratings blocks, use shared mu-plugins blocks (#146)
Browse files Browse the repository at this point in the history
See WordPress/wporg-mu-plugins#633

Co-authored-by: Kelly Dwan <[email protected]>
  • Loading branch information
StevenDufresne and ryelle authored Jul 24, 2024
1 parent 7cd1a03 commit 79dd01d
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 298 deletions.
2 changes: 0 additions & 2 deletions source/wp-content/themes/wporg-themes-2024/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
require_once( __DIR__ . '/src/business-model-notice/index.php' );
require_once( __DIR__ . '/src/child-theme-notice/index.php' );
require_once( __DIR__ . '/src/meta-list/index.php' );
require_once( __DIR__ . '/src/ratings-bars/index.php' );
require_once( __DIR__ . '/src/ratings-stars/index.php' );
require_once( __DIR__ . '/src/theme-available-translations/index.php' );
require_once( __DIR__ . '/src/theme-downloads/index.php' );
require_once( __DIR__ . '/src/theme-patterns/index.php' );
Expand Down
25 changes: 24 additions & 1 deletion 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, get_theme_information, 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 @@ -17,6 +17,7 @@
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_favorite_button_settings', __NAMESPACE__ . '\get_favorite_settings', 10, 2 );
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 @@ -409,3 +410,25 @@ function update_site_title( $block_content ) {
$block_content
);
}

/**
* Update ratings blocks with real rating data.
*
* @param array $data Rating data.
* @param int $post_id Current post.
*
* @return array
*/
function set_rating_data( $data, $post_id ) {
$theme = get_theme_information( $post_id );
if ( ! $theme ) {
return $data;
}

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

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 79dd01d

Please sign in to comment.