| | |
| | | <?php |
| | | namespace JVBase\managers; |
| | | |
| | | use JVBase\meta\MetaManager; |
| | | use JVBase\meta\Meta; |
| | | use WP_Term; |
| | | use DateTime; |
| | | use DateMalformedStringException; |
| | |
| | | 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 |
| | |
| | | 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) { |
| | |
| | | */ |
| | | 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) { |
| | |
| | | */ |
| | | 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': |
| | |
| | | return $this->getCityTitle($term); |
| | | |
| | | default: |
| | | return $term->name; |
| | | return html_entity_decode($term->name); |
| | | } |
| | | } |
| | | |
| | |
| | | */ |
| | | 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': |
| | |
| | | * 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'; |
| | |
| | | * 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'; |
| | |
| | | |
| | | // 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'); |
| | |
| | | |
| | | // 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'); |
| | |
| | | * 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); |
| | | |
| | |
| | | */ |
| | | 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); |
| | |
| | | */ |
| | | 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); |
| | |
| | | } |
| | | |
| | | // 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'); |
| | |
| | | } |
| | | |
| | | // 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}"; |
| | | } |
| | |
| | | * 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')) { |
| | |
| | | } |
| | | } |
| | | |
| | | $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', |
| | |
| | | $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')) { |
| | |
| | | } |
| | | |
| | | // Build description |
| | | $description = "{$term->name}"; |
| | | $description = html_entity_decode($term->name); |
| | | |
| | | if (!empty($established)) { |
| | | $description .= " has been slinging ink in {$city} since {$established}"; |
| | |
| | | */ |
| | | 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 = ''; |
| | |
| | | } |
| | | |
| | | // 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); |
| | |
| | | } |
| | | } |
| | | |
| | | $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; |
| | | } |
| | |
| | | */ |
| | | 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)) { |
| | |
| | | } |
| | | |
| | | // 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; |
| | | } |
| | |
| | | */ |
| | | 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"; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | // 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"; |
| | |
| | | } |
| | | } |
| | | |
| | | new SEOMetaManager(); |
| | | //new SEOMetaManager(); |