From: Steve Sutton Date: Tue, 12 Feb 2019 20:49:56 +0000 (-0500) Subject: Update filter for trip planner links X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=0e4ebfb2213d7a5bc9c085b5805933df0554af3c;p=WP-Plugins%2Fglm-member-db-itinerary.git Update filter for trip planner links Updating to a function so it can be used in callback to more than one filter. --- diff --git a/setup/frontHooks.php b/setup/frontHooks.php index 12afb34..c4803fb 100644 --- a/setup/frontHooks.php +++ b/setup/frontHooks.php @@ -25,46 +25,44 @@ * * *** Also note that parameters will be in the context of the main front controller constructor. *** */ -add_filter( - 'glm-member-db-front-members-list-memberImageTop', - function( $content, $member_id ){ - global $wp, $config; - if ( isset( $_SESSION['travel-list'][$member_id] ) && $_SESSION['travel-list'][$member_id] ) { - $class = 'list-view-link'; - $span1 = 'view_trip1'; - $label = $config['settings']['view_label']; - $alt_label = $config['settings']['add_label']; - $is_view = '1'; - } else { - $class = 'list-add-link'; - $span1 = 'add_trip1'; - $label = $config['settings']['add_label']; - $alt_label = $config['settings']['view_label']; - $is_view = ''; - } - $load_page = get_the_permalink( $config['settings']['itinerary_page'] ); - $current_slug = add_query_arg( array(), $wp->request ); - return $content . sprintf( - '
- - %s - Trip Planner - -
', - $class, - $member_id, - htmlspecialchars( $alt_label, ENT_QUOTES, 'UTF-8' ), - get_bloginfo( 'url' ), - $current_slug, - $is_view, - $load_page, - $span1, - $label - ); - }, - 10, - 2 -); +function glm_member_itinerary_trip_planner_link( $content, $member_id ) +{ + global $wp, $config; + if ( isset( $_SESSION['travel-list'][$member_id] ) && $_SESSION['travel-list'][$member_id] ) { + $class = 'list-view-link'; + $span1 = 'view_trip1'; + $label = $config['settings']['view_label']; + $alt_label = $config['settings']['add_label']; + $is_view = '1'; + } else { + $class = 'list-add-link'; + $span1 = 'add_trip1'; + $label = $config['settings']['add_label']; + $alt_label = $config['settings']['view_label']; + $is_view = ''; + } + $load_page = get_the_permalink( $config['settings']['itinerary_page'] ); + $current_slug = add_query_arg( array(), $wp->request ); + return $content . sprintf( + '
+ + %s + Trip Planner + +
', + $class, + $member_id, + htmlspecialchars( $alt_label, ENT_QUOTES, 'UTF-8' ), + get_bloginfo( 'url' ), + $current_slug, + $is_view, + $load_page, + $span1, + $label + ); +} +add_filter( 'glm-member-db-front-members-list-memberImageTop', 'glm_member_itinerary_trip_planner_link', 10, 2 ); +add_filter( 'glm-member-db-front-members-detail-mapTop', 'glm_member_itinerary_trip_planner_link', 10, 2 ); // If no session then start one. add_action( 'init', function(){