array( 'type' => 'boolean', 'default' => true, 'description' => __( 'Follow each child sitemap to collect page URLs. When false, only the child sitemap URLs listed in the index are returned.', 'acrossai-abilities-manager' ), ), 'limit' => array( 'type' => 'integer', 'default' => 250, 'minimum' => 1, 'maximum' => 1000, 'description' => __( 'Maximum URLs to return. Fetching stops once reached.', 'acrossai-abilities-manager' ), ), ); } protected function output_properties(): array { return array( 'index_url' => array( 'type' => 'string' ), 'sitemaps' => array( 'type' => 'array' ), 'urls' => array( 'type' => 'array' ), 'count' => array( 'type' => 'integer' ), 'children_fetched' => array( 'type' => 'integer' ), 'limit_reached' => array( 'type' => 'boolean' ), ); } 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 ) { $include_children = array_key_exists( 'include_children', $input ) ? (bool) $input['include_children'] : true; $limit = isset( $input['limit'] ) ? (int) $input['limit'] : 250; $limit = max( 1, min( 1000, $limit ) ); $result = Sitemap_Repository::list_urls( $include_children, $limit ); if ( is_wp_error( $result ) ) { return $result; } $result['message'] = sprintf( /* translators: 1: number of URLs returned, 2: number of child sitemaps in the index */ __( 'Returned %1$d URLs from %2$d child sitemaps.', 'acrossai-abilities-manager' ), $result['count'], count( $result['sitemaps'] ) ); return $result; } }