* Plugin Name: GLM Members Database Events
* Plugin URI: http://www.gaslightmedia.com/
* Description: Gaslight Media Members Database.
- * Version: 1.2.17
+ * Version: 1.2.18
* Author: Chuck Scott
* Author URI: http://www.gaslightmedia.com/
* License: GPL2
* @package glmMembersDatabaseEventsAddOn
* @author Chuck Scott <cscott@gaslightmedia.com>
* @license http://www.gaslightmedia.com Gaslightmedia
- * @version 1.2.17
+ * @version 1.2.18
*/
/*
* so that we're sure the other add-ons see an up to date
* version from this plugin.
*/
-define('GLM_MEMBERS_EVENTS_PLUGIN_VERSION', '1.2.17');
+define('GLM_MEMBERS_EVENTS_PLUGIN_VERSION', '1.2.18');
define('GLM_MEMBERS_EVENTS_PLUGIN_DB_VERSION', '0.0.18');
// This is the minimum version of the GLM Members DB plugin require for this plugin.
*
* The code below checks if we're on a event detail page and if so returns the event 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 event name in here while we're at it.
*/
-add_filter('glm_rel_canonical_slug', function($detailSlug) {
+if (strpos(GLM_MEMBERS_PLUGIN_CURRENT_URL, $this->config['settings']['canonical_event_page']) > 0) {
- // If another add-on already supplied the detail slug, then just return that.
- if ($detailSlug != false) {
- return $detailSlug;
- }
+ // Parse out only the event slug from the current URL
+ $m = array();
+ preg_match('|.*/'.$this->config['settings']['canonical_event_page'].'/([^/]*).*|', GLM_MEMBERS_PLUGIN_CURRENT_URL, $m );
+ $GLOBALS['glmDetailSlug'] = $m[1];
- // Check if the page is a event-detail page use the correct
- if (strpos(GLM_MEMBERS_PLUGIN_CURRENT_URL, $this->config['settings']['canonical_event_page']) > 0) {
+ // Return the current event slug to the glm_rel_canonical_slug filter for use in the canonical page link.
+ add_filter('glm_rel_canonical_slug', function($detailSlug) {
- // Parse out only the event slug and use that
- $m = array();
- preg_match('|.*/'.$this->config['settings']['canonical_event_page'].'/([^/]*).*|', GLM_MEMBERS_PLUGIN_CURRENT_URL, $m );
- $detailSlug = $m[1];
+ // 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 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']."'" );
+
+ // Set the page title to the event name
+ add_filter('wp_title', function() {
+ return $GLOBALS['glmEventName'];
+ });
+}
// Add eventslug query var
add_filter('query_vars', function($vars) {