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.

Method of the class: Reviews{}

No Hooks.

Return

String|Mixed. Translated text.

Usage

// protected - for code of main (parent) or child class
$result = $this->edit_comments_screen_text( $translation, $text );
$translation(string|mixed) (required)
Translated text.
$text(string|mixed) (required)
Text to translate.

Reviews::edit_comments_screen_text() code WC 7.1.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'] ) && $_GET['action'] === 'editcomment' ) {
		$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 ) && get_post_type( $comment->comment_post_ID ) === 'product' ) {
		if ( $text === 'Edit Comment' ) {
			$translation = $is_reply
				? __( 'Edit Review Reply', 'woocommerce' )
				: __( 'Edit Review', 'woocommerce' );
		} elseif ( $text === 'Moderate Comment' ) {
			$translation = $is_reply
				? __( 'Moderate Review Reply', 'woocommerce' )
				: __( 'Moderate Review', 'woocommerce' );
		}
	}

	return $translation;
}