From 3baf3d2545ba6ece6b74a64c0def59bd0774cf54 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Wed, 10 Jun 2026 16:34:12 +0000
Subject: [PATCH] =Laid the groundwork for an improved DashboardManager.php setup. Have to put it aside so I can get the dang Northeh done though.
---
inc/managers/RoleManager.php | 24 ++++++++++++++++++------
1 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/inc/managers/RoleManager.php b/inc/managers/RoleManager.php
index b275f12..e859813 100644
--- a/inc/managers/RoleManager.php
+++ b/inc/managers/RoleManager.php
@@ -24,7 +24,7 @@
return strtolower(str_replace(' ', '_', $registrar->getPlural()??$registrar->getSingular().'s'));
},array_merge(
Registrar::getRegistered('post'),
- Registrar::getFeatured('is_content', 'term')
+ Registrar::withFeature('is_content', 'term')
));
add_action('set_user_role', [$this, 'updateRoles'], 10, 3);
@@ -441,9 +441,9 @@
$content = jvbNoBase($content);
$registrar = Registrar::getInstance($content);
if ($registrar && $registrar->getPlural()) {
- return str_replace(' ', '_', $registrar->getPlural());
+ return strtolower(str_replace(' ', '_', $registrar->getPlural()));
}
- return str_replace(' ', '_', $content.'s');
+ return strtolower(str_replace(' ', '_', $content.'s'));
}
public static function activate(): void
@@ -470,7 +470,7 @@
protected function addAdminCaps():void
{
$users = get_users(['role' => 'administrator']);
- foreach (array_merge(Registrar::getRegistered('post'), Registrar::getFeatured('is_content')) as $slug) {
+ foreach (array_merge(Registrar::getRegistered('post'), Registrar::withFeature('is_content')) as $slug) {
$this->grantRoleCapabilities('administrator', $slug);
$this->grantRoleOthersCapabilities('administrator', $slug);
@@ -785,7 +785,7 @@
if ($ownable === null) {
$ownable = array_map(function ($instance) {
return $instance->slug;
- }, Registrar::getFeatured('is_ownable', 'term'));
+ }, Registrar::withFeature('is_ownable', 'term'));
}
return $ownable;
@@ -803,7 +803,7 @@
if ($invitable === null) {
$invitable = array_map(function ($instance) {
return $instance->slug;
- }, Registrar::getFeatured('invitable', 'term'));
+ }, Registrar::withFeature('invitable', 'term'));
}
return $invitable;
@@ -821,6 +821,18 @@
}
return null;
}
+ public static function getPermissionName(string $action, string $content, ?int $ID = null):?string
+ {
+ $plural = (new self())->getContentPlural($content);
+ switch ($action) {
+ case 'edit':
+ if ($ID) {
+ return "edit_{$content}";
+ }
+ return "edit_{$plural}";
+ }
+ return null;
+ }
public function maybeSwitchPermissions(int $object_id, array $terms, array $tt_ids, string $taxonomy, bool $append, array $old_tt_ids):void
{
--
Gitblit v1.10.0