| | |
| | | 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); |
| | | |
| | |
| | | $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 |
| | |
| | | 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); |
| | | |
| | |
| | | if ($ownable === null) { |
| | | $ownable = array_map(function ($instance) { |
| | | return $instance->slug; |
| | | }, Registrar::getFeatured('is_ownable', 'term')); |
| | | }, Registrar::withFeature('is_ownable', 'term')); |
| | | } |
| | | |
| | | return $ownable; |
| | |
| | | if ($invitable === null) { |
| | | $invitable = array_map(function ($instance) { |
| | | return $instance->slug; |
| | | }, Registrar::getFeatured('invitable', 'term')); |
| | | }, Registrar::withFeature('invitable', 'term')); |
| | | } |
| | | |
| | | return $invitable; |
| | |
| | | } |
| | | 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 |
| | | { |