*/ protected function input_properties(): array { return array(); } /** * @since 0.0.34 * @return array */ protected function required_input(): array { return array(); } /** * @since 0.0.34 * @return array */ protected function output_properties(): array { return array( 'packs' => array( 'type' => 'array', 'items' => array( 'type' => 'object', 'additionalProperties' => true ), ), 'library_connected' => array( 'type' => 'boolean', 'description' => __( 'Whether this site is signed in to the WPCode library.', 'acrossai-abilities-manager' ), ), 'connect_url' => array( 'type' => 'string', 'description' => __( 'When not connected, the wp-admin URL a person should open to sign in. No ability can sign in on their behalf.', 'acrossai-abilities-manager' ), ), 'count' => array( 'type' => 'integer' ), ); } /** * @since 0.0.34 * @return array */ protected function annotations(): array { return array( 'readonly' => true, 'destructive' => false, 'idempotent' => true ); } /** * @since 0.0.34 * @param array $input Input. * @return array|WP_Error */ protected function run( array $input ) { $packs = Library_Repository::packs(); if ( is_wp_error( $packs ) ) { return $packs; } $connection = Library_Repository::connection(); return array( 'packs' => $packs, 'count' => count( $packs ), 'library_connected' => (bool) $connection['connected'], 'connect_url' => (string) $connection['connect_url'], 'message' => Library_Repository::reader_message( $connection, sprintf( /* translators: %d: number of packs. */ _n( '%d snippet pack available.', '%d snippet packs available.', count( $packs ), 'acrossai-abilities-manager' ), count( $packs ) ) ), ); } }