From 0a9b6980d632ae6dae0c8ebc523fc4b06c039204 Mon Sep 17 00:00:00 2001 From: StevenDufresne Date: Fri, 25 Oct 2024 02:39:00 +0000 Subject: [PATCH 01/13] Update theme. --- .../themes/pub/wporg-support-2024/bbpress.php | 3 +- .../pub/wporg-support-2024/functions.php | 47 +++++++++++++++++++ .../pub/wporg-support-2024/package-lock.json | 10 ++-- .../sass/site/_bbpress.scss | 5 +- .../pub/wporg-support-2024/style-rtl.css | 5 +- .../themes/pub/wporg-support-2024/style.css | 5 +- 6 files changed, 60 insertions(+), 15 deletions(-) diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/bbpress.php b/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/bbpress.php index f09ecac155..c3822014cd 100644 --- a/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/bbpress.php +++ b/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/bbpress.php @@ -4,13 +4,12 @@ * * @package WPBBP */ - +global $wp_query; get_header(); ?>
-
diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/functions.php b/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/functions.php index df6cc5ae45..a0865ef0da 100644 --- a/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/functions.php +++ b/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/functions.php @@ -1557,3 +1557,50 @@ function bb_is_intl_forum() { * Include the Strings for the supporg/update-php page. */ include_once __DIR__ . '/helphub-update-php-strings.php'; + + +/** + * Update ratings blocks with real rating data. + * + * @param array $data Rating data. + * @param int $post_id Current post. + * + * @return array + */ +function wporg_set_rating_data( $data, $post_id ) { + $post = wporg_support_get_compat_object(); + + if ( class_exists( '\WPORG_Ratings' ) ) { + $rating = \WPORG_Ratings::get_avg_rating( $post->type, $post->post_name ) ?: 0; + $ratings = \WPORG_Ratings::get_rating_counts( $post->type, $post->post_name ) ?: array(); + } + + /** + * Why do we multiply the average rating by 20? + * The themes API does it this way, and the rating plugin was built to fit that. + * Instead of redoing everything, multiplying here keeps things simple and works well. + * + * @see theme-directory/class-themes-api.php for more info. + */ + $adjusted_rating = $rating * 20; + + return array( + 'rating' => $adjusted_rating, + 'ratingsCount' => array_sum( $ratings ), + 'ratings' => $ratings, + 'supportUrl' => esc_url( sprintf( home_url( '/%s/%s/reviews/' ), $post->type, $post->post_name ) ) + ); +} + +add_filter( 'wporg_ratings_data', 'wporg_set_rating_data', 10, 2 ); + +function wporg_render_block_context( $context, $parsed_block, $parent_block ) { + + if ( in_array( $parsed_block['blockName'], [ 'wporg/ratings-stars', 'wporg/ratings-bars' ] ) ) { + $context = array_merge( $context, [ 'postId' => wporg_support_get_compat_object()->ID ] ); + } + + return $context; +} + +add_filter( 'render_block_context', 'wporg_render_block_context', 10, 3 ); \ No newline at end of file diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/package-lock.json b/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/package-lock.json index 5ec2b40621..46e76102d8 100644 --- a/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/package-lock.json +++ b/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/package-lock.json @@ -8,9 +8,6 @@ "name": "wporg-support", "version": "1.0.0", "license": "GPL-2.0-or-later", - "dependencies": { - "postcss-scss": "~4.0.9" - }, "devDependencies": { "@lodder/grunt-postcss": "~3.1.1", "@wordpress/browserslist-config": "~5.33.0", @@ -2308,6 +2305,7 @@ "version": "3.3.7", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.7.tgz", "integrity": "sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==", + "dev": true, "funding": [ { "type": "github", @@ -2613,7 +2611,8 @@ "node_modules/picocolors": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", - "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", + "dev": true }, "node_modules/picomatch": { "version": "2.3.1", @@ -2640,6 +2639,7 @@ "version": "8.4.33", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.33.tgz", "integrity": "sha512-Kkpbhhdjw2qQs2O2DGX+8m5OVqEcbB9HRBvuYM9pgrjEFUg30A9LmXNlTAUj4S9kgtGyrMbTzVjH7E+s5Re2yg==", + "dev": true, "funding": [ { "type": "opencollective", @@ -2695,6 +2695,7 @@ "version": "4.0.9", "resolved": "https://registry.npmjs.org/postcss-scss/-/postcss-scss-4.0.9.tgz", "integrity": "sha512-AjKOeiwAitL/MXxQW2DliT28EKukvvbEWx3LBmJIRN8KfBGZbRTxNYW0kSqi1COiTZ57nZ9NW06S6ux//N1c9A==", + "dev": true, "funding": [ { "type": "opencollective", @@ -3254,6 +3255,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz", "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==", + "dev": true, "engines": { "node": ">=0.10.0" } diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/sass/site/_bbpress.scss b/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/sass/site/_bbpress.scss index 18e9fbd1c0..e018f157f2 100644 --- a/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/sass/site/_bbpress.scss +++ b/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/sass/site/_bbpress.scss @@ -1344,8 +1344,8 @@ div.bbp-breadcrumb { .review-ratings { @extend .clear; - margin-bottom: ms(0); - padding-bottom: 10px; + margin-bottom: var(--wp--preset--spacing--20); + padding-bottom: var(--wp--preset--spacing--20); border-bottom: 1px solid var(--wp--custom--color--border); display: flex; flex-direction: row-reverse; @@ -1354,7 +1354,6 @@ div.bbp-breadcrumb { font-size: ms(-2); margin: 0; min-width: 40%; - border-top: 1px solid var(--wp--custom--color--border); flex-shrink: 0; .reviews-total-count { diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/style-rtl.css b/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/style-rtl.css index 136a46fc83..2769a786ba 100644 --- a/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/style-rtl.css +++ b/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/style-rtl.css @@ -3557,8 +3557,8 @@ div.bbp-breadcrumb .bbp-breadcrumb-sep { # Plugin / Theme specific support pages --------------------------------------------------------------*/ .bbp-view .review-ratings { - margin-bottom: 1rem; - padding-bottom: 10px; + margin-bottom: var(--wp--preset--spacing--20); + padding-bottom: var(--wp--preset--spacing--20); border-bottom: 1px solid var(--wp--custom--color--border); display: flex; flex-direction: row-reverse; @@ -3567,7 +3567,6 @@ div.bbp-breadcrumb .bbp-breadcrumb-sep { font-size: 0.8rem; margin: 0; min-width: 40%; - border-top: 1px solid var(--wp--custom--color--border); flex-shrink: 0; } .bbp-view .review-ratings .col-3 .reviews-total-count { diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/style.css b/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/style.css index eace4a2868..cdbb92fdc8 100644 --- a/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/style.css +++ b/wordpress.org/public_html/wp-content/themes/pub/wporg-support-2024/style.css @@ -3557,8 +3557,8 @@ div.bbp-breadcrumb .bbp-breadcrumb-sep { # Plugin / Theme specific support pages --------------------------------------------------------------*/ .bbp-view .review-ratings { - margin-bottom: 1rem; - padding-bottom: 10px; + margin-bottom: var(--wp--preset--spacing--20); + padding-bottom: var(--wp--preset--spacing--20); border-bottom: 1px solid var(--wp--custom--color--border); display: flex; flex-direction: row-reverse; @@ -3567,7 +3567,6 @@ div.bbp-breadcrumb .bbp-breadcrumb-sep { font-size: 0.8rem; margin: 0; min-width: 40%; - border-top: 1px solid var(--wp--custom--color--border); flex-shrink: 0; } .bbp-view .review-ratings .col-3 .reviews-total-count { From 49662e8e73759a998aa78a09c349ce2e426510d4 Mon Sep 17 00:00:00 2001 From: StevenDufresne Date: Fri, 25 Oct 2024 02:44:45 +0000 Subject: [PATCH 02/13] Update support forum plugin. --- .../inc/class-ratings-compat.php | 49 +------------------ 1 file changed, 2 insertions(+), 47 deletions(-) diff --git a/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-ratings-compat.php b/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-ratings-compat.php index 6ae00461f1..5bbda14d80 100644 --- a/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-ratings-compat.php +++ b/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-ratings-compat.php @@ -221,56 +221,11 @@ public function do_view_header() { '' . number_format_i18n( $this->reviews_count ) . '' ); ?>
- ratings_counts[ $rating ] ) ? $this->ratings_counts[ $rating ] : 0; - $ratings_count_total = isset( $this->ratings_counts ) ? array_sum( $this->ratings_counts) : 0; - $stars_title = sprintf( - /* translators: %s: number of stars */ - _n( - 'Click to see reviews that provided a rating of %d star', - 'Click to see reviews that provided a rating of %d stars', - $rating, - 'wporg-forums' - ), - $rating - ); - /* translators: %d: number of stars */ - $stars_text = sprintf( - /* translators: %d: number of stars */ - _n( '%d star', '%d stars', $rating, 'wporg-forums' ), - $rating - ); - $width = 0; - if ( $ratings_count && $ratings_count_total ) { - $width = 100 * ( $ratings_count / $ratings_count_total ); - } - ?> - - + ' ); ?>
- avg_rating ); - printf( - /* translators: 1: number of stars in rating, 2: total number of stars (5) */ - __( '%1$s out of %2$s stars', 'wporg-forums' ), - round( isset( $this->avg_rating ) ? $this->avg_rating : 0, 1 ), - '5' - ); - ?> + ' ); ?>
- ' ); ?> + ' ); ?>