is_available() || $this->manager instanceof AccessControlManager ) { return; } $this->manager = new AccessControlManager( self::PROVIDERS_FILTER, self::TABLE_SLUG ); } /** * Register the library REST routes when available. * * @return void */ public function register_rest_api(): void { $manager = $this->get_manager(); if ( null === $manager ) { return; } $manager->register_rest_api(); } /** * Check whether the access-control library is available. * * @return bool */ public function is_available(): bool { return class_exists( AccessControlManager::class ); } /** * Return the manager instance when available. * * @return AccessControlManager|null */ public function get_manager(): ?AccessControlManager { if ( ! $this->manager instanceof AccessControlManager ) { $this->boot_manager(); } return $this->manager; } /** * Register a notice in the shared AcrossAI notices collection when the * wpb-access-control library is absent. * * Hooked to the `acrossai_notices` filter provided by * `acrossai-co/main-menu` 0.0.30+. The notice surfaces on the AcrossAI → * Notices submenu (rendered by `NoticesPageRenderer`) and as a summary * banner on every other admin page (`SummaryNoticeEmitter`). Ensures * admins are aware that per-ability rules are inactive (fail-open, per * DEC-PERM-CB) without adding a raw wp-admin banner. (SAC-01 / MEDIUM-03) * * @since 0.1.0 * @param array $notices Current notice records keyed 0..N; see main-menu Notices class. * @return array Notice list with the library-missing entry appended when applicable. */ public function register_library_notice( $notices ) { if ( ! is_array( $notices ) ) { $notices = array(); } if ( $this->is_available() ) { return $notices; } $notices[] = array( 'id' => 'wpb_access_control_missing', 'title' => __( 'Access-control library is not loaded', 'acrossai-abilities-manager' ), 'message' => sprintf( /* translators: %s: library class name */ __( 'The wpb-access-control library (%s) is not loaded. Per-ability access-control rules are inactive and all ability checks will pass (fail-open). Install or activate the library to enforce saved rules.', 'acrossai-abilities-manager' ), 'WPBoilerplate\\AccessControl\\AccessControlManager' ), 'type' => 'warning', 'source' => __( 'AcrossAI Abilities Manager', 'acrossai-abilities-manager' ), ); return $notices; } }