, unresolved: array} * Resolved post IDs in input order with duplicates collapsed, * and the entries that could not be resolved. */ public static function parse( string $raw ): array { $parts = preg_split( '/[\s,]+/', $raw ); if ( false === $parts ) { return array( 'ids' => array(), 'unresolved' => array(), ); } $ids = array(); $unresolved = array(); foreach ( $parts as $part ) { $part = trim( $part ); if ( '' === $part ) { continue; } if ( 1 === preg_match( '/^[0-9]+$/', $part ) ) { $id = (int) $part; if ( $id > 0 ) { $ids[ $id ] = true; } continue; } $id = function_exists( 'url_to_postid' ) ? (int) url_to_postid( $part ) : 0; if ( $id > 0 ) { $ids[ $id ] = true; continue; } $unresolved[ $part ] = true; } return array( // Keys carried the de-duplication; the caller wants a plain list. 'ids' => array_map( 'intval', array_keys( $ids ) ), 'unresolved' => array_keys( $unresolved ), ); } }