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..434f27a623 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 @@ -212,65 +212,9 @@ public function do_view_header() { add_filter( 'bbp_get_topic_last_topic_title', array( $this, 'undo_topic_title' ), 10, 1 ); ?>
-
- -
reviews_count, 'wporg-forums' ), - '' . 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' - ); - ?> + ' ); ?>
+
+ +
reviews_count, 'wporg-forums' ), + '' . number_format_i18n( $this->reviews_count ) . '' + ); + ?>
+ ' ); ?> +
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 ) ) + ); +} + +/** + * Modifies the block context to include a `postId` for specific blocks. + * + * The `wporg/ratings-stars` and `wporg/ratings-bars` require a postId. Due to context, it's unavailable. + * + * @param array $context The current block context. + * @param array $parsed_block The block being rendered. + * @param WP_Block|null $parent_block Optional. The parent block, if any. + * + * @return array The modified block context. + */ +function wporg_render_block_context( $context, $parsed_block, $parent_block ) { + if ( isset( $parsed_block['blockName'] ) && + in_array( $parsed_block['blockName'], [ 'wporg/ratings-stars', 'wporg/ratings-bars' ], true ) ) { + + $compat_object = wporg_support_get_compat_object(); + + if ( $compat_object ) { + $context = array_merge( $context, [ 'postId' => $compat_object->ID ] ); + } + } + + return $context; +} 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..97ad106965 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 @@ -1343,19 +1343,23 @@ div.bbp-breadcrumb { // Review page .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; - .col-3 { + > div:first-child { font-size: ms(-2); - margin: 0; - min-width: 40%; - border-top: 1px solid var(--wp--custom--color--border); + width: 60%; + min-width: 54%; flex-shrink: 0; + } + + > div:last-child { + margin: 0 0 10px 0; + padding-right: 10px; + min-width: 40%; + font-size: ms(-2); .reviews-total-count { font-weight: 700; @@ -1363,20 +1367,7 @@ div.bbp-breadcrumb { padding-top: 5px; } - .counter-bar { - background-color: var(--wp--preset--color--pomegrade-1) !important; - } - } - - .col-5 { - margin: 0 0 10px 0; - padding-right: 10px; - width: 60%; - min-width: 54%; - font-size: ms(-2); - > div:first-child { - @extend h4; margin-top: 0; } @@ -1392,11 +1383,16 @@ div.bbp-breadcrumb { } @media (max-width: 499px) { - flex-direction: column-reverse; + flex-direction: column; - .col-3, .col-5 { + > div:first-child { width: 100%; + margin-bottom: 20px; } } } + + .reviews-submit-link { + margin-top: 10px; + } } 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..3dd6a3ea96 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 @@ -918,7 +918,7 @@ h1, h2, h3, h4, -.bbp-view .review-ratings .col-5 > div:first-child, +.bbp-view .review-ratings > div:last-child > div:first-child, h5, h6 { margin: 0 0 var(--wp--style--block-gap); @@ -1980,9 +1980,8 @@ fieldset label { /*-------------------------------------------------------------- # Clearings --------------------------------------------------------------*/ -.clear::before, .bbp-view .review-ratings::before, .bbpress main#main::before, +.clear::before, .bbpress main#main::before, .clear::after, -.bbp-view .review-ratings::after, .bbpress main#main::after, .entry-content::before, .entry-content::after, @@ -1999,7 +1998,7 @@ fieldset label { table-layout: fixed; } -.clear::after, .bbp-view .review-ratings::after, .bbpress main#main::after, +.clear::after, .bbpress main#main::after, .entry-content::after, .comment-content::after, .site-header::after, @@ -3557,52 +3556,50 @@ 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; } -.bbp-view .review-ratings .col-3 { +.bbp-view .review-ratings > div:first-child { font-size: 0.8rem; - margin: 0; - min-width: 40%; - border-top: 1px solid var(--wp--custom--color--border); + width: 60%; + min-width: 54%; flex-shrink: 0; } -.bbp-view .review-ratings .col-3 .reviews-total-count { - font-weight: 700; - padding-bottom: 5px; - padding-top: 5px; -} -.bbp-view .review-ratings .col-3 .counter-bar { - background-color: var(--wp--preset--color--pomegrade-1) !important; -} -.bbp-view .review-ratings .col-5 { +.bbp-view .review-ratings > div:last-child { margin: 0 0 10px 0; padding-left: 10px; - width: 60%; - min-width: 54%; + min-width: 40%; font-size: 0.8rem; } -.bbp-view .review-ratings .col-5 > div:first-child { +.bbp-view .review-ratings > div:last-child .reviews-total-count { + font-weight: 700; + padding-bottom: 5px; + padding-top: 5px; +} +.bbp-view .review-ratings > div:last-child > div:first-child { margin-top: 0; } -.bbp-view .review-ratings .col-5 .wporg-ratings { +.bbp-view .review-ratings > div:last-child .wporg-ratings { display: inline-block; margin-left: 1rem; } -.bbp-view .review-ratings .col-5 .reviews-submit-link { +.bbp-view .review-ratings > div:last-child .reviews-submit-link { margin-top: 1rem; } @media (max-width: 499px) { .bbp-view .review-ratings { - flex-direction: column-reverse; + flex-direction: column; } - .bbp-view .review-ratings .col-3, .bbp-view .review-ratings .col-5 { + .bbp-view .review-ratings > div:first-child { width: 100%; + margin-bottom: 20px; } } +.bbp-view .reviews-submit-link { + margin-top: 10px; +} /*-------------------------------------------------------------- # HelpHub Specific 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..a9a047e9e2 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 @@ -918,7 +918,7 @@ h1, h2, h3, h4, -.bbp-view .review-ratings .col-5 > div:first-child, +.bbp-view .review-ratings > div:last-child > div:first-child, h5, h6 { margin: 0 0 var(--wp--style--block-gap); @@ -1980,9 +1980,8 @@ fieldset label { /*-------------------------------------------------------------- # Clearings --------------------------------------------------------------*/ -.clear::before, .bbp-view .review-ratings::before, .bbpress main#main::before, +.clear::before, .bbpress main#main::before, .clear::after, -.bbp-view .review-ratings::after, .bbpress main#main::after, .entry-content::before, .entry-content::after, @@ -1999,7 +1998,7 @@ fieldset label { table-layout: fixed; } -.clear::after, .bbp-view .review-ratings::after, .bbpress main#main::after, +.clear::after, .bbpress main#main::after, .entry-content::after, .comment-content::after, .site-header::after, @@ -3557,52 +3556,50 @@ 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; } -.bbp-view .review-ratings .col-3 { +.bbp-view .review-ratings > div:first-child { font-size: 0.8rem; - margin: 0; - min-width: 40%; - border-top: 1px solid var(--wp--custom--color--border); + width: 60%; + min-width: 54%; flex-shrink: 0; } -.bbp-view .review-ratings .col-3 .reviews-total-count { - font-weight: 700; - padding-bottom: 5px; - padding-top: 5px; -} -.bbp-view .review-ratings .col-3 .counter-bar { - background-color: var(--wp--preset--color--pomegrade-1) !important; -} -.bbp-view .review-ratings .col-5 { +.bbp-view .review-ratings > div:last-child { margin: 0 0 10px 0; padding-right: 10px; - width: 60%; - min-width: 54%; + min-width: 40%; font-size: 0.8rem; } -.bbp-view .review-ratings .col-5 > div:first-child { +.bbp-view .review-ratings > div:last-child .reviews-total-count { + font-weight: 700; + padding-bottom: 5px; + padding-top: 5px; +} +.bbp-view .review-ratings > div:last-child > div:first-child { margin-top: 0; } -.bbp-view .review-ratings .col-5 .wporg-ratings { +.bbp-view .review-ratings > div:last-child .wporg-ratings { display: inline-block; margin-right: 1rem; } -.bbp-view .review-ratings .col-5 .reviews-submit-link { +.bbp-view .review-ratings > div:last-child .reviews-submit-link { margin-top: 1rem; } @media (max-width: 499px) { .bbp-view .review-ratings { - flex-direction: column-reverse; + flex-direction: column; } - .bbp-view .review-ratings .col-3, .bbp-view .review-ratings .col-5 { + .bbp-view .review-ratings > div:first-child { width: 100%; + margin-bottom: 20px; } } +.bbp-view .reviews-submit-link { + margin-top: 10px; +} /*-------------------------------------------------------------- # HelpHub Specific