array( 'type' => 'integer', 'default' => 50, 'minimum' => 1, 'maximum' => 200, 'description' => __( 'Page size.', 'acrossai-abilities-manager' ), ), 'page' => array( 'type' => 'integer', 'default' => 1, 'minimum' => 1, 'description' => __( '1-based page number.', 'acrossai-abilities-manager' ), ), 'search' => array( 'type' => 'string', 'description' => __( 'Match against the logged URI.', 'acrossai-abilities-manager' ), ), 'orderby' => array( 'type' => 'string', 'enum' => array( 'id', 'uri', 'accessed', 'times_accessed' ), 'default' => 'accessed', 'description' => __( 'Sort column. Use times_accessed to find the most-requested missing URLs.', 'acrossai-abilities-manager' ), ), 'order' => array( 'type' => 'string', 'enum' => array( 'ASC', 'DESC' ), 'default' => 'DESC', 'description' => __( 'Sort direction.', 'acrossai-abilities-manager' ), ), ); } protected function output_properties(): array { return array( 'logs' => array( 'type' => 'array' ), 'count' => array( 'type' => 'integer' ), 'total' => array( 'type' => 'integer' ), 'page' => 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 = Log_Repository::listing( isset( $input['limit'] ) ? max( 1, min( 200, (int) $input['limit'] ) ) : 50, isset( $input['page'] ) ? max( 1, (int) $input['page'] ) : 1, isset( $input['search'] ) ? sanitize_text_field( (string) $input['search'] ) : '', isset( $input['orderby'] ) ? sanitize_key( (string) $input['orderby'] ) : 'accessed', isset( $input['order'] ) && 'ASC' === strtoupper( (string) $input['order'] ) ? 'ASC' : 'DESC' ); if ( is_wp_error( $result ) ) { return $result; } $result['message'] = sprintf( /* translators: 1: number returned, 2: total logged */ __( 'Returned %1$d of %2$d logged 404s.', 'acrossai-abilities-manager' ), $result['count'], $result['total'] ); return $result; } }