<?php
|
|
use JVBase\base\Site;
|
use JVBase\managers\Cache;
|
use JVBase\registrar\Registrar;
|
|
if (!defined('ABSPATH')) {
|
exit;
|
}
|
function jvbCheck(string $key, $config = []):bool
|
{
|
return (array_key_exists($key, $config) && $config[$key] === true);
|
}
|
|
function jvbUserTypes():array
|
{
|
return Registrar::getFeatured('profile_link', 'user');
|
}
|
|
|
//function jvbIsOpen():bool
|
//{
|
//
|
// if (!jvbCheck('limit_hours', JVB_SITE)) {
|
// return true;
|
// }
|
// if (get_option(BASE.'open_to_public') !== '1') {
|
// return false;
|
// }
|
// //Check if today_hours is set
|
// if (get_option(BASE.'today_hours')) {
|
// return jvbIsTimeBetween();
|
// }
|
// //Default to the stored settings
|
// return jvbIsCurrentlyOpen();
|
//}
|
|
|
function jvbTermHasPosts(int $termID, string $taxonomy):bool
|
{
|
$cache = Cache::for('termUtility', 30*60)->connect('taxonomy');
|
return $cache->remember(
|
$termID,
|
function() use($taxonomy, $termID) {
|
$taxonomy = jvbCheckBase($taxonomy);
|
$tax = get_taxonomy($taxonomy);
|
$query = new WP_Query([
|
'post_type' => $tax->object_type,
|
'posts_per_page' => 1,
|
'fields' => 'ids',
|
'tax_query' => [
|
[
|
'taxonomy' => $taxonomy,
|
'terms' => $termID
|
]
|
]
|
]);
|
$result = ($query->have_posts()) ? 'true' : 'false';
|
wp_reset_postdata();
|
return $result;
|
}
|
);
|
}
|