', $hidden, $name, $name, $name, $labelBefore, $off, $on, $labelAfter ); } /** * @param int $ID * @param MetaManager|null $meta * * @return string */ function jvbRenderLinks(int $ID, MetaManager|null $meta = null):string { $cache = CacheManager::for('bio-'.$ID, WEEK_IN_SECONDS); $key = 'links'; $cached = $cache->get($key); if ($cached) { return $cached; } if (!$meta) { $meta = jvbGetMeta($ID); } $links = $meta->getValue('links'); $out = ''; if (!empty($links)) { $out = ''; } $cache->set($key, $out); return $out; } /** * @param int $ID * @param MetaManager|null $meta * * @return string */ function jvbRenderContactInfo(int $ID, MetaManager|null $meta = null):string { $cache = CacheManager::for('bio-'.$ID, WEEK_IN_SECONDS); $key = 'contact'; $cached = $cache->get($key); if($cached){ return $cached; } if (!$meta) { $meta = jvbGetMeta($ID); } $preference = $meta->getValue('public_contact'); $preference = (is_array($preference)) ? $preference : explode(',', $preference); $out = ''; if (!empty($preference)) { $out = ''; } $cache->set($key, $out); return $out; } /** * @param int $ID * @param MetaManager|null $meta * @return string */ function jvbRenderSpecialtyField(int $ID, MetaManager|null $meta = null):string { if (!$meta) { $meta = jvbGetMeta($ID); } $out = ''; $specialties = $meta->getValue('specialties'); if (!empty($specialties)) { foreach ($specialties as $specialty) { $out .= '
  • '.$specialty['specialty'].''; if ($specialty['description'] !== '') { $out .= apply_filters('the_content', $specialty['description']); } $out .= '
  • '; } } if ($out !== '') { $out = ''; } return $out; } /** * @param int $ID * @param MetaManager|null $meta * @return string */ function jvbRenderAwardsField(int $ID, MetaManager|null $meta = null):string { if (!$meta) { $meta = jvbGetMeta($ID); } $out = ''; $awards = $meta->getValue('awards'); if (!empty($awards)) { foreach ($awards as $award) { $out .= '
  • '.$award['name'].''; $out .= ($award['presenter'] !== '') ? ' | '.$award['presenter'].'' : ''; $out .= ($award['year'] !== '') ? ', '.$award['year'] : ''; $out .= '
  • '; } } if ($out !== '') { $out = ''; } return $out; } /** * @param int $ID * @param MetaManager|null $meta * @return string */ function jvbRenderReviewsField(int $ID, MetaManager|null $meta = null):string { if (!$meta) { $meta = jvbGetMeta($ID); } $out = ''; $reviews = $meta->getValue('reviews'); if (!empty($reviews)) { foreach ($reviews as $review) { if ($review['review'] === '') { continue; } $out .= '
  • '.apply_filters('the_content', $review['review']); if ($review['name'] !== '' || $review['rating'] !== 'none') { $date = $aOpen = $aClose = ''; if ($review['url']) { $aOpen = ''; $aClose = ''; } if ($review['date'] !== '') { $date = new Date('M j, Y', strtotime($review['date'])); } $out .= ''; if ($review['rating'] !== 'none') { $out .= jvbFormatStarRating($review['rating']); } if ($review['name'] !== '') { $out .= $aOpen.$review['name'].$aClose; } if ($date !== '') { $out .= $date; } $out .= ''; } $out .= '
  • '; } } if ($out !== '') { $out = ''; } return $out; } function jvbGetMeta(int $ID) { if (is_tax()) { $type = 'term'; } elseif (is_singular()) { $type = 'post'; } else { $type = 'user'; } return new JVBase\meta\MetaManager($ID, $type); } function jvbRenderTermList(array|bool|WP_Error $terms, string $label = '') { if (!$terms || is_wp_error($terms) || empty($terms)) { return ''; } $out = ($label === '') ? '' : '

    '.$label.'

    '; $out .= ''; return $out; } add_action('wp_footer', 'jvbOutputImageTemplates'); function jvbOutputImageTemplates() { if (wp_script_is('jvb-form')) { jvbInlineStyles('forms'); ?> $ID] : false; $addID = ($ID) ? '-'.$ID : ''; $fields = array_merge([ 'image_data' => [ 'type' => 'group', 'wrap' => 'details', 'label' => 'Image Info', 'hint' => 'These will be automatically generated if left blank.', 'fields' => [ 'image-title'.$addID => [ 'type' => 'text', 'label' => 'Image Title', 'value' => $title, 'data' => $dataID ], 'image-alt-text'.$addID => [ 'type' => 'text', 'label' => 'Alt Text', 'value' => $alt, 'hint' => 'Alt text helps the visually impaired, as well as some benefits for SEO.', 'data' => $dataID ], 'image-caption'.$addID => [ 'type' => 'textarea', 'value' => $caption, 'label' => 'Image Caption', 'data' => $dataID ] ] ] ], $fields); return $form->render('image_data',null, $fields,false, true); } function jvbLocationLinks(array $location): string { if (empty($location['address'])) { return ''; } $cache = CacheManager::for('locations'); $key = $cache->generateKey($location); $cached = false; if ($cached) { return $cached; } $firstPart = [ $location['street'], $location['city'], $location['province'], $location['postal_code'], $location['country'], ]; $address = implode(', ',$firstPart); $coords = $location['lat'].','.$location['lng']; $googleAddress = urlencode($coords.','.$address); $appAddress = urlencode($address); $google_url = "https://www.google.com/maps/dir/?api=1&destination={$googleAddress}"; $apple_url = "https://maps.apple.com/?daddr={$appAddress}"; $apple = sprintf( '%s', $apple_url, jvbIcon('apple-logo') ); $google = sprintf( '%s', $google_url, jvbIcon('google-logo') ); $cached = '

    '.jvbIcon('map-pin').'Find us here: '.$google.$apple.'

    '; $cache->set($key, $cached); return $cached; } add_action('jvbRenderFormField', 'jvbFormFields', 10, 3); function jvbFormFields(string $name, array $config, mixed $value):void { switch ($name) { case 'hours': echo jvbCopyHoursTemplate(); break; } }