roles) ); $creatable = []; foreach ($roles as $role) { $creatable = array_merge($creatable, JVB_USER[$role]['can_create']??[]); } $creatable = jvbExtractUserContent($creatable); return !empty($creatable); } function jvbRolesWithDashboard():array { return array_keys(array_filter(JVB_USER, function ($role) { return jvbCheck('has_dashboard', $role); })); } function jvbSiteHasTermApproval():bool { return jvbCheck('terms_approval', JVB_MEMBERSHIP); } function jvbUserIsVerified():bool { return !(Features::forMembership()->has('member_verified')) || current_user_can('skip_moderation'); } function jvbUserTypes():array { $types = get_option(BASE.'user_types'); if (JVB_TESTING) { $types = false; } if ($types === false) { $types = []; foreach (JVB_USER as $type => $config) { if (array_key_exists('profile', $config)) { $types[$type] = BASE.$config['profile']; } } update_option(BASE.'user_types', $types); } return $types; } function isJVBUserType():bool { return (is_singular(jvbUserTypes()) || is_post_type_archive(jvbUserTypes())); } function contentIsJVBUserType(string $content):bool { $content = jvbCheckBase($content); return in_array($content, jvbUserTypes()); } function isJVBContentTax():bool { return is_tax(jvbContentTaxonomies()); } function taxIsJVBContentTax($tax):bool { $tax = jvbCheckBase($tax); return in_array($tax, jvbContentTaxonomies()); } function jvbSiteHasIntegrations():bool { return array_key_exists('integrations', JVB_SITE) && !empty(JVB_SITE['integrations']); } 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 jvbIsValidType(string $type):bool { return (array_key_exists($type, JVB_CONTENT) || array_key_exists($type, JVB_TAXONOMY) || array_key_exists($type, JVB_USER) || $type === 'options'); } function jvbGetObjectType(string $type):string { if (array_key_exists($type, JVB_CONTENT)) { return 'post'; } elseif (array_key_exists($type, JVB_TAXONOMY)) { return 'term'; } elseif (array_key_exists($type, JVB_USER)) { return 'user'; } elseif ($type === 'options') { return 'options'; } return ''; } function jvbTermHasPosts(int $termID, string $taxonomy):bool { $cache = CacheManager::for('terms', 30*60)->connectTo('taxonomy'); $key = $termID.$taxonomy; $cached = $cache->get($key); if ($cached) { return ($cached === 'true'); } $taxonomy = jvbCheckBase($taxonomy); $tax = get_taxonomy($taxonomy); $query = new WP_Query([ 'post_type' => $tax->object_type, 'posts_per_page' => 1, 'fields' => 'id', 'tax_query' => [ [ 'taxonomy' => $taxonomy, 'terms' => $termID ] ] ]); $result = ($query->have_posts()) ? 'true': 'false'; wp_reset_postdata(); $cache->set($key, $result); return $result === 'true'; }