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 8.7.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 = isset( $comment->comment_parent ) && $comment->comment_parent > 0;

	// 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;
}