%s
%s
%s
%s
',
$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 = new JVBase\managers\CacheManager('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 = new JVBase\managers\CacheManager('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-uploader')) {
?>
Drag here to create new group!
= jvbImageMeta() ?>
0 items selected
= jvbIcon('add') ?>
New Group
Processing files...
0/0 ')?>
=jvbIcon('edit')?>Edit Image Info
Looks like we left things hanging
If you'd rather start over, you can clear this information.
= jvbIcon('restore') ?>
Restore Selected
= jvbIcon('close') ?>
Clear Cache
Start Over?
This will permanently delete:
All newly uploaded images
All newly created groups
All newly created metadata and settings
This cannot be undone!
Cancel
Yes, Start Over
Image Title
Image Caption
These will be automatically generated if left blank.
';
}
function jvbLocationLinks(array $location): string {
if (empty($location['address'])) {
return '';
}
$cache = new \JVBase\managers\CacheManager('location');
$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;
}
}