array( 'type' => 'string', 'enum' => array( 'all', 'manual', 'auto' ), 'default' => 'all', 'description' => __( 'Which submissions to include.', 'acrossai-abilities-manager' ), ), 'limit' => array( 'type' => 'integer', 'default' => 50, 'minimum' => 1, 'maximum' => 500, 'description' => __( 'Maximum entries to return.', 'acrossai-abilities-manager' ), ), ); } protected function output_properties(): array { return array( 'entries' => array( 'type' => 'array' ), 'count' => array( 'type' => 'integer' ), 'filtered' => array( 'type' => 'integer' ), 'total' => array( 'type' => 'integer' ), 'filter' => array( 'type' => 'string' ), ); } 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 ) { $filter = isset( $input['filter'] ) ? sanitize_key( (string) $input['filter'] ) : 'all'; if ( ! in_array( $filter, array( 'all', 'manual', 'auto' ), true ) ) { return new WP_Error( 'invalid_input', __( 'filter must be all, manual or auto.', 'acrossai-abilities-manager' ) ); } $limit = isset( $input['limit'] ) ? (int) $input['limit'] : 50; $limit = max( 1, min( 500, $limit ) ); $result = Instant_Indexing_Repository::log( $filter, $limit ); if ( is_wp_error( $result ) ) { return $result; } $result['message'] = sprintf( /* translators: 1: number of entries returned, 2: total entries in the log */ __( 'Returned %1$d of %2$d IndexNow log entries.', 'acrossai-abilities-manager' ), $result['count'], $result['total'] ); return $result; } }