From 1257c20def14aa0ca2137362e62f8f78275a080b Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Tue, 15 Nov 2016 13:09:39 -0500 Subject: [PATCH] Update the meta tags that are being done by yoast. These are for open graph and twitter. This will add the intro and name of the event into the meta tags. --- setup/frontHooks.php | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/setup/frontHooks.php b/setup/frontHooks.php index aa48897..4fce8c7 100644 --- a/setup/frontHooks.php +++ b/setup/frontHooks.php @@ -76,12 +76,31 @@ if (strpos(GLM_MEMBERS_PLUGIN_CURRENT_URL, $this->config['settings']['canonical_ // Get the event name for use in the page title global $wpdb; - $GLOBALS['glmEventName'] = $wpdb->get_var( "SELECT name FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events WHERE name_slug = '".$GLOBALS['glmDetailSlug']."'" ); + $eventData = $wpdb->get_row( + "SELECT name,intro + FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "events + WHERE name_slug = '".$GLOBALS['glmDetailSlug']."'", + ARRAY_A + ); + $GLOBALS['glmEventName'] = $eventData['name']; + $GLOBALS['glmEventIntro'] = $eventData['intro']; // Set the page title to the event name - Using low priority so it's the last to set the title! - add_filter('wp_title', function($title) { + add_filter( 'wp_title', function($title) { + return $GLOBALS['glmEventName']; + }, 99, 1 ); + add_filter( 'wpseo_opengraph_title', function($tag){ + return $GLOBALS['glmEventName']; + }, 99, 1 ); + add_filter( 'wpseo_opengraph_desc', function($tag){ + return $GLOBALS['glmEventIntro']; + }, 99, 1 ); + add_filter( 'wpseo_twitter_title', function($tag){ return $GLOBALS['glmEventName']; - }, 99, 1); + }, 99, 1 ); + add_filter( 'wpseo_twitter_description', function($tag){ + return $GLOBALS['glmEventIntro']; + }, 99, 1 ); } // Add eventslug query var -- 2.17.1