From addfabe8dec2b5100034a392c8c358dea33aa1a1 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Tue, 15 Nov 2016 14:02:49 -0500 Subject: [PATCH] Setting up yoast filters for open graph and twitter. Set the title and description for open graph and twitter within the yoast filters. --- setup/frontHooks.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/setup/frontHooks.php b/setup/frontHooks.php index 0a25e54b..c6a11b5e 100644 --- a/setup/frontHooks.php +++ b/setup/frontHooks.php @@ -146,12 +146,33 @@ if (strpos(GLM_MEMBERS_PLUGIN_CURRENT_URL, $this->config['settings']['canonical_ // Get the member name for use in the page title global $wpdb; - $GLOBALS['glmMembName'] = $wpdb->get_var( "SELECT name FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX . "members WHERE member_slug = '".$GLOBALS['glmDetailSlug']."'" ); + $memberData = $wpdb->get_row( + "SELECT T.name,I.short_descr + FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX . "members T, + ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member_info I + WHERE T.member_slug = '".$GLOBALS['glmDetailSlug']."' + AND T.id = I.member", + ARRAY_A + ); + $GLOBALS['glmMembName'] = $memberData['name']; + $GLOBALS['glmMembIntro'] = $memberData['short_descr']; // Set the page title to the member name - Using low priority so it's the last to set the title! add_filter('wp_title', function($title) { return $GLOBALS['glmMembName']; }, 99, 1); + add_filter( 'wpseo_opengraph_title', function($tag){ + return $GLOBALS['glmMembName']; + }, 99, 1 ); + add_filter( 'wpseo_opengraph_desc', function($tag){ + return $GLOBALS['glmMembIntro']; + }, 99, 1 ); + add_filter( 'wpseo_twitter_title', function($tag){ + return $GLOBALS['glmMembName']; + }, 99, 1 ); + add_filter( 'wpseo_twitter_description', function($tag){ + return $GLOBALS['glmMembIntro']; + }, 99, 1 ); } // Squash Bread Crumbs if using Breadcrumb NavXT plugin -- NEED TO CREATE A MANAGEMENT OPTION FOR THIS TO TURN IT ON/OFF -- 2.17.1