Update the meta tags that are being done by yoast.
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 15 Nov 2016 18:09:39 +0000 (13:09 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 15 Nov 2016 18:10:17 +0000 (13:10 -0500)
These are for open graph and twitter.
This will add the intro and name of the event into the meta tags.

setup/frontHooks.php

index aa48897..4fce8c7 100644 (file)
@@ -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