Automattic\WooCommerce\Blocks\BlockTypes\Reviews
ProductReviewsTitle::get_reviews_title
Get the reviews title.
Метод класса: ProductReviewsTitle{}
Хуков нет.
Возвращает
string.
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_reviews_title( $attributes, $product );
- $attributes(массив) (обязательный)
- Block attributes.
- $product(WC_Product) (обязательный)
- Product instance.
Код ProductReviewsTitle::get_reviews_title() ProductReviewsTitle::get reviews title WC 11.2.1
private function get_reviews_title( $attributes, $product ) {
$show_product_title = ! empty( $attributes['showProductTitle'] ) && $attributes['showProductTitle'];
$show_reviews_count = ! empty( $attributes['showReviewsCount'] ) && $attributes['showReviewsCount'];
$reviews_count = $product->get_review_count();
if ( $show_reviews_count && $show_product_title ) {
return 1 === $reviews_count
/* translators: %s: Product title. */
? sprintf( __( 'One review for %s', 'woocommerce' ), $product->get_title() )
: sprintf(
/* translators: 1: Number of reviews, 2: Product title. */
_n(
'%1$s review for %2$s',
'%1$s reviews for %2$s',
$reviews_count,
'woocommerce'
),
number_format_i18n( $reviews_count ),
$product->get_title()
);
}
if ( ! $show_reviews_count && $show_product_title ) {
return 1 === $reviews_count
/* translators: %s: Product title. */
? sprintf( __( 'Review for %s', 'woocommerce' ), $product->get_title() )
: sprintf(
/* translators: %s: Product title. */
__( 'Reviews for %s', 'woocommerce' ),
$product->get_title()
);
}
if ( $show_reviews_count && ! $show_product_title ) {
return 1 === $reviews_count
/* translators: %s: Number of reviews. */
? __( 'One review', 'woocommerce' )
: sprintf(
/* translators: %s: Number of reviews. */
_n( '%s review', '%s reviews', $reviews_count, 'woocommerce' ),
number_format_i18n( $reviews_count )
);
}
if ( 1 === $reviews_count ) {
return __( 'Review', 'woocommerce' );
}
return __( 'Reviews', 'woocommerce' );
}