array( 'type' => 'string', 'description' => __( 'Restrict to one role slug, e.g. editor. Omit for every role.', 'acrossai-abilities-manager' ), ), ); } protected function output_properties(): array { return array( 'capabilities' => array( 'type' => 'array' ), 'roles' => array( 'type' => 'object' ), 'role_count' => array( 'type' => 'integer' ), 'cap_count' => array( 'type' => 'integer' ), ); } protected function required_input(): array { return array(); } protected function annotations(): array { return array( 'readonly' => true, 'destructive' => false, 'idempotent' => true ); } /** * @param array $input * @return array|WP_Error */ protected function run( array $input ) { $result = Role_Capability_Repository::matrix( isset( $input['role'] ) ? sanitize_key( (string) $input['role'] ) : '' ); if ( is_wp_error( $result ) ) { return $result; } $result['message'] = sprintf( /* translators: 1: number of capabilities, 2: number of roles */ __( 'Returned %1$d Rank Math capabilities across %2$d roles.', 'acrossai-abilities-manager' ), $result['cap_count'], $result['role_count'] ); return $result; } }