From f2a680cda524c15cd30bebe6b84cdaf5dc1569be Mon Sep 17 00:00:00 2001 From: Remco Tolsma <869674+remcotolsma@users.noreply.github.com> Date: Mon, 19 Feb 2024 14:36:41 +0100 Subject: [PATCH] Only display invoice to users we can read invoice. --- classes/Theme.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/classes/Theme.php b/classes/Theme.php index 2ecc472..80366c1 100644 --- a/classes/Theme.php +++ b/classes/Theme.php @@ -44,14 +44,16 @@ public function post_class( $classes ) { * @return array */ public function project_sections( $sections ) { - $sections[] = [ - 'id' => 'invoices', - 'slug' => __( 'invoices', 'orbis-projects' ), - 'name' => __( 'Invoices', 'orbis-projects' ), - 'callback' => function () { - include __DIR__ . '/../templates/project-invoices.php'; - }, - ]; + if ( \current_user_can( 'read_orbis_project_invoice', \get_the_ID() ) ) { + $sections[] = [ + 'id' => 'invoices', + 'slug' => __( 'invoices', 'orbis-projects' ), + 'name' => __( 'Invoices', 'orbis-projects' ), + 'callback' => function () { + include __DIR__ . '/../templates/project-invoices.php'; + }, + ]; + } return $sections; }