Cleaned up shortcode description data.
authorChuck Scott <cscott@gaslightmedia.com>
Wed, 6 Jul 2016 20:58:13 +0000 (16:58 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Wed, 6 Jul 2016 20:58:13 +0000 (16:58 -0400)
Added code in frontHooks to do canonical URL cleanup for event-detail pages

setup/frontHooks.php
setup/shortcodes.php

index 54492e2..ec30ef9 100644 (file)
@@ -45,6 +45,35 @@ if ( ! isset( $rules['('.$this->config['settings']['canonical_event_page'].')/([
 
 }
 
+/*
+ * Event Detail Page Canonical URL Fix
+ *
+ * Since the event detail pages are actually all the same page, and since WordPress has a specific
+ * canonical URL for that page, we need to override the rel='canonical' value in the page header.
+ *
+ * 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.
+ */
+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;
+    }
+
+    // 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) {
+
+            // 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];
+
+    }
+
+    return $detailSlug;
+});
+
 // Add eventslug query var
 add_filter('query_vars', function($vars) {
     array_push($vars, 'eventslug');
index d413696..0b17350 100644 (file)
@@ -129,7 +129,6 @@ $glmMembersEventsShortcodes = array(
 );
 
 $glmMembersEventsShortcodesDescription = '
-<table id="glm-table-shortcodes-events" class="glm-admin-table glm-shortcodes-table glm-hidden">
     <tr><th>Shortcode</th><th>Attribute</th><th>Description</th></tr>
      <tr>
         <th>[glm-members-event-list]</th>
@@ -152,6 +151,5 @@ $glmMembersEventsShortcodesDescription = '
             Adds an event submission form to the page.
         </td>
     </tr>
-</table>
 ';