| | |
| | | } |
| | | |
| | | use JVBase\base\Site; |
| | | use JVBase\managers\CacheManager; |
| | | use JVBase\registrar\Registrar; |
| | | |
| | | add_filter('jvb_base', function () { |
| | |
| | | * - rewrite rules |
| | | * - archive title |
| | | */ |
| | | add_filter('jvb_site', 'altr_setup_site'); |
| | | //add_filter('jvb_site', 'altr_setup_site'); |
| | | function altr_setup_site():array |
| | | { |
| | | return [ |
| | |
| | | return 'logo-triangle'; |
| | | } |
| | | |
| | | |
| | | add_filter('jvbSummaryHeader', 'altr_progress_summary_header', 10, 2); |
| | | |
| | | function altr_progress_summary_header(string $title, string $type):string |
| | | function altr_title_generator(?string $type = null):string |
| | | { |
| | | switch ($type) { |
| | | if (!$type) { |
| | | $obj = get_queried_object(); |
| | | |
| | | if (is_tax()) { |
| | | $type = $obj->taxonomy; |
| | | } elseif (is_post_type_archive()) { |
| | | $type = $obj->name; |
| | | } elseif (is_singular()) { |
| | | $type = $obj->post_type; |
| | | } else { |
| | | error_log('Could not determine type: '.print_r($obj, true)); |
| | | return ''; |
| | | } |
| | | } |
| | | |
| | | |
| | | $registrar = Registrar::getInstance($type); |
| | | if (!$registrar) { |
| | | error_log('Could not find registrar for '.$type); |
| | | return ''; |
| | | } |
| | | |
| | | switch($registrar->getSlug()) { |
| | | case 'progress': |
| | | return Registrar::getInstance($type)->getPlural(); |
| | | return $registrar->getPlural(); |
| | | case 'skin_type': |
| | | $name = get_queried_object()->name; |
| | | $basic = match($name) { |
| | | 'i','ii','iii','iv type 1' => 'Lighter Skin', |
| | | 'iv type 2', 'v', 'vi' => 'Darker Skin' |
| | | }; |
| | | return '<small>How We Remove Tattoos On </small> '.$basic.' <small>(FitzPatrick Skin Type '.$name.')</small>'; |
| | | case 'age': |
| | | $name = strtolower(get_queried_object()->name); |
| | | if (str_contains($name, 'years')) { |
| | | $name = str_replace('years', 'year', $name); |
| | | } |
| | | if (str_contains($name, 'months')) { |
| | | $name = str_replace('months', 'month', $name); |
| | | } |
| | | if (str_contains($name, 'weeks')) { |
| | | $name = str_replace('weeks', 'week', $name); |
| | | } |
| | | return '<small>How We Remove </small>'.ucwords($name).' Old<small> Tattoos</small>'; |
| | | |
| | | case 'timeline': |
| | | $name = strtolower(get_queried_object()->name); |
| | | return '<small>Laser Tattoo Removal </small>'.ucwords($name).' Later'; |
| | | case 'goal': |
| | | $name = get_queried_object()->name; |
| | | $name = match($name) { |
| | | 'Complete Removal' => 'Completely Remove Tattoos', |
| | | 'Cover Up Tattoo' => 'Fade Tattoos for a Cover Up', |
| | | default => 'Clean Up Tattoo Blowout' |
| | | }; |
| | | return '<small>How we </small>'.$name; |
| | | case 'style': |
| | | case 'body_part': |
| | | case 'theme': |
| | | $name = get_queried_object()->name; |
| | | return '<small>How We Remove </small>'.ucwords($name).' Tattoos'; |
| | | default: |
| | | $singular = Registrar::getInstance($type)->getSingular(); |
| | | return '<small>Before & After Laser Tattoo Removal</small><small>'.$singular.':</small>'.str_replace($singular.': ','',$title); |
| | | error_log('No title preset found for '.$registrar->getSlug()); |
| | | return ''; |
| | | } |
| | | } |
| | | |
| | | add_filter('get_the_archive_title', 'altr_archive_title', 10, 1); |
| | | function altr_archive_title(string $title):string |
| | | { |
| | | return altr_title_generator(); |
| | | } |
| | | |
| | | add_filter('the_seo_framework_title_from_generation', 'altr_title_filter', 10, 2); |
| | | function altr_title_filter(string $title, $args):string |
| | | { |
| | | $newTitle = ''; |
| | | |
| | | $tsf = tsf(); |
| | | |
| | | $type = null; |
| | | if (null === $args) { |
| | | // We're in the loop |
| | | if ($tsf->query()->is_tax()) { |
| | | $type = $tsf->query()->get_current_taxonomy(); |
| | | } |
| | | } else { |
| | | if (!empty($args['taxonomy']??'')) { |
| | | $type = $args['taxonomy']; |
| | | } |
| | | } |
| | | |
| | | if ($type) { |
| | | $newTitle = altr_title_generator(jvbNoBase($type)); |
| | | } |
| | | |
| | | return empty($newTitle) ? $title : wp_strip_all_tags($newTitle); |
| | | } |
| | | |
| | | |
| | | //add_filter('jvbSummaryHeader', 'altr_progress_summary_header', 10, 2); |
| | | // |
| | | //function altr_progress_summary_header(string $title, string $type):string |
| | | //{ |
| | | // $pre = $singular = ''; |
| | | // $registrar = Registrar::getInstance($type); |
| | | // |
| | | // switch ($type) { |
| | | // |
| | | // |
| | | // } |
| | | // $pre = 'Before & After Laser Tattoo Removal'; |
| | | // if (is_tax()) { |
| | | // return '<small>Before & After </small>'.get_queried_object()->name.'<small> Tattoo Removal</small>'; |
| | | // } elseif (is_post_type_archive()) { |
| | | // $singular = Registrar::getInstance($type)->getSingular(); |
| | | // } elseif (is_singular()) { |
| | | // global $post; |
| | | // $singular = $post->post_title; |
| | | // } |
| | | // return '<small>Before & After Laser Tattoo Removal</small>'.$singular; |
| | | //} |
| | | add_filter('jvbSummaryHeaderExtra', 'altr_progress_summary_header_extra', 10, 2); |
| | | |
| | | function altr_progress_summary_header_extra(string $title, string $type):string |