| | |
| | | <?php |
| | | |
| | | use JVBase\meta\Form; |
| | | use JVBase\utility\Features; |
| | | use JVBase\utility\Image; |
| | | |
| | |
| | | <div class="actions row end"> |
| | | <button class="retry" data-action="retry"><span>Retry</span><?= jvbIcon('arrows-clockwise')?></button> |
| | | <button class="cancel" data-action="cancel"><span>Cancel</span><?= jvbIcon('x-square')?></button> |
| | | <button class="refresh" data-action="refresh" title="Refresh to see changes"><span>Refresh</span><?= jvbIcon('arrows-clockwise')?></button> |
| | | <button class="dismiss" data-action="dismiss"><span>Dismiss</span><?= jvbIcon('eye-closed')?></button> |
| | | |
| | | </div> |
| | | </div> |
| | | </template> |
| | |
| | | */ |
| | | function jvbSearch(string $placeholder = 'Search...', string $id = 'search'):string |
| | | { |
| | | $id = sanitize_title($id); |
| | | return sprintf( |
| | | '<div class="search-container row start nowrap"> |
| | | <input type="search" id="%s" placeholder="%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> |
| | | </div>', |
| | | $id, |
| | | $placeholder, |
| | | jvbIcon('x', ['title'=> 'Clear Search']), |
| | | jvbIcon('magnifying-glass') |
| | | ); |
| | | return Form::search($placeholder, $id); |
| | | } |
| | | |
| | | |
| | |
| | | function jvbImageCaption(int $imgID, string $start = 'tiny', string $end = 'large', bool $addLink = true, ?string $postSlug = null):string |
| | | { |
| | | $caption = wp_get_attachment_caption($imgID); |
| | | $caption = ($caption && $caption !== '') ? '<figcaption>'.apply_filters('the_content', $caption).'</figcaption>' : ''; |
| | | $caption = ($caption && $caption !== '') ? '<figcaption>'.jvb_filter_content( $caption).'</figcaption>' : ''; |
| | | return '<figure>'.jvbFormatImage($imgID, $start, $end, $addLink, $postSlug).$caption.'</figure>'; |
| | | } |
| | | |
| | |
| | | <h2>'.$config['title'].'</h2>'; |
| | | if ( array_key_exists('description', $config)) { |
| | | if (!is_array($config['description'])) { |
| | | $content .= apply_filters('the_content', $config['description']); |
| | | $content .= jvb_filter_content( $config['description']); |
| | | } else { |
| | | // foreach ($config['description'] as $desc) { |
| | | // $content .= apply_filters('the_content', $desc); |
| | | // $content .= jvb_filter_content( $desc); |
| | | // } |
| | | $content .= implode('',array_map(function ($paragraph) { |
| | | return apply_filters('the_content', $paragraph); |
| | | return jvb_filter_content( $paragraph); |
| | | }, $config['description'])); |
| | | } |
| | | |
| | |
| | | return $out; |
| | | } |
| | | |
| | | function jvbRenderProgressBar(string $inside ='', $top = false, $icon = true) |
| | | function jvbRenderProgressBar(string $inside ='', $top = false, $icon = true, $return = false):string |
| | | { |
| | | |
| | | $top = $top ? ' abs top' : ''; |
| | | ?> |
| | | <div class="progress<?=$top?>"> |
| | | $bar = sprintf( |
| | | '<div class="progress%s"> |
| | | <div class="bar"> |
| | | <div class="fill"></div> |
| | | </div> |
| | | <div class="row btw"> |
| | | <?php if ($icon) { ?> |
| | | <i class="icon"></i> |
| | | <?php } ?> |
| | | %s |
| | | <div class="details"> |
| | | <?=$inside?> |
| | | %s |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <?php |
| | | </div>', |
| | | $top, |
| | | ($icon) ? '<i class="icon"></i>': '', |
| | | $inside |
| | | ); |
| | | if (!$return) { |
| | | echo $bar; |
| | | } |
| | | return $bar; |
| | | } |
| | | |
| | | function jvbFormStatus(string $message = '') { |
| | |
| | | </div> |
| | | <div class="fstatus row" hidden> |
| | | <div class="spinner"></div> |
| | | <i class="icon"></i> |
| | | <p class="message">'.$message.'</p> |
| | | </div>'; |
| | | } |