| | |
| | | use JVBase\managers\Cache; |
| | | use JVBase\meta\Meta; |
| | | use JVBase\registrar\Registrar; |
| | | use JVBase\utility\Image; |
| | | |
| | | if (!defined('ABSPATH')) { |
| | | exit; |
| | |
| | | return; |
| | | } |
| | | $project = Registrar::forTerm('project', 'Project', 'Projects') |
| | | ->setIcon('scribble') |
| | | ->setIcon('cards-three') |
| | | ->make([ |
| | | 'rewrite' => [ |
| | | 'slug' => 'projects', |
| | |
| | | ->setAll([ |
| | | 'show_feed', |
| | | 'show_directory', |
| | | 'is_content' |
| | | 'is_content', |
| | | ]); |
| | | } |
| | | function ajv_project_fields():void |
| | |
| | | } |
| | | $project = Registrar::getInstance('project'); |
| | | |
| | | //$directory = $project->getConfig('directory'); |
| | | $directory = $project->config('directory'); |
| | | $directory->setTitle('Projects'); |
| | | //$breadcrumbs = $project->config('breadcrumbs'); |
| | | //$breadcrumbs->setCrumb('project'); |
| | | |
| | |
| | | $extra = jvbCommaList($temp); |
| | | } |
| | | } |
| | | $extra .= ' Made Project'; |
| | | $extra .= '-Based Project'; |
| | | return '<small>'.$extra.'</small>'.$fields['name'].'.'; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | return '<p>Or see <a href="'.JVB()->directories()->getDirectoryList()[$type]['url'].'">all projects</a>.</p>'; |
| | | return '<p>Or see <a href="'.get_home_url(null,'/projects/').'">all projects</a>.</p>'; |
| | | } |
| | | |
| | | add_filter('jvbBeforeSummary', 'ajv_project_before_summary', 10, 2); |
| | |
| | | $meta = Meta::forTerm(get_queried_object_id()); |
| | | $fields = $meta->getAll(); |
| | | $rows = []; |
| | | if ($fields['city'] !== '') { |
| | | if (!empty($fields['city'])) { |
| | | $rows[] = jvbMetaTermList($fields['city'], 'city'); |
| | | } |
| | | if ($fields['target'] !== '') { |
| | |
| | | for ($i = 0; $i <= (int) $fields['budget']; $i++) { |
| | | $budget .= '$'; |
| | | } |
| | | $title = match((int)$fields['budget']) { |
| | | 0 => 'Low', |
| | | 1 => 'Medium Low', |
| | | 2 => 'Medium', |
| | | 3 => 'Medium High', |
| | | 4 => 'High' |
| | | |
| | | $budget = match($fields['budget']) { |
| | | 'low' => '$', |
| | | 'medium-low' => '$$', |
| | | 'medium' => '$$$', |
| | | 'medium-high' => '$$$$', |
| | | 'high' => '$$$$$' |
| | | }; |
| | | |
| | | $title = ucwords($fields['budget']); |
| | | $rows[] = '<span>'.jvbIcon('currency-dollar-simple').'Budget:</span><span title="'.$title.'">'.$budget.'</span>'; |
| | | } |
| | | |
| | | if ($fields['timeline'] !== '') { |
| | | $rows[] = '<span>'.jvbIcon('hourglass-medium').'Timeline:</span>'.$fields['timeline']; |
| | | } |
| | | $summary = ''; |
| | | |
| | | $summary = '<section id="summary"><h2>At a Glance</h2>'; |
| | | if (!empty($rows)) { |
| | | $summary = '<section id="summary"><h2>At a Glance</h2><ul class="summary">'; |
| | | $summary .= '<ul class="summary">'; |
| | | $summary .= implode('', array_map(function ($row) { |
| | | return '<li>'.$row.'</li>'; |
| | | }, $rows)); |
| | | $summary .= '</ul></section>'; |
| | | } |
| | | |
| | | return $summary; |
| | | $summary .= '</ul>'; |
| | | } |
| | | if (!empty($meta->get('summary'))) { |
| | | $summary .= '<div>'.wpautop($meta->get('summary')).'</div>'; |
| | | } |
| | | $summary .= '</section>'; |
| | | |
| | | $img = ''; |
| | | if (!empty($meta->get('thumbnail'))) { |
| | | $data = Image::getData($meta->get('thumbnail')); |
| | | if (!empty($data)) { |
| | | $img = sprintf( |
| | | '<div class="poster" style="background-image:url(\'%s\');" data-bg-img data-bg-small="%s" data-bg-medium="%s" data-bg-large="%s"></div>', |
| | | $data['tiny'], |
| | | $data['small'], |
| | | $data['medium'], |
| | | $data['large'], |
| | | ); |
| | | } |
| | | } |
| | | return $summary.$img; |
| | | } |
| | | |
| | | add_filter('jvbSummaryImage', 'ajv_project_summary_image', 10, 2); |
| | |
| | | if ($type !== 'project') { |
| | | return $return; |
| | | } |
| | | return ''; |
| | | $meta = Meta::forTerm(get_queried_object_id()); |
| | | $thumbnail = $meta->get('thumbnail'); |
| | | |
| | |
| | | $fields = $meta->getAll(); |
| | | |
| | | if ($fields['summary'] !== '') { |
| | | $return['about-this-project'] = $fields['summary']; |
| | | $return['about-this-project'] = wpautop($fields['summary']); |
| | | } |
| | | if (!empty($fields['needs'])) { |
| | | $return['needs'] = ajvb_format_needs($fields['needs']); |
| | |
| | | } |
| | | $ids[] = 'project-parts'; |
| | | return $ids; |
| | | } |
| | | |
| | | add_filter('jvb_content_tax_args_project', 'ajv_modify_project_args'); |
| | | function ajv_modify_project_args(array $args):array |
| | | { |
| | | // $args['meta_key'] = BASE.'started'; |
| | | // $args['meta_type'] = 'DATETIME'; |
| | | // $args['orderby'] = 'meta_value'; |
| | | return $args; |
| | | } |
| | | |
| | | function ajv_render_project_content(int $termID):string |
| | | { |
| | | $meta = Meta::forTerm($termID); |
| | | $slug = sanitize_title($meta->get('name')); |
| | | $inside = ''; |
| | | |
| | | $postTypes = array_map(function($type) { return jvbCheckBase($type);}, Registrar::getInstance('project')->registrar->for); |
| | | $images = ajv_get_limited_post_images([ |
| | | 'post_type' => $postTypes, |
| | | 'tax_query' => [ |
| | | [ |
| | | 'taxonomy' => BASE.'project', |
| | | 'terms' => $termID |
| | | ] |
| | | ] |
| | | ], true); |
| | | |
| | | |
| | | |
| | | if (!empty($images)) { |
| | | $images = sprintf( |
| | | '<h3>Project Parts</h3><ul class="loop scroll">%s</ul>', |
| | | implode('',array_map(function ($img) { |
| | | return sprintf( |
| | | '<li>%s</li>', |
| | | $img |
| | | ); |
| | | }, $images)) |
| | | ); |
| | | } else { |
| | | $images = ''; |
| | | } |
| | | $url = get_term_link($termID, BASE.'project')??''; |
| | | |
| | | $titleExtra = ''; |
| | | $terms = [ |
| | | 'city', |
| | | 'target' |
| | | ]; |
| | | foreach ($terms as $term) { |
| | | if (!empty($meta->get($term))) { |
| | | $registrar = Registrar::getInstance($term); |
| | | |
| | | $titleExtra .= '<li>'.jvbIcon($registrar->getIcon()).jvbGetTermLink($meta->get($term), BASE.$term).'</li>'; |
| | | } |
| | | } |
| | | if (!empty($titleExtra)) { |
| | | $titleExtra = '<ul class="terms">'.$titleExtra.'</ul>'; |
| | | } |
| | | $times = [ |
| | | 'started', |
| | | 'ended' |
| | | ]; |
| | | |
| | | $temp = ''; |
| | | foreach ($times as $time) { |
| | | if (!empty($meta->get($time))) { |
| | | $theTime = strtotime($meta->get($time)); |
| | | $temp .= sprintf( |
| | | '<li>%s: <time datetime="%s">%s</time></li>', |
| | | ucfirst($time), |
| | | date('c', $theTime), |
| | | date('F j, Y', $theTime) |
| | | ); |
| | | } |
| | | } |
| | | if (!empty($temp)) { |
| | | $titleExtra .= '<ul class="term-list">'.$temp.'</ul>'; |
| | | } |
| | | return sprintf( |
| | | '<li id="%s"> |
| | | <div class="cover row btm x-mid"> |
| | | %s |
| | | <div class="content"> |
| | | <h2><a href="%s">%s</a></h2> |
| | | <div class="meta"> |
| | | %s |
| | | </div> |
| | | </div> |
| | | </div> |
| | | %s |
| | | %s |
| | | %s |
| | | <a class="btn" href="%s">%sSee Full Project</a> |
| | | </li>', |
| | | $slug, |
| | | jvbFormatImage((int)$meta->get('thumbnail')), |
| | | $url, |
| | | $meta->get('name'), |
| | | $titleExtra, |
| | | empty($meta->get('summary')) ? '' : wpautop($meta->get('summary')), |
| | | $inside, |
| | | $images, |
| | | $url, |
| | | jvbIcon('arrow-circle-right') |
| | | ); |
| | | } |