| | |
| | | /** |
| | | * Render complete form from Meta instance |
| | | */ |
| | | public static function renderFormFrom(Meta $meta, string $endpoint, array $options = []): string |
| | | public static function renderFormFrom(Meta $meta, string $endpoint, array $options = [], array $fields = []): string |
| | | { |
| | | $id = $options['form-id'] ?? $endpoint; |
| | | $classes = isset($options['classes']) ? ' class="' . implode(' ', $options['classes']) . '"' : ''; |
| | |
| | | $output .= '<p>' . esc_html($d) . '</p>'; |
| | | } |
| | | } |
| | | |
| | | foreach ($meta->configs() as $name => $config) { |
| | | $output .= static::render($name, $meta->get($name), $config); |
| | | $allFields = $meta->getAll($fields); |
| | | foreach ($allFields as $name => $value) { |
| | | $config = $meta->config($name); |
| | | $output .= static::render($name, $value, $config); |
| | | } |
| | | |
| | | if (!empty($options['submit'])) { |
| | |
| | | if (!array_key_exists('class', $config)) { |
| | | $config['class'] = []; |
| | | } |
| | | $config['class'][] ='row btw'; |
| | | $config['class'][] ='row x-btw'; |
| | | |
| | | $checked = filter_var($value, FILTER_VALIDATE_BOOLEAN); |
| | | |
| | |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="selection-actions row btw" hidden> |
| | | <div class="selection-actions row x-btw" hidden> |
| | | <button type="button" data-action="add-to-group"> |
| | | %sGroup |
| | | </button> |
| | |
| | | protected static function renderUploadItemActions(?int $attachmentId = null):string |
| | | { |
| | | return sprintf( |
| | | '<div class="item-actions row btw"> |
| | | '<div class="item-actions row x-btw"> |
| | | <div class="btn"> |
| | | <input type="radio" class="featured btn" name="featured" id="featured%s" hidden> |
| | | <label for="featured"> |
| | |
| | | $containerId = sprintf('%s-%s-selector', $name, $config['subtype']); |
| | | |
| | | $input = sprintf( |
| | | '<div class="row btw"> |
| | | '<div class="row x-btw"> |
| | | <input type="hidden" name="%s" value="%s"> |
| | | <label for="%s-autocomplete">%s<span>%s</span></label>', |
| | | esc_attr($name), |
| | |
| | | } |
| | | $plural = static::getPlural($config); |
| | | $input .= sprintf( |
| | | '<div class="selected-items row start" role="region" aria-label="Selected %s"></div>', |
| | | '<div class="selected-items row left" role="region" aria-label="Selected %s"></div>', |
| | | $plural[1]??'' |
| | | ); |
| | | |
| | |
| | | $config['data']['tag-format'] = esc_attr($tagFormat); |
| | | |
| | | $input = sprintf( |
| | | '<h3>%s</h3><div class="row start wrap">', |
| | | '<h3>%s</h3><div class="row left wrap">', |
| | | esc_html($config['label']??'') |
| | | ); |
| | | |
| | |
| | | %s |
| | | </button> |
| | | <details%s> |
| | | <summary class="row btw repeater-row-header"> |
| | | <summary class="row x-btw repeater-row-header"> |
| | | <span class="drag-handle">%s</span> |
| | | <span class="row-number">#%s</span> |
| | | <span class="row-title">%s</span> |
| | |
| | | { |
| | | return sprintf('<dialog id="jvb-selector" aria-labelledby="modal-title" aria-modal="true"> |
| | | <div class="wrap col"> |
| | | <header class="modal-header"> |
| | | <header class="row"> |
| | | <h3 id="modal-title">Select Taxonomy</h3> |
| | | </header> |
| | | |
| | |
| | | <div class="items-wrap"> |
| | | <!-- Common/Favorite terms section --> |
| | | <details class="favourite-terms" hidden> |
| | | <summary class="title row btw">Your Go Tos:</summary> |
| | | <ul class="favourite-list row btw"></ul> |
| | | <summary class="title row x-btw">Your Go Tos:</summary> |
| | | <ul class="favourite-list row x-btw"></ul> |
| | | </details> |
| | | |
| | | <!-- Pagination info --> |
| | |
| | | { <span>loading items</span> } |
| | | </p> |
| | | <!-- Terms list --> |
| | | <ul class="items-container col start" role="listbox" aria-label="Available terms"> |
| | | <ul class="items-container col top" role="listbox" aria-label="Available terms"> |
| | | <!-- Terms will be populated here --> |
| | | </ul> |
| | | |
| | |
| | | |
| | | <!-- Create new term section --> |
| | | <details class="create-term" hidden> |
| | | <summary class="row btw">Add New Term</summary> |
| | | <summary class="row x-btw">Add New Term</summary> |
| | | <div class="create-new-term-section"> |
| | | <form class="create-term" data-nocache data-form-id="create-term" data-save="terms"> |
| | | <div class="form-group"> |
| | |
| | | <template class="selectedTerm"> |
| | | <div class="selected-item row"> |
| | | <span class="item-name"></span> |
| | | <button type="button" class="remove-term row">%s</button> |
| | | <button type="button" class="remove-term">%s</button> |
| | | </div> |
| | | </template> |
| | | <template class="termBreadcrumb"> |
| | | <button type="button" class="path-level"></button> |
| | | </template>', |
| | | static::search('Search terms', 'search-terms'), |
| | | str_replace('class="search-container', 'class="open search-container', static::search('Search terms', 'search-terms')), |
| | | jvbModalActions(), |
| | | jvbIcon('plus-square'), |
| | | jvbIcon('x') |
| | | ); |
| | | } |
| | | |
| | | public static function search(string $placeholder = 'Search...', string $id = 'search'):string |
| | | public static function search(string $placeholder = 'Search...', string $id = 'search', string $label = '', string $buttonText = '',bool $buttonInside = false, bool $hideSearch = false):string |
| | | { |
| | | $id = sanitize_title($id); |
| | | $label = empty($label) ? '' : sprintf( |
| | | '<h3>%s</h3>', |
| | | $label |
| | | ); |
| | | $buttonText = empty($buttonText) ? '' : sprintf( |
| | | '<span>%s</span>', |
| | | $buttonText |
| | | ); |
| | | $hideSearch = $hideSearch ? ' hidden' : ''; |
| | | return sprintf( |
| | | '<div class="search-container row start nowrap"> |
| | | <input type="search" id="%s" placeholder="%s"> |
| | | '%s<div class="search-container row left nowrap%s"> |
| | | <input type="search" id="%s" placeholder="%s"%s> |
| | | <button title="Clear Search" type="button" class="clear-search" aria-label="Clear search" |
| | | onclick="this.previousElementSibling.value = \'\'; this.previousElementSibling.focus();">%s</button> |
| | | <button type="button" title="Search" class="toggle search" aria-label="Toggles search input visually" onclick="this.parentNode.classList.toggle(\'open\');this.previousElementSibling.previousElementSibling.focus();">%s</button> |
| | | <button type="button" title="Search" class="toggle search" aria-label="Toggles search input visually" onclick="this.parentNode.classList.toggle(\'open\');this.previousElementSibling.previousElementSibling.focus();">%s%s</button> |
| | | </div>', |
| | | $label, |
| | | $buttonInside ? ' insideButton' : '', |
| | | $id, |
| | | $placeholder, |
| | | $hideSearch, |
| | | jvbIcon('x', ['title' => 'Clear Search']), |
| | | jvbIcon('magnifying-glass') |
| | | jvbIcon('magnifying-glass'), |
| | | $buttonText |
| | | ); |
| | | } |
| | | } |