From cf5224e1f6ba312d2ba0ec4ad3f23495155f03cd Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Thu, 10 Oct 2019 13:02:20 -0400 Subject: [PATCH] Add shortcode for getting a member trip planner button Create it to add to a page. --- models/front/itinerary/button.php | 102 ++++++++++++++++++++++++++++++ setup/shortcodes.php | 17 ++++- setup/validActions.php | 3 +- views/front/itinerary/button.html | 5 ++ 4 files changed, 125 insertions(+), 2 deletions(-) create mode 100755 models/front/itinerary/button.php create mode 100644 views/front/itinerary/button.html diff --git a/models/front/itinerary/button.php b/models/front/itinerary/button.php new file mode 100755 index 0000000..737abf4 --- /dev/null +++ b/models/front/itinerary/button.php @@ -0,0 +1,102 @@ + + * @license PHP Version 3.0 {@link http://www.php.net/license/3_0.txt} + */ +class GlmMembersFront_itinerary_button // extends GlmMembersFront_events_baseAction +{ + /** + * Constructor + * + * This constructor performs the work for this model. This model returns + * an array containing the following. + * + * 'status' + * + * True if successful and false if there was a fatal failure. + * + * '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. + * + * @wpdb object WordPress database object + * + * @return array Array containing status, suggested view, and any data + */ + 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); + + } + + /** + * modelAction + * + * @param bool $actionData Action Data passed to the modelAction + * + * @access public + * @return void + */ + public function modelAction( $actionData = false ) + { + $status = true; + $option = false; + $view = 'button.html'; + $member = false; + + + if ( isset( $_REQUEST['option'] ) ) { + $option = filter_var( $_REQUEST['option'], FILTER_SANITIZE_STRING ); + } + + switch ( $option ) { + + default: + if ( isset( $actionData['request']['member'] ) && $member = filter_var( $actionData['request']['member'], FILTER_VALIDATE_INT ) ) { + $button = glm_member_itinerary_trip_planner_link( '', $member ); + } else { + $button = false; + } + break; + } + + $templateData = array( + 'button' => $button, + ); + + return array( + 'status' => $status, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'front/itinerary/' . $view, + 'data' => $templateData, + ); + } + +} diff --git a/setup/shortcodes.php b/setup/shortcodes.php index 5b32e24..9bba43e 100644 --- a/setup/shortcodes.php +++ b/setup/shortcodes.php @@ -95,7 +95,16 @@ $glmMembersItineraryShortcodes = array( 'table' => false, 'attributes' => array( ), - ) + ), + 'glm-itinerary-button' => array( + 'plugin' => 'glm-member-db-itinerary', + 'menu' => 'itinerary', + 'action' => 'button', + 'table' => false, + 'attributes' => array( + 'member' => false, + ), + ), ); $glmMembersItineraryShortcodesDescription = ' @@ -106,5 +115,11 @@ $glmMembersItineraryShortcodesDescription = ' Displays the trip planner list. + + [glm-itinerary-button] + + Display button with a member + + '; diff --git a/setup/validActions.php b/setup/validActions.php index a091937..d00a980 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -68,7 +68,8 @@ $glmMembersItineraryAddOnValidActions = array( ), 'frontActions' => array( 'itinerary' => array( - 'list' => GLM_MEMBERS_ITINERARY_PLUGIN_SLUG, + 'list' => GLM_MEMBERS_ITINERARY_PLUGIN_SLUG, + 'button' => GLM_MEMBERS_ITINERARY_PLUGIN_SLUG, ) ) ); diff --git a/views/front/itinerary/button.html b/views/front/itinerary/button.html new file mode 100644 index 0000000..01f89d0 --- /dev/null +++ b/views/front/itinerary/button.html @@ -0,0 +1,5 @@ +
+
+ {$button} +
+
-- 2.17.1