Automattic\WooCommerce\Internal\Admin\ProductReviews

Reviews::edit_review_parent_file()protectedWC 1.0

Highlights Product -> Reviews admin menu item when editing a review or a reply to a review.

Method of the class: Reviews{}

No Hooks.

Return

String.

Usage

// protected - for code of main (parent) or child class
$result = $this->edit_review_parent_file( $parent_file );
$parent_file(string|mixed) (required)
Parent menu item.

Notes

  • Global. String. $submenu_file

Reviews::edit_review_parent_file() code WC 7.1.0

protected function edit_review_parent_file( $parent_file ) {
	global $submenu_file, $current_screen;

	if ( isset( $current_screen->id, $_GET['c'] ) && $current_screen->id === 'comment' ) {

		$comment_id = absint( $_GET['c'] );
		$comment    = get_comment( $comment_id );

		if ( isset( $comment->comment_parent ) && $comment->comment_parent > 0 ) {
			$comment = get_comment( $comment->comment_parent );
		}

		if ( isset( $comment->comment_post_ID ) && get_post_type( $comment->comment_post_ID ) === 'product' ) {
			$parent_file  = 'edit.php?post_type=product';
			$submenu_file = 'product-reviews'; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
		}
	}

	return $parent_file;
}