array( 'fw-enc-url' ), 'enclosure: choose where the size' => array( 'fw-enc-length' ), 'enclosure: choose where the type' => array( 'fw-enc-type' ), 'enclosure: the fixed type' => array( 'fw-enc-type' ), 'enclosure:' => array( 'fw-enc-url' ), 'output path "enclosure"' => array( 'fw-enc-url' ), 'give the feed a name' => array( 'fw-name' ), 'url slug' => array( 'fw-slug' ), 'another feed already uses' => array( 'fw-slug' ), 'item limit' => array( 'fw-limit' ), 'content type' => array( 'fw-type-post', 'feedweaver-post-types' ), 'custom date format' => array( 'fw-date-custom', 'fw-date-format' ), 'supported date format' => array( 'fw-date-format' ), 'root name' => array( 'fw-root' ), 'item element name' => array( 'fw-item' ), 'top-level or item name' => array( 'fw-root' ), 'channel title' => array( 'fw-rss-title' ), 'channel link' => array( 'fw-rss-link' ), 'channel description' => array( 'fw-rss-description' ), 'language must be' => array( 'fw-rss-language' ), 'copyright' => array( 'fw-rss-copyright' ), 'managing editor' => array( 'fw-rss-editor' ), 'title or a description' => array( 'fw-path-0' ), 'at least one field mapping' => array( 'feedweaver-add-mapping' ), 'taxonomy' => array( 'feedweaver-taxonomies' ), 'term chosen' => array( 'feedweaver-taxonomies' ), 'filter by at most' => array( 'feedweaver-taxonomies' ), 'at most 50 terms' => array( 'feedweaver-taxonomies' ), 'namespaces' => array( 'feedweaver-ns-section' ), ); foreach ( $map as $needle => $targets ) { if ( false !== strpos( $text, $needle ) ) { return $targets; } } return array(); } /** * Messages with their candidate controls, ready for the page and for JSON. * * @param string[] $messages Validation messages. * @return array */ public static function describe( array $messages ): array { $out = array(); foreach ( $messages as $message ) { $message = (string) $message; $out[] = array( 'message' => $message, 'targets' => self::locate( $message ), ); } return $out; } }