=added functions for outputting custom meta fields for our post types
| | |
| | | } |
| | | |
| | | use JVBase\managers\CacheManager; |
| | | use JVBase\meta\Meta; |
| | | |
| | | add_filter('jvb_base', function () { |
| | | return 'ajv_'; |
| | |
| | | } |
| | | return $base.JVB()->blocks()->render_core_post_content($block, $content); |
| | | } |
| | | |
| | | 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;}, array_keys(JVB_CONTENT)))) { |
| | | return $return; |
| | | } |
| | | |
| | | $return = ajvb_term_list(); |
| | | $return .= ajvb_meta_output(); |
| | | |
| | | return $return; |
| | | } |
| | | |
| | | function ajvb_term_list():string |
| | | { |
| | | if (!JVB_TAXONOMY){ |
| | | return ''; |
| | | } |
| | | $ID = get_the_ID(); |
| | | $type = jvbNoBase(get_post_type($ID)); |
| | | $taxonomies = array_filter(JVB_TAXONOMY, function($config) use ($type){ |
| | | return in_array($type, $config['for_content']); |
| | | }); |
| | | |
| | | $lists = []; |
| | | foreach ($taxonomies as $taxonomy => $config) { |
| | | $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($config['icon']), |
| | | $config['plural'] |
| | | ); |
| | | 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($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 |
| | | ); |
| | | } |
| | |
| | | <?php |
| | | use JVBase\utility\Image; |
| | | |
| | | function ajv_render_core_site_logo(array $block, string $content):string |
| | | { |
| | |
| | | return $open.$icons.$close; |
| | | } |
| | | |
| | | function ajv_render_core_cover(array $block, string $content):string |
| | | function ajv_render_core_cover(array $block):string |
| | | { |
| | | $types = array_map(function($type) { |
| | | return BASE.$type; |
| | | }, array_keys(JVB_CONTENT)); |
| | | if (!is_post_type_archive($types)) { |
| | | return JVB()->blocks()->render_core_cover($block); |
| | | } |
| | | |
| | | if (is_post_type_archive($types)) { |
| | | $obj = get_queried_object(); |
| | | foreach ($types as $type) { |
| | | if ($type === $obj->name) { |
| | |
| | | return '<section class="align-full cover alt '.$type.'">'.call_user_func($function).'</section>'; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | if(!is_singular(array_map(function($item) { return BASE.$item; }, array_keys(JVB_CONTENT)))) { |
| | | return JVB()->blocks()->render_core_cover($block); |
| | | } |
| | | |
| | | $ID = get_the_ID(); |
| | | $imgID = get_post_thumbnail_id($ID); |
| | | $img = ''; |
| | | if ($imgID && $imgID > 0) { |
| | | $img = str_replace('<img', '<img style="object-fit:center"',jvbFormatImage($imgID, 'tiny', 'large', false)) ; |
| | | } |
| | | |
| | | $post_type = jvbNoBase(get_post_type()); |
| | | $singular = JVB_CONTENT[$post_type]['singular']; |
| | | |
| | | $header = 'Canadian made '.$singular.'. Made in Edmonton.'; |
| | | $title = get_the_title(); |
| | | |
| | | $title = '<small>'.$header.'</small>'.$title; |
| | | |
| | | |
| | | $date = '<small><time datetime="'.get_the_date('c').'" itemprop="datePublished">'.get_the_date().'</time></small>'; |
| | | |
| | | |
| | | return sprintf( |
| | | '<section class="overlay-50 a-end end align-full cover row" style="background-color: rgba(var(--base-rgb), var(--rgb-medium));"> |
| | | %s |
| | | <div class="content"> |
| | | <h1>%s</h1> |
| | | %s |
| | | </div> |
| | | </section>', |
| | | $img, |
| | | $title, |
| | | $date |
| | | ); |
| | | |
| | | } |
| | | |
| | | function ajv_get_limited_posts(string $type, int $limit):array { |
| | | $posts = new WP_Query([ |
| | | 'post_type' => jvbCheckBase($type), |
| | |
| | | 'label' => 'Need', |
| | | 'required' => true |
| | | ], |
| | | 'image' => [ |
| | | 'type' => 'upload', |
| | | 'multiple' => true, |
| | | 'label' => 'Example Image' |
| | | ], |
| | | 'fulfilled' => [ |
| | | 'type' => 'textarea', |
| | | 'quill' => true, |
| | |
| | | 'label' => 'Want', |
| | | 'required' => true |
| | | ], |
| | | 'image' => [ |
| | | 'type' => 'upload', |
| | | 'multiple' => true, |
| | | 'label' => 'Example Image' |
| | | ], |
| | | 'fulfilled' => [ |
| | | 'type' => 'textarea', |
| | | 'quill' => true, |
| | |
| | | |
| | | function ajv_render_art_content(array $block, string $content):string |
| | | { |
| | | $out = ''; |
| | | $ID = get_the_ID(); |
| | | $meta = Meta::forPost($ID); |
| | | |
| | | $fields = $meta->getAll(); |
| | | |
| | | $city = (empty($fields['city'])) ? 'Edmonton' : jvbGetTermLink((int)$fields['city']); |
| | | $form = (empty($fields['form'])) ? 'art' : jvbGetTermLink((int)$fields['form']); |
| | | |
| | | $style = (empty($fields['style'])) ? '' : jvbGetTermLink(explode(',',$fields['style'])[0]).' '; |
| | | $subtitle = '<h2 class="subtitle">'.$city.' handmade '.$style.'<b>'.$form.'</b>.</h2>'; |
| | | |
| | | |
| | | /** INTRO **/ |
| | | $intro = '<section id="intro" class="row"><div class="text">'.apply_filters('wpautop', $fields['post_excerpt']).'</div><div class="images">'; |
| | | $intro .= (!empty($fields['post_thumbnail'])) ? jvbImageCaption($fields['post_thumbnail']) : ''; |
| | | if (!empty($fields['gallery'])) { |
| | | $images = explode(',',$fields['gallery']); |
| | | foreach ($images as $image) { |
| | | $intro .= jvbImageCaption($image, 'tiny', 'medium'); |
| | | } |
| | | } |
| | | $intro .= '</section>'; |
| | | |
| | | |
| | | /** META **/ |
| | | $taxonomies = ['city', 'project','form', 'media','style','theme']; |
| | | $meta = ''; |
| | | foreach ($taxonomies as $taxonomy) { |
| | | if (!empty($fields[$taxonomy])) { |
| | | $icon = jvbIcon(JVB_TAXONOMY[$taxonomy]['icon'])??''; |
| | | $meta .= jvbRenderTermList($fields[$taxonomy], $icon.JVB_TAXONOMY[$taxonomy]['singular']); |
| | | } |
| | | } |
| | | if ($meta !== '') { |
| | | $meta = '<section class="meta">'.$meta.'</section>'; |
| | | $bits = []; |
| | | if (array_key_exists('post_excerpt', $fields) && !empty($fields['post_excerpt'])) { |
| | | $bits[] = sprintf( |
| | | '<section id="excerpt"><h2>At a Glance</h2>%s</section>', |
| | | apply_filters('the_content', $fields['post_excerpt']) |
| | | ); |
| | | } |
| | | |
| | | return $subtitle.$meta.$intro.$meta; |
| | | if (array_key_exists('gallery', $fields) && !empty($fields['gallery'])) { |
| | | $gallery = explode(',',$fields['gallery']); |
| | | $gallery = array_map(function ($imgID) { |
| | | $out = '<figure>'.jvbFormatImage($imgID,'tiny','medium'); |
| | | $caption = wp_get_attachment_caption($imgID); |
| | | $out .= ($caption && $caption !== '') ? '<figcaption>'.apply_filters('the_content', $caption).'</figcaption>' : ''; |
| | | $out .= '</figure>'; |
| | | return $out; |
| | | |
| | | }, $gallery); |
| | | $gallery = implode('',$gallery); |
| | | $bits[] = sprintf( |
| | | '<section id="gallery"><h2>Gallery</h2><div>%s</div></section>', |
| | | $gallery |
| | | ); |
| | | } |
| | | |
| | | if (array_key_exists('post_content', $fields) && !empty($fields['post_content'])) { |
| | | $bits[] = sprintf( |
| | | '<section id="content">%s</section>', |
| | | apply_filters('the_content', $fields['post_content']) |
| | | ); |
| | | } |
| | | |
| | | if (array_key_exists('needs', $fields) && !empty($fields['needs'])) { |
| | | $bits[] = ajvb_format_needs($fields['needs']); |
| | | } |
| | | if (array_key_exists('wants', $fields) && !empty($fields['wants'])) { |
| | | $bits[] = ajvb_format_wants($fields['wants']); |
| | | } |
| | | |
| | | if (!empty($bits)) { |
| | | $out = implode('',$bits); |
| | | } |
| | | |
| | | |
| | | return $out; |
| | | } |
| | |
| | | 'directory' => 'Design', |
| | | 'show_feed' => true, |
| | | 'show_directory'=> true, |
| | | 'addCrumb' => 'project', |
| | | 'favouritable' => true, |
| | | 'karma' => false, |
| | | 'icon' => 'scribble', |
| | |
| | | 'label' => 'Notes' |
| | | ], |
| | | |
| | | |
| | | 'needs' => [ |
| | | 'type' => 'repeater', |
| | | 'label' => 'Needs', |
| | |
| | | 'label' => 'Need', |
| | | 'required' => true |
| | | ], |
| | | 'image' => [ |
| | | 'type' => 'upload', |
| | | 'multiple' => true, |
| | | 'label' => 'Example Image' |
| | | ], |
| | | 'fulfilled' => [ |
| | | 'type' => 'textarea', |
| | | 'quill' => true, |
| | |
| | | 'label' => 'Want', |
| | | 'required' => true |
| | | ], |
| | | 'image' => [ |
| | | 'type' => 'upload', |
| | | 'multiple' => true, |
| | | 'label' => 'Example Image' |
| | | ], |
| | | 'fulfilled' => [ |
| | | 'type' => 'textarea', |
| | | 'quill' => true, |
| | |
| | | ], |
| | | ], |
| | | 'single_image' => false, |
| | | 'upload_title' => 'Upload Artwork', |
| | | 'upload_title' => 'Upload Designs', |
| | | ]; |
| | | } |
| | |
| | | 'singular' => 'Development', |
| | | 'plural' => 'Developments', |
| | | 'directory' => 'Development', |
| | | 'hide_single' => false, |
| | | 'redirectToAuthor'=> false, |
| | | 'addCrumb' => 'project', |
| | | 'show_directory'=> true, |
| | | 'show_feed' => true, |
| | | 'favouritable' => true, |
| | |
| | | 'label' => 'Notes' |
| | | ], |
| | | |
| | | |
| | | 'needs' => [ |
| | | 'type' => 'repeater', |
| | | 'label' => 'Needs', |
| | |
| | | 'label' => 'Need', |
| | | 'required' => true |
| | | ], |
| | | 'image' => [ |
| | | 'type' => 'upload', |
| | | 'multiple' => true, |
| | | 'label' => 'Example Image' |
| | | ], |
| | | 'fulfilled' => [ |
| | | 'type' => 'textarea', |
| | | 'quill' => true, |
| | |
| | | 'label' => 'Want', |
| | | 'required' => true |
| | | ], |
| | | 'image' => [ |
| | | 'type' => 'upload', |
| | | 'multiple' => true, |
| | | 'label' => 'Example Image' |
| | | ], |
| | | 'fulfilled' => [ |
| | | 'type' => 'textarea', |
| | | 'quill' => true, |
| | |
| | | ], |
| | | ], |
| | | 'single_image' => false, |
| | | 'upload_title' => 'Upload Artwork', |
| | | 'upload_title' => 'Upload Development', |
| | | ]; |
| | | } |
| | |
| | | 'redirectToAuthor'=> false, |
| | | 'show_directory'=> true, |
| | | 'directory' => 'Strategy', |
| | | 'addCrumb' => 'project', |
| | | 'show_feed' => true, |
| | | 'favouritable' => true, |
| | | 'karma' => false, |
| | |
| | | 'label' => 'Notes' |
| | | ], |
| | | |
| | | |
| | | 'needs' => [ |
| | | 'type' => 'repeater', |
| | | 'label' => 'Needs', |
| | |
| | | 'label' => 'Need', |
| | | 'required' => true |
| | | ], |
| | | 'image' => [ |
| | | 'type' => 'upload', |
| | | 'multiple' => true, |
| | | 'label' => 'Example Image' |
| | | ], |
| | | 'fulfilled' => [ |
| | | 'type' => 'textarea', |
| | | 'quill' => true, |
| | |
| | | 'label' => 'Want', |
| | | 'required' => true |
| | | ], |
| | | 'image' => [ |
| | | 'type' => 'upload', |
| | | 'multiple' => true, |
| | | 'label' => 'Example Image' |
| | | ], |
| | | 'fulfilled' => [ |
| | | 'type' => 'textarea', |
| | | 'quill' => true, |
| | |
| | | ], |
| | | ], |
| | | 'single_image' => false, |
| | | 'upload_title' => 'Upload Artwork', |
| | | 'upload_title' => 'Upload Strategies', |
| | | ]; |
| | | } |
| | |
| | | 'hide_single' => false, |
| | | 'redirectToAuthor'=> false, |
| | | 'show_feed' => true, |
| | | 'addCrumb' => 'project', |
| | | 'show_directory'=> true, |
| | | 'directory' => 'Writing', |
| | | 'favouritable' => true, |
| | |
| | | 'quill' => true, |
| | | 'label' => 'Notes' |
| | | ], |
| | | |
| | | 'needs' => [ |
| | | 'type' => 'repeater', |
| | | 'label' => 'Needs', |
| | |
| | | 'label' => 'Need', |
| | | 'required' => true |
| | | ], |
| | | 'image' => [ |
| | | 'type' => 'upload', |
| | | 'multiple' => true, |
| | | 'label' => 'Example Image' |
| | | ], |
| | | 'fulfilled' => [ |
| | | 'type' => 'textarea', |
| | | 'quill' => true, |
| | |
| | | 'label' => 'Want', |
| | | 'required' => true |
| | | ], |
| | | 'image' => [ |
| | | 'type' => 'upload', |
| | | 'multiple' => true, |
| | | 'label' => 'Example Image' |
| | | ], |
| | | 'fulfilled' => [ |
| | | 'type' => 'textarea', |
| | | 'quill' => true, |
| | |
| | | ], |
| | | ], |
| | | 'single_image' => false, |
| | | 'upload_title' => 'Upload Artwork', |
| | | 'upload_title' => 'Upload Writings', |
| | | ]; |
| | | } |