Automattic\WooCommerce\Internal\Admin\ProductReviews

Reviews::edit_comments_screen_text()protectedWC 1.0

Replaces Edit/Moderate Comment title/headline with Edit Review, when editing/moderating a review.

{} Это метод класса: Reviews{}

Хуков нет.

Возвращает

Строку|Разное. Translated text.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->edit_comments_screen_text( $translation, $text );
$translation(строка|разное) (обязательный)
Translated text.
$text(строка|разное) (обязательный)
Text to translate.

Код Reviews::edit_comments_screen_text() WC 6.8.0

protected function edit_comments_screen_text( $translation, $text ) {
	global $comment;

	// Bail out if not a text we should replace.
	if ( ! in_array( $text, [ 'Edit Comment', 'Moderate Comment' ], true ) ) {
		return $translation;
	}

	// Try to get comment from query params when not in context already.
	if ( ! $comment && isset( $_GET['action'], $_GET['c'] ) && 'editcomment' === $_GET['action'] ) {
		$comment_id = absint( $_GET['c'] );
		$comment    = get_comment( $comment_id ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
	}

	$is_reply = false;

	if ( isset( $comment->comment_parent ) && $comment->comment_parent > 0 ) {
		$is_reply = true;
		$comment = get_comment( $comment->comment_parent ); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
	}

	// Only replace the translated text if we are editing a comment left on a product (ie. a review).
	if ( isset( $comment->comment_post_ID ) && 'product' === get_post_type( $comment->comment_post_ID ) ) {
		if ( 'Edit Comment' === $text ) {
			$translation = $is_reply
				? __( 'Edit Review Reply', 'woocommerce' )
				: __( 'Edit Review', 'woocommerce' );
		} elseif ( 'Moderate Comment' === $text ) {
			$translation = $is_reply
				? __( 'Moderate Review Reply', 'woocommerce' )
				: __( 'Moderate Review', 'woocommerce' );
		}
	}

	return $translation;
}