Jake Vanderwerf
2026-02-04 2127b1bdd73ecd2423e443992da4b442f5a3c1a3
inc/managers/SEOMetaManager.php
@@ -1,7 +1,7 @@
<?php
namespace JVBase\managers;
use JVBase\meta\MetaManager;
use JVBase\meta\Meta;
use WP_Term;
use DateTime;
use DateMalformedStringException;
@@ -10,6 +10,7 @@
    exit; // Exit if accessed directly
}
/**
 * @deprecated use JVBase\managers\seo\SEO.php
 * SEO Meta Manager for edmonton.ink
 *
 * Integrates with The SEO Framework to generate optimized titles and meta descriptions
@@ -113,7 +114,7 @@
    protected function getPostTitle(int $post_id):string
    {
        $title = get_the_title($post_id);
        $meta = new MetaManager($post_id, 'post');
        $meta = Meta::forPost($post_id);
        $post_type = get_post_type($post_id);
        return match ($post_type) {
@@ -132,7 +133,7 @@
     */
    protected function getPostDescription(int $post_id):string
    {
        $meta = new MetaManager($post_id, 'post');
        $meta = Meta::forPost($post_id);
        $post_type = get_post_type($post_id);
        switch ($post_type) {
@@ -158,7 +159,7 @@
     */
    protected function getTermTitle(WP_Term $term):string
    {
        $meta = new MetaManager($term->term_id, 'term');
        $meta = Meta::forTerm($term->term_id);
        switch ($term->taxonomy) {
            case BASE . 'shop':
@@ -174,7 +175,7 @@
                return $this->getCityTitle($term);
            default:
                return $term->name;
                return html_entity_decode($term->name);
        }
    }
@@ -186,7 +187,7 @@
     */
    protected function getTermDescription(WP_Term $term):string
    {
        $meta = new MetaManager($term->term_id, 'term');
        $meta = Meta::forTerm($term->term_id);
        switch ($term->taxonomy) {
            case BASE . 'shop':
@@ -275,10 +276,9 @@
     * Get artist title
     *
     * @param string $title The original title
     * @param MetaManager $meta The meta manager
     * @return string The optimized title
     */
    protected function getArtistTitle(string $title, MetaManager $meta):string
    protected function getArtistTitle(string $title):string
    {
        $city_terms = get_the_terms(get_the_ID(), BASE . 'city');
        $city = ($city_terms && !is_wp_error($city_terms)) ? $city_terms[0]->name : 'Edmonton';
@@ -294,17 +294,17 @@
     * Get artist description
     *
     * @param int $post_id The post ID
     * @param MetaManager $meta The meta manager
     * @param Meta $meta The meta manager
     * @return string The optimized description
     */
    protected function getArtistDescription(int $post_id, MetaManager $meta):string
    protected function getArtistDescription(int $post_id, Meta $meta):string
    {
        $bio = $meta->getValue('short_bio');
        $bio = $meta->get('short_bio');
        if ($bio !== '') {
            return $bio;
        }
        $first_name = $meta->getValue('first_name');
        $first_name = $meta->get('first_name');
        $city_terms = get_the_terms($post_id, BASE . 'city');
        $city = ($city_terms && !is_wp_error($city_terms)) ? $city_terms[0]->name : 'Edmonton';
@@ -313,7 +313,7 @@
        // Get top styles if available
        $styles = [];
        $top_styles = $meta->getValue('top_style');
        $top_styles = $meta->get('top_style');
        if (!empty($top_styles)) {
            foreach ((array)$top_styles as $style_id) {
                $style = get_term($style_id, BASE . 'style');
@@ -325,7 +325,7 @@
        // Get top themes if available
        $themes = [];
        $top_themes = $meta->getValue('top_theme');
        $top_themes = $meta->get('top_theme');
        if (!empty($top_themes)) {
            foreach ((array)$top_themes as $theme_id) {
                $theme = get_term($theme_id, BASE . 'theme');
@@ -393,16 +393,16 @@
     * Get partner description
     *
     * @param int $post_id The post ID
     * @param MetaManager $meta The meta manager
     * @param Meta $meta The meta manager
     * @return string The optimized description
     */
    protected function getPartnerDescription(int $post_id, MetaManager$meta):string
    protected function getPartnerDescription(int $post_id, Meta$meta):string
    {
        $short_bio = $meta->getValue('short_bio');
        $short_bio = $meta->get('short_bio');
        if ($short_bio !== '') {
            return $short_bio;
        }
        $established = $meta->getValue('established');
        $established = $meta->get('established');
        $description = get_the_title($post_id);
@@ -426,16 +426,16 @@
     */
    protected function getEventTitle(int $post_id, string $title):string
    {
        $meta = new MetaManager($post_id, 'post');
        $meta = Meta::forPost($post_id);
        // Get event type if available
        $event_type = $meta->getValue('event_type') ?: '';
        $event_type = $meta->get('event_type') ?: '';
        if ($event_type && term_exists((int)$event_type, BASE . 'type')) {
            $event_type = get_term($event_type, BASE . 'type')->name;
        }
        // Get date information
        $date_start = $meta->getValue('date_start');
        $date_start = $meta->get('date_start');
        $month = '';
        if ($date_start) {
            $date = new DateTime($date_start);
@@ -473,17 +473,17 @@
     */
    protected function getEventDescription(int $post_id):string
    {
        $meta = new MetaManager($post_id, 'post');
        $meta = Meta::forPost($post_id);
        $title = get_the_title($post_id);
        // Get event type if available
        $event_type = $meta->getValue('event_type') ?: '';
        $event_type = $meta->get('event_type') ?: '';
        if ($event_type && term_exists((int)$event_type, BASE . 'type')) {
            $event_type = get_term($event_type, BASE . 'type')->name;
        }
        // Get date information
        $date_start = $meta->getValue('date_start');
        $date_start = $meta->get('date_start');
        $date_format = '';
        if ($date_start) {
            $date = new DateTime($date_start);
@@ -491,7 +491,7 @@
        }
        // Get location information
        $location = $meta->getValue('location');
        $location = $meta->get('location');
        $location_name = '';
        if (!empty($location['shop'])) {
            $shop_term = get_term($location['shop'], BASE . 'shop');
@@ -522,11 +522,11 @@
        }
        // Add event details if available
        $is_free = $meta->getValue('is_free');
        $is_free = $meta->get('is_free');
        if ($is_free) {
            $description .= ". Free admission";
        } else {
            $cost = $meta->getValue('cost');
            $cost = $meta->get('cost');
            if ($cost) {
                $description .= ". Admission: {$cost}";
            }
@@ -541,12 +541,12 @@
     * Get shop title
     *
     * @param WP_Term $term The term object
     * @param MetaManager $meta The meta manager
     * @param Meta $meta The meta manager
     * @return string The optimized title
     */
    protected function getShopTitle(WP_Term $term, MetaManager $meta):string
    protected function getShopTitle(WP_Term $term, Meta $meta):string
    {
        $city_id = $meta->getValue('city');
        $city_id = $meta->get('city');
        $city = 'Edmonton';
        if ($city_id && term_exists((int)$city_id, BASE . 'city')) {
@@ -556,7 +556,7 @@
            }
        }
        $length = strlen($term->name) + strlen($city);
        $length = strlen(html_entity_decode($term->name)) + strlen($city);
        $title = match (true) {
            $length < 36 => $city . '\s Best Tattoo Studios',
@@ -565,26 +565,27 @@
            $length < 46 => $city . ' Tattoo Shop',
            default => 'Tattoo Shop: ',
        };
        return "{$term->name} | {$title}";
      $name = html_entity_decode($term->name);
        return "{$name} | {$title}";
    }
    /**
     * Get shop description
     *
     * @param WP_Term $term The term object
     * @param MetaManager $meta The meta manager
     * @param Meta $meta The meta manager
     * @return string The optimized description
     */
    protected function getShopDescription(WP_Term $term, MetaManager $meta):string
    protected function getShopDescription(WP_Term $term, Meta $meta):string
    {
        $short_bio = $meta->getValue('short_bio');
        $short_bio = $meta->get('short_bio');
        if ($short_bio !== '') {
            return $short_bio;
        }
        $established = $meta->getValue('established');
        $established = $meta->get('established');
        // Get city
        $city_id = $meta->getValue('city');
        $city_id = $meta->get('city');
        $city = 'Edmonton';
        if ($city_id && term_exists((int)$city_id, BASE . 'city')) {
@@ -613,7 +614,7 @@
        }
        // Build description
        $description = "{$term->name}";
        $description = html_entity_decode($term->name);
        if (!empty($established)) {
            $description .= " has been slinging ink in {$city} since {$established}";
@@ -638,25 +639,26 @@
     */
    protected function getStyleTitle(WP_Term $term):string
    {
        return "Edmonton's Best {$term->name} Tattoo Artists";
      $name = html_entity_decode($term->name);
        return "Edmonton's Best {$name} Tattoo Artists";
    }
    /**
     * Get style description
     *
     * @param WP_Term $term The term object
     * @param MetaManager $meta The meta manager
     * @param Meta $meta The meta manager
     * @return string The optimized description
     */
    protected function getStyleDescription(WP_Term $term, MetaManager $meta):string
    protected function getStyleDescription(WP_Term $term, Meta $meta):string
    {
        $tagline = $meta->getValue('tagline');
        $tagline = $meta->get('tagline');
        if (!$tagline !== '') {
            return $tagline;
        }
        $characteristics = $meta->getValue('characteristics');
        $alternate_names = $meta->getValue('alternate_name');
        $characteristics = $meta->get('characteristics');
        $alternate_names = $meta->get('alternate_name');
        // Get alt names if available
        $alt_name_text = '';
@@ -674,7 +676,8 @@
        }
        // Build description
        $description = "{$term->name}{$alt_name_text} is a distinctive tattoo style";
      $name = html_entity_decode($term->name);
        $description = "{$name}{$alt_name_text} is a distinctive tattoo style";
        if (!empty($characteristics)) {
            $stripped = wp_strip_all_tags($characteristics);
@@ -685,7 +688,8 @@
            }
        }
        $description .= " Find Edmonton artists specializing in {$term->name} tattoos.";
      $name = html_entity_decode($term->name);
        $description .= " Find Edmonton artists specializing in {$name} tattoos.";
        return $description;
    }
@@ -698,25 +702,26 @@
     */
    protected function getThemeTitle(WP_Term $term):string
    {
        return "Edmonton's Best {$term->name} Tattoos";
      $name = html_entity_decode($term->name);
        return "Edmonton's Best {$name} Tattoos";
    }
    /**
     * Get theme description
     *
     * @param WP_Term $term The term object
     * @param MetaManager $meta The meta manager
     * @param Meta $meta The meta manager
     * @return string The optimized description
     */
    protected function getThemeDescription(WP_Term $term, MetaManager $meta):string
    protected function getThemeDescription(WP_Term $term, Meta $meta):string
    {
        $description_meta = $meta->getValue('description');
        $description_meta = $meta->get('description');
        if ($description_meta !== '') {
            return $description_meta;
        }
        // Get similar themes if available
        $similar = $meta->getValue('similar');
        $similar = $meta->get('similar');
        $similar_text = '';
        if (!empty($similar)) {
@@ -734,15 +739,16 @@
        }
        // Build description
        $description = "Explore {$term->name} tattoos";
      $name = html_entity_decode($term->name);
        $description = "Explore {$name} tattoos";
        $description .= ", a popular motif in Edmonton's tattoo scene.";
        $description .= $similar_text;
        $description .= " Find artists specializing in {$term->name} tattoos.";
      $name = html_entity_decode($term->name);
        $description .= " Find artists specializing in {$name} tattoos.";
        return $description;
    }
@@ -755,7 +761,8 @@
     */
    protected function getCityTitle(WP_Term $term):string
    {
        return "{$term->name} Tattoo Artists & Shops | edmonton.ink";
      $name = html_entity_decode($term->name);
        return "{$name} Tattoo Artists & Shops | edmonton.ink";
    }
    /**
@@ -798,7 +805,8 @@
        }
        // Build description
        $description = "Discover {$term->name}'s vibrant tattoo scene";
      $name = html_entity_decode($term->name);
        $description = "Discover {$name}'s vibrant tattoo scene";
        if ($shop_count > 0 || $artist_count > 0) {
            $description .= " featuring";
@@ -821,4 +829,4 @@
    }
}
new SEOMetaManager();
//new SEOMetaManager();