| | |
| | | exit; |
| | | } |
| | | |
| | | define('JVB_LOADED', is_plugin_active('jvb/jvb.php')); |
| | | |
| | | use JVBase\base\Site; |
| | | use JVBase\managers\Cache; |
| | | use JVBase\managers\CacheManager; |
| | | use JVBase\meta\Meta; |
| | | use JVBase\registrar\Registrar; |
| | | |
| | | add_filter('jvb_base', function () { |
| | | return 'ajv_'; |
| | |
| | | const AJV_DIR = WP_PLUGIN_DIR . '/ajakevan'; |
| | | define('AJV_URL', plugin_dir_url(__FILE__)); |
| | | |
| | | add_filter('jvbChildDir', function() { return AJV_DIR; }); |
| | | add_filter('jvbChildUrl', function() { return AJV_URL; }); |
| | | |
| | | |
| | | require(AJV_DIR . '/blocks/_setup.php'); |
| | | require(AJV_DIR . '/content/_setup.php'); |
| | | //require(AJV_DIR . '/dashboard/setup.php'); |
| | |
| | | //require(AJV_DIR . '/files/fileManagement.php'); |
| | | require(AJV_DIR . '/seo.php'); |
| | | |
| | | add_action('plugins_loaded', 'ajv_siteDefinition', 2); |
| | | add_action('jvbLoadDefinitions', 'ajv_siteDefinition'); |
| | | function ajv_siteDefinition():void |
| | | { |
| | | if (!class_exists('JVBase\base\Site')) { |
| | | return; |
| | | } |
| | | $site = Site::getInstance(); |
| | | $site->set('icons', 'light'); |
| | | $site->setAll([ |
| | | 'is_directory', |
| | | 'dashboard', |
| | | 'magic_link', |
| | | 'feed_block', |
| | | 'support', |
| | | // 'faq', |
| | | 'referrals' |
| | | // 'has_map', |
| | | // 'referrals', |
| | | ]); |
| | | $site->setIntegrations([ |
| | | 'cloudflare', |
| | | // 'facebook', |
| | | 'gmb', |
| | | 'maps', |
| | | 'helcim', |
| | | 'postmark', |
| | | // 'instagram', |
| | | 'umami' |
| | | ]); |
| | | |
| | | $login = $site->login(); |
| | | $site->setDirectorySingular('List'); |
| | | $site->setDirectoryPlural('Lists'); |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * Defines base options like: |
| | |
| | | * - rewrite rules |
| | | * - archive title |
| | | */ |
| | | add_filter('jvb_site', 'ajv_setup_site'); |
| | | //add_filter('jvb_site', 'ajv_setup_site'); |
| | | function ajv_setup_site():array |
| | | { |
| | | return [ |
| | |
| | | 'icon' => 'user-square', |
| | | ] |
| | | ]; |
| | | foreach (JVB_CONTENT as $slug => $config) { |
| | | if (array_key_exists('public', $config) && !$config['public']) { |
| | | |
| | | foreach (Registrar::getRegistered('post') as $slug) { |
| | | |
| | | $registrar = Registrar::getInstance($slug); |
| | | if (!$registrar || !$registrar->registrar->public) { |
| | | continue; |
| | | } |
| | | $items[] = [ |
| | | 'text' => $config['singular'], |
| | | 'text' => $registrar->getSingular(), |
| | | 'url' => get_post_type_archive_link(BASE.$slug), |
| | | 'icon' => $config['icon'], |
| | | 'icon' => $registrar->getIcon(), |
| | | 'class' => $slug, |
| | | ]; |
| | | } |
| | |
| | | return '<p>I live and work in amiskwacîwâskahikan ᐊᒥᐢᑲᐧᒋᐋᐧᐢᑲᐦᐃᑲᐣ</p><p><a href="https://www.treatysix.org/#comp-lkljqlw1" title="Learn More">Treaty 6 territory</a></p><p>Edmonton, Alberta, Canada</p>'; |
| | | } |
| | | |
| | | add_filter('jvbRegisterCustomIcons', 'jv_custom_icons'); |
| | | function jv_custom_icons(array $icons):array |
| | | add_filter('jvbRegisterCustomIcons', 'ajv_custom_icons'); |
| | | function ajv_custom_icons(array $icons):array |
| | | { |
| | | $icons['logo'] = AJV_DIR . '/assets/icons/logo-concentric.svg'; |
| | | $icons['logo-jakevan'] = AJV_DIR . '/assets/icons/logo-concentric-jakevan.svg'; |
| | |
| | | $icons['logo-right-jakevan'] = AJV_DIR . '/assets/icons/logo-right-aligned-jakevan.svg'; |
| | | $icons['jakevan'] = AJV_DIR . '/assets/icons/jakevan.svg'; |
| | | $icons['loading'] = AJV_DIR . '/assets/icons/loading.svg'; |
| | | // $icons['art'] = AJV_DIR . '/assets/icons/jakevan-does-art.svg'; |
| | | // $icons['design'] = AJV_DIR . '/assets/icons/jakevan-does-design.svg'; |
| | | // $icons['development'] = AJV_DIR . '/assets/icons/jakevan-does-development.svg'; |
| | | // $icons['project'] = AJV_DIR . '/assets/icons/jakevan-does-project.svg'; |
| | | // $icons['strategy'] = AJV_DIR . '/assets/icons/jakevan-does-strategy.svg'; |
| | | // $icons['writing'] = AJV_DIR . '/assets/icons/jakevan-does-writing.svg'; |
| | | return $icons; |
| | | } |
| | | |
| | |
| | | && array_key_exists('className', $block['attrs']) |
| | | && $block['attrs']['className'] === 'is-style-fixed' |
| | | && $nav === '') { |
| | | $text = '<li><a href="'.jvbTextLink(8258239916,'I have an idea - can you help bring it to life?').'" title="Text Me">'.jvbIcon('chat').'<span class="hide-small">825.823.9916</span></a></li>'; |
| | | $email = '<li><a href="'.jvbMailToLink( |
| | | $text = sprintf( |
| | | '<li><a href="%s" title="Text Me">%s<span class="hide-small">825.823.9916</span></a></li>', |
| | | jvbTextLink(8258239916,'I have an idea - can you help bring it to life?'), |
| | | jvbIcon('chat') |
| | | ); |
| | | $email = sprintf( |
| | | '<li><a href="%s" title="Email Me">%s<span class="hide-small">get@jakevan.ca</span></a></li>', |
| | | |
| | | jvbMailToLink( |
| | | 'get@jakevan.ca', |
| | | '[JakeVan] I have an idea - can you help bring it to life?','Be sure to as much detail as possible, including what your idea is about, when you need it done by, and budget.' |
| | | ).'" title="Email Me">'.jvbIcon('envelope').'<span class="hide-small">get@jakevan.ca</span></a></li>'; |
| | | ), |
| | | jvbIcon('envelope') |
| | | ); |
| | | |
| | | return $text.$email; |
| | | } |
| | |
| | | { |
| | | $extra = match($type) { |
| | | 'strategy' => 'Edmonton-focused brand', |
| | | 'project' => 'Edmonton-based', |
| | | default => 'Edmonton made' |
| | | }; |
| | | $title = ($type === 'directory') ? 'Directory' : JVB_CONTENT[$type]['singular']; |
| | | $title = ($type === 'directory') ? 'Directory' : Registrar::getInstance($type)->getSingular(); |
| | | return '<small>'.$extra.'</small>'.$title.'.'; |
| | | } |
| | | |
| | | add_filter('jvbSummaryHeaderExtra', 'altr_summary_extra', 10, 2); |
| | | function altr_summary_extra(string $return, string $type):string |
| | | add_filter('jvbSummaryHeaderExtra', 'ajv_summary_extra', 10, 2); |
| | | function ajv_summary_extra(string $return, string $type):string |
| | | { |
| | | return ($type === 'directory') ? '' : '<p>Or see <a href="'.JVB()->directories()->getDirectoryList()[$type]['url'].'">alphabetical list</a>.</p>'; |
| | | } |
| | | |
| | | function ajv_render_core_post_content(array $block, string $content = ''):string |
| | | function ajv_prerender_core_post_content(array $block, ?string $content, ?WP_Block $parent):?string |
| | | { |
| | | if(!is_singular(array_map(function($item) { return BASE.$item; }, array_keys(JVB_CONTENT)))) { |
| | | return JVB()->blocks()->render_core_post_content($block, $content); |
| | | if(!is_singular(array_map(function($item) { return BASE.$item; }, Registrar::getRegistered('post')))) { |
| | | return null; |
| | | } |
| | | |
| | | $postType = jvbNoBase(get_post_type()); |
| | | $function = "ajv_render_{$postType}_content"; |
| | | $function = "ajv_prerender_{$postType}_content"; |
| | | |
| | | $base = ''; |
| | | if (function_exists($function)) { |
| | | $base = call_user_func($function, $block, $content); |
| | | $base = $function($block,$content,$parent); |
| | | } |
| | | return $base.JVB()->blocks()->render_core_post_content($block, $content); |
| | | return $base; |
| | | // return $base.JVB()->blocks()->prerender_core_post_content($block, $content, $parent); |
| | | } |
| | | |
| | | add_filter('the_seo_framework_meta_render_data', 'ajvb_no_next_archive', 10, 1); |
| | | function ajvb_no_next_archive($tags) { |
| | | if (is_tax() || is_post_type_archive()) { |
| | | if (array_key_exists('next', $tags)) { |
| | | unset($tags['next']); |
| | | } |
| | | } |
| | | return $tags; // Keep the link for other pages |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | add_filter('jvbSummaryDetailsOutput', 'ajvb_summary_info',10, 1); |
| | | function ajvb_summary_info(string $return):string |
| | | { |
| | | if (!is_singular(array_map(function($item) { return BASE.$item;}, Registrar::getRegistered('post')))) { |
| | | return $return; |
| | | } |
| | | |
| | | $return = ajvb_term_list(); |
| | | $return .= ajvb_meta_output(); |
| | | |
| | | return $return; |
| | | } |
| | | |
| | | function ajvb_term_list():string |
| | | { |
| | | if (empty(Registrar::getRegistered('term'))){ |
| | | return ''; |
| | | } |
| | | $ID = get_the_ID(); |
| | | $type = jvbNoBase(get_post_type($ID)); |
| | | |
| | | $registrar = Registrar::getInstance($type); |
| | | $taxonomies = $registrar->registrar->taxonomies; |
| | | |
| | | $lists = []; |
| | | foreach ($taxonomies as $taxonomy) { |
| | | $baseless = jvbNoBase($taxonomy); |
| | | $taxRegistrar = Registrar::getInstance($baseless); |
| | | $terms = wp_get_object_terms($ID, $taxonomy); |
| | | if ($terms && !is_wp_error($terms)) { |
| | | $list = sprintf( |
| | | '<li>%s<span>%s</span><ul class="term-list">', |
| | | jvbIcon($taxRegistrar->getIcon()), |
| | | $taxRegistrar->getPlural() |
| | | ); |
| | | foreach ($terms as $term) { |
| | | $list .= sprintf( |
| | | '<li><a href="%s" rel="tag">%s</a></li>', |
| | | get_term_link($term), |
| | | $term->name |
| | | ); |
| | | } |
| | | $list .='</ul></li>'; |
| | | $lists[] = $list; |
| | | } |
| | | } |
| | | $out =''; |
| | | if (!empty($lists)){ |
| | | $out = sprintf( |
| | | '<ul class="ajv-term-list">%s</ul>', |
| | | implode('',$lists) |
| | | ); |
| | | } |
| | | |
| | | return $out; |
| | | |
| | | } |
| | | |
| | | function ajvb_meta_output():string |
| | | { |
| | | if (!class_exists('JVBase\meta\Meta')) { |
| | | return ''; |
| | | } |
| | | $ID = get_the_ID(); |
| | | $type = jvbNoBase(get_post_type($ID)); |
| | | |
| | | return apply_filters('ajvb_summary_meta_output', '', $type); |
| | | } |
| | | |
| | | function ajvb_format_needs(array $needs):string |
| | | { |
| | | $theNeeds = ''; |
| | | foreach ($needs as $need) { |
| | | $theNeeds .= sprintf( |
| | | '<li><h3>%s</h3>%s<div class="info">%s</div></li>', |
| | | $need['need'], |
| | | $need['image'] !== '' ? jvbFormatImage((int)$need['image']) : '', |
| | | $need['fulfilled'] |
| | | ); |
| | | } |
| | | return sprintf( |
| | | '<section id="needs"><h2>What we needed:</h2><ul class="needs-wants">%s</ul></section>', |
| | | $theNeeds |
| | | ); |
| | | } |
| | | |
| | | function ajvb_format_wants(array $wants):string |
| | | { |
| | | $theWants = ''; |
| | | foreach ($wants as $want) { |
| | | $theWants .= sprintf( |
| | | '<li><h3>%s</h3>%s<div class="info">%s</div></li>', |
| | | $want['need'], |
| | | $want['image'] !== '' ? jvbFormatImage($want['image']) : '', |
| | | $want['fulfilled'] |
| | | ); |
| | | } |
| | | return sprintf( |
| | | '<section id="wants"><h2>What we wanted:</h2><ul class="needs-wants">%s</ul></section>', |
| | | $theWants |
| | | ); |
| | | } |
| | | |
| | | function ajv_is_singular(null|array|string $types = null):bool |
| | | { |
| | | if ($types) { |
| | | if (is_string($types)) { |
| | | $types = [$types]; |
| | | } |
| | | $types = array_map(function($type) { return jvbCheckBase($type); }, $types); |
| | | |
| | | }else { |
| | | $types = Cache::for('ajakevan')->remember( |
| | | 'types', |
| | | function() { |
| | | return array_map(function($type) { return jvbCheckBase($type);}, Registrar::getRegistered('post')); |
| | | } |
| | | ); |
| | | } |
| | | return is_singular($types); |
| | | } |