Added code to fix up canonical page URLs for detail pages in add-ons.
Also added code to use the canonical page URL fix up filter to fix member-detail page
canonical URL tags.
// Add filters for use anywhere else (apply_filter). Will have to add this to index.php eventually
add_filter('glmMembersFrontScriptsFilter',array($this,'glmMembersFrontScripts'));
add_action('glmMembersFrontCSSFilter',array($this,'glmMembersFrontCSS'));
+
}
/**
public function modelAction($actionData = false) {
- $shortcodesDescription = '';
-
- // For each add-on that's registered
- foreach ($this->config['addOns'] as $a) {
-
- // Add their shortcodes descriptions
- if (isset($a['shortcodesDescription'])) {
- $shortcodesDescription .= $a['shortcodesDescription'];
- }
-
- }
-
// Return status, any suggested view, and any data to controller
return array(
'status' => true,
'modelRedirect' => false,
'view' => 'admin/shortcodes/index.html',
'data' => array(
- 'shortcodesDescription' => $shortcodesDescription,
- 'junk' => 'My Junk'
+ 'addOns' => $this->config['addOns']
)
);
}
- public function fancybox_scripts(){
-
- }
/*
* Perform Model Action
*
*/
public function modelAction ($actionData = false)
{
+ /**** NEED TO REVIEW WHERE THESE STYLES SHOULD BE ENQUEUED - SHOULD NOT BE HERE ****/
wp_enqueue_style('fancyStyle', GLM_MEMBERS_PLUGIN_URL . 'fancybox/source/jquery.fancybox.css?v=2.1.5');
wp_enqueue_style('fancyStyleButtons', GLM_MEMBERS_PLUGIN_URL . 'fancybox/source/helpers/jquery.fancybox-buttons.css?v=1.0.5');
wp_enqueue_style('fancyStyleThumbs', GLM_MEMBERS_PLUGIN_URL . 'fancybox/source/helpers/jquery.fancybox-thumbs.css?v=1.0.7');
}
}
-
+
$expanded = htmlspecialchars($_GET['expanded']);
-
+
// Since the ID we recieved with the member data is the pointer to the member info record, replace it with member ID
$memberData['id'] = $memberData['member_pointer'];
+
// Compile template data
$templateData = array(
'haveMember' => $haveMember,
+++ /dev/null
-<?php
-
-/**
- * Gaslight Media Members Database
- * Front Member Detail
- *
- * PHP version 5.5
- *
- * @category glmWordPressPlugin
- * @package glmMembersDatabase
- * @author Chuck Scott <cscott@gaslightmedia.com>
- * @license http://www.gaslightmedia.com Gaslightmedia
- * @version 0.1
- */
-
-// Translation table for [glm-member-detail] "show" options to configuration parameters
-$GLOBALS['showOpts'] = array(
- 'map' => 'detail_show_map',
- 'map-logo' => 'detail_map_show_logo',
- 'map-description' => 'detail_map_show_descr',
- 'map-short-description' => 'detail_map_show_short_descr',
- 'map-address' => 'detail_map_show_address',
- 'map-street' => 'detail_map_show_street',
- 'map-city-state-zip' => 'detail_map_show_citystatezip',
- 'map-country' => 'detail_map_show_country',
- 'map-region' => 'detail_map_show_region',
- 'map-phone' => 'detail_map_show_phone',
- 'map-toll-free' => 'detail_map_show_tollfree',
- 'map-url' => 'detail_map_show_url',
- 'map-url-new-target' => 'detail_map_show_url_newtarget',
- 'map-email' => 'detail_map_show_email',
- 'map-categories' => 'detail_map_show_categories',
- 'map-credit-cards' => 'detail_map_show_creditcards',
- 'map-amentities' => 'detail_map_show_amenities',
- 'logo' => 'detail_show_logo',
- 'address' => 'detail_show_address',
- 'street' => 'detail_show_street',
- 'city-state-zip' => 'detail_show_citystatezip',
- 'country' => 'detail_show_country',
- 'region' => 'detail_show_region',
- 'description' => 'detail_show_descr',
- 'short-description' => 'detail_show_short_descr',
- 'phone' => 'detail_show_phone',
- 'toll-free' => 'detail_show_tollfree',
- 'url' => 'detail_show_url',
- 'url-new-target' => 'detail_show_url_newtarget',
- 'email' => 'detail_show_email',
- 'categories' => 'detail_show_categories',
- 'credit-cards' => 'detail_show_creditcards',
- 'amentities' => 'detail_show_amenities'
-);
-
-// Load Members data abstract
-require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php');
-
-/*
- * This class performs the work for the default action of the "Members" menu
- * option, which is to display the members dashboard.
- *
- */
-
-class GlmMembersFront_members_detail extends GlmDataMemberInfo
-{
-
- /**
- * WordPress Database Object
- *
- * @var $wpdb
- * @access public
- */
- public $wpdb;
- /**
- * Plugin Configuration Data
- *
- * @var $config
- * @access public
- */
- public $config;
-
- /*
- * Constructor
- *
- * This contructor sets up this model. At this time that only includes
- * storing away the WordPress data object.
- *
- * @return object Class object
- *
- */
- public function __construct ($wpdb, $config)
- {
-
- // Save WordPress Database object
- $this->wpdb = $wpdb;
-
- // Save plugin configuration object
- $this->config = $config;
-
- // Run constructor for members data class
- parent::__construct(false, false);
-
- }
-
- /*
- * Perform Model Action
- *
- * This method does the work for this model and returns any resulting data
- *
- * @return array Status and data array
- *
- * 'status'
- *
- * True if successfull and false if there was a fatal failure.
- *
- * 'menuItemRedirect'
- *
- * If not false, provides a menu item the controller should
- * execute after this one. Normally if this is used, there would also be a
- * modelRedirect value supplied as well.
- *
- * 'modelRedirect'
- *
- * If not false, provides an action the controller should execute after
- * this one.
- *
- * 'view'
- *
- * A suggested view name that the contoller should use instead of the
- * default view for this model or false to indicate that the default view
- * should be used.
- *
- * 'data'
- *
- * Data that the model is returning for use in merging with the view to
- * produce output.
- *
- */
- public function modelAction ($actionData = false)
- {
- wp_enqueue_style('fancyStyle', GLM_MEMBERS_PLUGIN_URL . 'css/jquery.fancybox.css');
- wp_enqueue_script('fancyScript', GLM_MEMBERS_PLUGIN_URL . 'js/jquery.fancybox.js', array('jquery'), '', true );
-echo GLM_MEMBERS_PLUGIN_URL;
-
-
- $where = '';
- $haveMember = false;
- $haveImageGallery = false;
- $success = false;
-
- // Check for "show" shortcode parameter
- $settings = array();
- $showList = $actionData['request']['show'];
-
- if ($showList) {
-
- // Separate options and see if we have any
- $show = explode(',', $showList);
- if (count($show) > 0) {
-
- // For each option
- foreach ($show as $s) {
-
- $s = trim($s);
-
- // If we're setting all
- if ($s == 'all') {
-
- while (list($key, $val) = each($GLOBALS['showOpts'])) {
- $settings[$val] = true;
- }
-
- // Or we're clearing all
- } elseif ($s == 'none') {
-
- while (list($key, $val) = each($GLOBALS['showOpts'])) {
- $settings[$val] = false;
- }
-
- // Or it's a single option
- } else {
-
- // Check if we're setting or clearing
- $tf = $s[0];
- if ($tf == '+') {
- $tf = true;
- } elseif ($tf == '-') {
- $tf = false;
- } else {
- $tf = null;
- }
-
- // If we have +/- and we have the key in our showOpts array
- $k = substr($s, 1);
- if ($tf !== null && isset($GLOBALS['showOpts'][$k])) {
-
- // Get the name of the configuration option
- $c = $GLOBALS['showOpts'][$k];
-
- // If the configuration option exists, add to list of modified settings
- if (isset($this->config['settings'][$c])) {
- $settings[$c] = $tf;
- }
- }
-
- }
-
- }
-
- }
- }
-
-
- // If we have a member slug supplied from a rewrite - get the id
- $rrMemberSlug = get_query_var('memberslug', '');
- if ($rrMemberSlug != '') {
-
- $sql = "
- SELECT id
- FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "members
- WHERE member_slug = '$rrMemberSlug'
- ;";
- $id = $this->wpdb->get_var($sql);
-
- // Otherwise if member ID submitted in the URL
- } elseif (isset($_REQUEST['id']) && $_REQUEST['id'] > 0) {
-
- $id = ($_REQUEST['id'] - 0);
-
- // Otherwise if ID from the short-code
- } elseif (isset($actionData['request']) && isset($actionData['request']['id'])) {
-
- $id = ($actionData['request']['id'] - 0);
-
- }
-
- // Check that ID is a positive value
- if ($id <= 0) {
-
- return array(
- 'status' => true,
- 'menuItemRedirect' => 'error',
- 'modelRedirect' => 'index',
- 'view' => 'front/error/index.html',
- 'data' => false
- );
-
- }
-
- // Default is we didn't find the member info
- $memberData = false;
- $haveMember = false;
- $haveImageGallery = false;
- $imageGallery = false;
-
- // Find the active member info record and get it with main member data
- $memberData = $this->getActiveInfoForMember($id);
-
- if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) {
- glmMembersFront::addNotice($memberData, 'DataBlock', 'Member Info with Member Data');
- }
-
- // If we did get member Info
- if ($memberData) {
-
- $success = true;
- $haveMember = true;
-
- // Also get any image gallery images
- require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataImages.php');
- $Images = new GlmDataImages($this->wpdb, $this->config);
- $imageGallery = $Images->getGallery($this->config['ref_type_numb']['MemberInfo'], $memberData['id']);
- $haveImageGallery = ($imageGallery != false);
-
- }
-
- // Since the ID we recieved with the member data is the pointer to the member info record, replace it with member ID
- $memberData['id'] = $memberData['member_pointer'];
-
- // Compile template data
- $templateData = array(
- 'haveMember' => $haveMember,
- 'member' => $memberData,
- 'haveImageGallery' => $haveImageGallery,
- 'imageGallery' => $imageGallery
-
- );
-
- // Return status, suggested view, and data to controller
- return array(
- 'status' => $success,
- 'menuItemRedirect' => false,
- 'modelRedirect' => false,
- 'view' => 'front/members/detail.html',
- 'data' => $templateData,
- 'settings' => $settings
- );
-
- }
-
-
-}
-
-?>
}
+/*
+ * Add a filter to correct rel_canonical header entries
+ *
+ * This replaces the WordPress wp_head "rel_canonical" action hook and
+ * includes a new filter that permits other code to link into the filter
+ * to replace the canonical URL.
+ *
+ */
+
+// Replace WordPress head tag 'rel_canonical' action with our own to handle
+// detail pages that need correct canonical URLs.
+add_action('init', function() {
+
+ remove_action( 'wp_head', 'rel_canonical');
+ add_action( 'wp_head', function() {
+
+ // Original Code from wp-includes/link-template.php rel_canonical()
+ if ( ! is_singular() ) {
+ return;
+ }
+
+ global $wp_the_query;
+ if ( ! $id = get_queried_object_id() ) {
+ return;
+ }
+
+ $url = get_permalink( $id );
+
+ // Create a filter that can be used to provide a different canonical URL
+ // Note that only one add-on linked to this filter may provide the URL at a time!
+ $newCanonicalSlug = apply_filters( 'glm_rel_canonical_slug', false );
+
+ // Output our replacement canonical URL and quit.
+ if ($newCanonicalSlug) {
+ echo "<link rel='canonical' href='".$url.$newCanonicalSlug."/' />\n";
+ return;
+ }
+
+ // Remainder of original code from wp-includes/link-template.php rel_canonical()
+ $page = get_query_var( 'page' );
+ if ( $page >= 2 ) {
+ if ( '' == get_option( 'permalink_structure' ) ) {
+ $url = add_query_arg( 'page', $page, $url );
+ } else {
+ $url = trailingslashit( $url ) . user_trailingslashit( $page, 'single_paged' );
+ }
+ }
+
+ $cpage = get_query_var( 'cpage' );
+ if ( $cpage ) {
+ $url = get_comments_pagenum_link( $cpage );
+ }
+ echo '<link rel="canonical" href="' . esc_url( $url ) . "\" />\n";
+
+ }); // add_action wp_head
+
+ return;
+}); // do_action 'init'
+
+/* End of rel_canonical code */
+
+
+/*
+ * Member Detail Page Canonical URL Fix
+ *
+ * Since the member 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 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.
+ */
+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 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 and use that
+ $m = array();
+ preg_match('|.*/'.$this->config['settings']['canonical_member_page'].'/([^/]*).*|', GLM_MEMBERS_PLUGIN_CURRENT_URL, $m );
+ $detailSlug = $m[1];
+
+ }
+
+ return $detailSlug;
+});
+
+
+
// Add memberslug query var
add_filter('query_vars', function($vars) {
array_push($vars, 'memberslug');
);
$glmMembersShortcodesDescription = '
-
-<!-- glm-members-list -->
-<table id="glm-table-shortcodes-members" class="glm-admin-table glm-shortcodes-table">
<tr><th>Shortcode</th><th>Attribute</th><th>Description</th></tr>
<tr>
<th>[glm-members-list]</th>
<td> </td>
<td width="50%">
- <p>
Displays a list of members and a map with markers for each member. Optionally,
the attributes below may used to modify the display of this page.
- </p>
</td>
</tr>
<tr>
category="{ category ID(s) }"
</th>
<td>
- <p>
The "category" attribute is used display only members in a specific category or
categories. To select multiple categories, separate the categories with a ",".
Categories are specified by ID number. The ID for each category is
shown in the Member Categories list.
- </p>
</td>
</tr>
<tr>
category-name="{ category name(s) }"
</th>
<td>
- <p>
The "category-name" attribute is used display only members in a specific category or
categories by specifying the category names. To select multiple categories,
separate the category names with a ",". Category names must match the name of a
category exactly to be selected. Category names must be enclosed in quotes.
- </p>
</td>
</tr>
<tr>
<td></td>
<th>amenity-groups="1,2"</th>
- <td><p>The "amenity-groups" attribute is used to display only the amenities that are in specific groups or a group.
- Separate the groups with a ","</p></td>
+ <td>
+ The "amenity-groups" attribute is used to display only the amenities that are in specific groups or a group.
+ Separate the groups with a ","
+ </td>
</tr>
<tr>
<td> </td>
blank-start="{True/False}"
</th>
<td>
- <p>
The "blank-start" attribute tells the page whether or not to display the list of members
when the user first hits the page. When "blank-start" is "True", the page first displays
with the member search form but without any list of members. When the user submits their
first search, the page is re-displayed with the member list resuts. Subsequent submissions
of the page also display any results found by the search as does selection of the alpha
(letter) links.
- </p>
</td>
</tr>
<tr>
show="{ content to show }"
</th>
<td>
- <p>
The "show" attribute is used control what content should be displayed in the
member list. The default is to show the content selected in the "Management",
"General Settings" page under "Member List Page Options".
- </p>
<p>
Content to show or not show is specified by a comma separated list of the
items listed below. Each item must be preceded by either a "+" or a "-" to
view="{ view to use }"
</th>
<td>
- <p>
Current options available are: bars (default), grid
- </p>
<p>
The "view" attribute tells the page which view file to use. The "bars" value will display
by default, and features a succession of page-wide bars containing an image, member contact
<th>[glm-member-detail]</th>
<td> </td>
<td>
- <p>
Displays details for a specific member along with a map showing their location. The
"id" attribute below is required to specify which member to display.
- </p>
</td>
</tr>
<tr>
id="{ member ID }"
</th>
<td>
- <p>
This is an optional attribute for [glm-member-detail] that specifies the ID of
the desired member. The ID for a member is displayed both in the left column
of the member list and at the top of the Member Dashboard. Only one ID may
member name slug as the last part of the path in the URL and try to locate
an active member information record with "Name for URLs" set to the same
string.
- </p>
</td>
</tr>
<tr>
show="{ content to show }"
</th>
<td>
- <p>
The "show" attribute is used control what content should be displayed in
member detail. The default is to show the content selected in the "Management",
"General Settings" page under "Member Detail Page Options".
- </p>
<p>
Content to show or not show is specified by a comma separated list of the
items listed below. Each item must be preceded by either a "+" or a "-" to
</p>
</td>
</tr>
- </table>
';
<h2>{$glmPluginName}</h2>
-
\ No newline at end of file
+ <div id="glm-admin-content-container">
\ No newline at end of file
<p> </p>
<h2 class="nav-tab-wrapper" style="margin-bottom: 1em;">
- <a id="glm-shortcodes-members" data-show-table="glm-table-shortcodes-members" class="glm-shortcodes-tab nav-tab nav-tab-active">Members</a>
- <a id="glm-shortcodes-packaging" data-show-table="glm-table-shortcodes-packaging" class="glm-shortcodes-tab nav-tab">Packaging</a>
- <a id="glm-shortcodes-events" data-show-table="glm-table-shortcodes-events" class="glm-shortcodes-tab nav-tab">Events</a>
-<!-- <a id="glm-shortcodes-contacts" data-show-table="glm-table-shortcodes-contacts" class="glm-shortcodes-tab nav-tab">Contacts</a>-->
-<!-- <a id="glm-shortcodes-socials" data-show-table="glm-table-shortcodes-socials" class="glm-shortcodes-tab nav-tab">Socials</a>-->
+ {$glmActive = true}
+ {foreach $addOns as $a}
+ {if isset($a.shortcodes)}
+ {if $a.shortcodes|@count gt 0}
+ <a id="glm-shortcodes-{$a.slug}" data-show-table="glm-table-shortcodes-{$a.slug}" class="glm-shortcodes-tab nav-tab{if $glmActive} nav-tab-active{/if}">{$a.short_name}</a>
+ {$glmActive = false}
+ {/if}
+ {/if}
+ {/foreach}
</h2>
- {$shortcodesDescription}
+ {$glmActive = true}
+ {foreach $addOns as $a}
+ {if isset($a.shortcodes)}
+ {if $a.shortcodes|@count gt 0}
+ <table id="glm-table-shortcodes-{$a.slug}" class="glm-admin-table glm-shortcodes-table{if !$glmActive} glm-hidden{/if}">
+ {$a.shortcodesDescription}
+ </table>
+ {$glmActive = false}
+ {/if}
+ {/if}
+ {/foreach}
<script>
jQuery(document).ready(function($) {