From: Steve Sutton Date: Tue, 15 Nov 2016 18:09:39 +0000 (-0500) Subject: Update the meta tags that are being done by yoast. X-Git-Tag: v1.5.6^2~1 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=1257c20def14aa0ca2137362e62f8f78275a080b;p=WP-Plugins%2Fglm-member-db-events.git 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. --- 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