| | |
| | | * Edmonton.ink Configuration |
| | | * |
| | | * Add this to your edmonton.ink child theme/plugin |
| | | * This replaces all the hardcoded logic in SchemaManager and SEOMetaManager |
| | | * This replaces all the hardcoded logic in SchemaManager and SEO`MetaManager` |
| | | */ |
| | | |
| | | // ================================================== |
| | | // SITE-WIDE SCHEMA CONFIGURATION |
| | | // ================================================== |
| | | |
| | | add_filter('jvb_schema', function ($schema) { |
| | | use JVBase\meta\Meta; |
| | | |
| | | add_filter('jvb_schema', function ($schema) { |
| | | return array_merge($schema, [ |
| | | 'site_type' => 'directory', |
| | | 'organization' => [ |
| | |
| | | |
| | | 'schema' => [ |
| | | 'custom_builder' => function ($post_id) { |
| | | $meta = new \JVBase\meta\MetaManager($post_id, 'post'); |
| | | $meta = Meta::forPost($post_id); |
| | | |
| | | $schema = [ |
| | | '@type' => 'Event', |
| | |
| | | 'url' => get_permalink($post_id), |
| | | ]; |
| | | |
| | | $date = $meta->getValue('event_date'); |
| | | $date = $meta->get('event_date'); |
| | | if ($date) { |
| | | $schema['startDate'] = date('c', strtotime($date)); |
| | | } |
| | | |
| | | $venue = $meta->getValue('venue'); |
| | | $venue_address = $meta->getValue('venue_address'); |
| | | $venue = $meta->get('venue'); |
| | | $venue_address = $meta->get('venue_address'); |
| | | if ($venue) { |
| | | $schema['location'] = [ |
| | | '@type' => 'Place', |
| | |
| | | 'variables' => [ |
| | | 'name' => 'term_name', |
| | | 'city' => ['callback' => function ($term_id, $context) { |
| | | $meta = new \JVBase\meta\MetaManager($term_id, 'term'); |
| | | $city_id = $meta->getValue('city'); |
| | | $meta = Meta::forTerm($term_id); |
| | | $city_id = $meta->get('city'); |
| | | if ($city_id && term_exists((int)$city_id, BASE . 'city')) { |
| | | $city_term = get_term($city_id, BASE . 'city'); |
| | | if ($city_term && !is_wp_error($city_term)) { |
| | |
| | | return 'Edmonton'; |
| | | }], |
| | | 'tagline_text' => ['callback' => function ($term_id) { |
| | | $meta = new \JVBase\meta\MetaManager($term_id, 'term'); |
| | | $tagline = $meta->getValue('tagline'); |
| | | $meta = Meta::forTerm($term_id); |
| | | $tagline = $meta->get('tagline'); |
| | | return $tagline ? " - {$tagline}" : ''; |
| | | }], |
| | | 'established_text' => ['callback' => function ($term_id) { |
| | | $meta = new \JVBase\meta\MetaManager($term_id, 'term'); |
| | | $established = $meta->getValue('established'); |
| | | $meta = Meta::forTerm($term_id); |
| | | $established = $meta->get('established'); |
| | | return $established ? " Established in {$established}" : ''; |
| | | }], |
| | | 'artist_count' => ['callback' => function ($term_id) { |
| | |
| | | 'priceRange' => 'price_range', |
| | | 'image' => 'logo', |
| | | 'url' => ['callback' => function ($term_id) { |
| | | $meta = new \JVBase\meta\MetaManager($term_id, 'term'); |
| | | $website = $meta->getValue('website'); |
| | | $meta = Meta::forTerm($term_id); |
| | | $website = $meta->get('website'); |
| | | return $website ?: get_term_link($term_id); |
| | | }], |
| | | 'sameAs' => ['callback' => function ($term_id) { |
| | | $meta = new \JVBase\meta\MetaManager($term_id, 'term'); |
| | | $meta = Meta::forTerm($term_id); |
| | | $links = []; |
| | | if ($ig = $meta->getValue('instagram')) $links[] = $ig; |
| | | if ($fb = $meta->getValue('facebook')) $links[] = $fb; |
| | | if ($ig = $meta->get('instagram')) $links[] = $ig; |
| | | if ($fb = $meta->get('facebook')) $links[] = $fb; |
| | | return !empty($links) ? $links : null; |
| | | }], |
| | | 'memberOf' => [ |
| | |
| | | 'variables' => [ |
| | | 'name' => 'term_name', |
| | | 'alt_names' => ['callback' => function ($term_id) { |
| | | $meta = new \JVBase\meta\MetaManager($term_id, 'term'); |
| | | $alts = $meta->getValue('alternate_name'); |
| | | $meta = Meta::forTerm($term_id); |
| | | $alts = $meta->get('alternate_name'); |
| | | if (!empty($alts) && is_array($alts)) { |
| | | $names = array_filter(array_column($alts, 'name')); |
| | | if (!empty($names)) { |
| | |
| | | 'description' => 'characteristics', |
| | | 'about' => ['meta' => 'description'], |
| | | 'alternateName' => ['callback' => function ($term_id) { |
| | | $meta = new \JVBase\meta\MetaManager($term_id, 'term'); |
| | | $alts = $meta->getValue('alternate_name'); |
| | | $meta = Meta::forTerm($term_id); |
| | | $alts = $meta->get('alternate_name'); |
| | | if (!empty($alts) && is_array($alts)) { |
| | | return array_filter(array_column($alts, 'name')); |
| | | } |
| | |
| | | 'variables' => [ |
| | | 'name' => 'term_name', |
| | | 'similar' => ['callback' => function ($term_id) { |
| | | $meta = new \JVBase\meta\MetaManager($term_id, 'term'); |
| | | $similar = $meta->getValue('similar'); |
| | | $meta = Meta::forTerm($term_id); |
| | | $similar = $meta->get('similar'); |
| | | if (!empty($similar)) { |
| | | $similar_names = []; |
| | | foreach ((array)$similar as $similar_id) { |