From: Chuck Scott Date: Fri, 8 Jul 2016 14:45:54 +0000 (-0400) Subject: Added member name as page title to member detail page. X-Git-Tag: v2.1.26^2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=54afc45970ac7ef5cce549087f8bc9a970ac4fa9;p=WP-Plugins%2Fglm-member-db.git Added member name as page title to member detail page. --- diff --git a/index.php b/index.php index 375e669e..53699757 100644 --- a/index.php +++ b/index.php @@ -3,7 +3,7 @@ * Plugin Name: GLM Members Database * Plugin URI: http://www.gaslightmedia.com/ * Description: Gaslight Media Members Database. - * Version: 2.1.25 + * Version: 2.1.26 * Author: Gaslight Media * Author URI: http://www.gaslightmedia.com/ * License: GPL2 @@ -38,7 +38,7 @@ * */ -define('GLM_MEMBERS_PLUGIN_VERSION', '2.1.25'); +define('GLM_MEMBERS_PLUGIN_VERSION', '2.1.26'); define('GLM_MEMBERS_PLUGIN_DB_VERSION', '1.1.11'); // Check if plugin version is not current in WordPress option and if needed updated it diff --git a/setup/frontHooks.php b/setup/frontHooks.php index 45e9b093..1656e57a 100644 --- a/setup/frontHooks.php +++ b/setup/frontHooks.php @@ -123,28 +123,36 @@ add_filter( 'wpseo_canonical', function($canonical) { * * The code below checks if we're on a member detail page and if so returns the member slug so that * can be added to the URL. The matching apply_filters is in the main plugin in setup/frontHooks.php. + * + * We're also going to set the page title to the member name in here while we're at it. */ -add_filter('glm_rel_canonical_slug', function($detailSlug) { - - // If another add-on already supplied the detail slug, then just return that. - if ($detailSlug != false) { - return $detailSlug; - } +if (strpos(GLM_MEMBERS_PLUGIN_CURRENT_URL, $this->config['settings']['canonical_member_page']) > 0) { - // Check if the page is a member-detail page use the correct - if (strpos(GLM_MEMBERS_PLUGIN_CURRENT_URL, $this->config['settings']['canonical_member_page']) > 0) { + // Parse out only the member slug from the current URL + $m = array(); + preg_match('|.*/'.$this->config['settings']['canonical_member_page'].'/([^/]*).*|', GLM_MEMBERS_PLUGIN_CURRENT_URL, $m ); + $GLOBALS['glmDetailSlug'] = $m[1]; - // Parse out only the member slug and use that - $m = array(); - preg_match('|.*/'.$this->config['settings']['canonical_member_page'].'/([^/]*).*|', GLM_MEMBERS_PLUGIN_CURRENT_URL, $m ); - $detailSlug = $m[1]; + // Return the current member slug to the glm_rel_canonical_slug filter for use in the canonical page link. + add_filter('glm_rel_canonical_slug', function($detailSlug) { - } + // If another add-on already supplied the detail slug, then just return that. + if ($detailSlug != false) { + return $detailSlug; + } + return $GLOBALS['glmDetailSlug']; - return $detailSlug; -}); + }); + // 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']."'" ); + // Set the page title to the member name + add_filter('wp_title', function() { + return $GLOBALS['glmMembName']; + }); +} // Add memberslug query var add_filter('query_vars', function($vars) {