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.

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

Хуков нет.

Возвращает

Строку.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->edit_review_parent_file( $parent_file );
$parent_file(строка|разное) (обязательный)
Parent menu item.

Заметки

  • Global. Строка. $submenu_file

Код Reviews::edit_review_parent_file() WC 8.7.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;
}