From: Steve Sutton Date: Tue, 17 May 2016 15:21:05 +0000 (-0400) Subject: Setting up the member db social add on for use in shortcode and filters X-Git-Tag: v1.0.0^2~4 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=cc8d4c4b56b1afea13f0fcc9d42aca1cdc0a0c09;p=WP-Plugins%2Fglm-member-db-social.git Setting up the member db social add on for use in shortcode and filters Created setup for shortcode Created model to handle the shortcode Created a hook in setup fronthooks --- diff --git a/models/admin/member/social.php b/models/admin/member/social.php index cb5d1ad..d0a18f1 100644 --- a/models/admin/member/social.php +++ b/models/admin/member/social.php @@ -144,7 +144,9 @@ class GlmMembersAdmin_member_social extends GlmDataSocialUrls foreach ($urlList as $url) { // If there's no input for an existing url record - if (!isset($_REQUEST['socialUrl'][$url['social']]) || trim($_REQUEST['socialUrl'][$url['social']]) == '') { + if ( !isset($_REQUEST['socialUrl'][$url['social']]) + || trim($_REQUEST['socialUrl'][$url['social']]) == '' + ) { // delete record here $this->wpdb->delete( @@ -163,7 +165,9 @@ class GlmMembersAdmin_member_social extends GlmDataSocialUrls foreach ($socialList as $socialData) { // Was there any input for this social media type - if (isset($_REQUEST['socialUrl'][$socialData['id']]) && trim($_REQUEST['socialUrl'][$socialData['id']]) != '') { + if ( isset($_REQUEST['socialUrl'][$socialData['id']]) + && trim($_REQUEST['socialUrl'][$socialData['id']]) != '' + ) { $url = $_REQUEST['socialUrl'][$socialData['id']]; @@ -174,7 +178,11 @@ class GlmMembersAdmin_member_social extends GlmDataSocialUrls $this->wpdb->update( $this->table, array('url' => $url), - array( 'ref_type' => $this->config['ref_type_numb']['MemberInfo'], 'ref_dest' => $memberID, 'social' => $socialData['id']), + array( + 'ref_type' => $this->config['ref_type_numb']['MemberInfo'], + 'ref_dest' => $memberID, + 'social' => $socialData['id'] + ), array('%s'), array('%d', '%d', '%s' ) ); diff --git a/models/front/social/list.php b/models/front/social/list.php new file mode 100644 index 0000000..af0e7ee --- /dev/null +++ b/models/front/social/list.php @@ -0,0 +1,66 @@ +wpdb = $wpdb; + $this->config = $config; + + parent::__construct(false, false); + } + + /** + * modelAction + * + * @param bool $actionData Action Data passed to the modelAction + * + * @access public + * @return void + */ + public function modelAction($actionData = false) + { + $status = null; + $action = ''; + $settings = $urlList = array(); + $view = 'list.html'; + + $memberID = filter_var( $actionData['request']['id'], FILTER_VALIDATE_INT); + if ($memberID) { + $urlList = $this->getList("ref_dest = " . $memberID); + } + + // Compile template data + $templateData = array( + 'socials' => $urlList, + 'memberID' => $memberID, + ); + + error_reporting(E_ALL ^ E_NOTICE); + return array( + 'status' => $status, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'front/social/' . $view, + 'data' => $templateData, + 'settings' => $settings + ); + } +} diff --git a/setup/frontHooks.php b/setup/frontHooks.php index 3ed55df..ad9160b 100644 --- a/setup/frontHooks.php +++ b/setup/frontHooks.php @@ -37,3 +37,14 @@ * * *** Also note that parameters will be in the context of the main front controller constructor. *** */ +if (isset($this->config['addOns']['glm-member-db'])) { + // Add internal page content links to member detail page + add_filter('glm-member-db-front-members-social-list', function($content, $id) { + $socialData = do_shortcode('[glm-members-social-list id='.$id.']'); + $content .= $socialData; + return $content; + }, + 10, + 2 + ); +} diff --git a/setup/shortcodes.php b/setup/shortcodes.php index 97a1a0a..170f74d 100644 --- a/setup/shortcodes.php +++ b/setup/shortcodes.php @@ -107,7 +107,23 @@ */ $glmMembersSocialShortcodes = array( + 'glm-members-social-list' => array( + 'plugin' => GLM_MEMBERS_SOCIAL_PLUGIN_SLUG, + 'menu' => 'social', + 'action' => 'list', + 'table' => false, + 'attributes' => array( + 'id' => false + ) + + ), ); -$glmMembersSocialShortcodesDescription = ''; +$glmMembersSocialShortcodesDescription = ' + [glm-members-social-list] +   + + Displays a list of social url\'s. + + '; diff --git a/setup/validActions.php b/setup/validActions.php index 62f1bd9..92d210b 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -54,13 +54,11 @@ $glmMembersSocialAddOnValidActions = array( ) ), 'frontActions' => array( -/* 'social' => array( 'list' => GLM_MEMBERS_SOCIAL_PLUGIN_SLUG, - 'detail' => GLM_MEMBERS_SOCIAL_PLUGIN_SLUG + // 'detail' => GLM_MEMBERS_SOCIAL_PLUGIN_SLUG ) -*/ ) ); -?> \ No newline at end of file +?> diff --git a/views/admin/member/social.html b/views/admin/member/social.html index abff50a..4af11b3 100644 --- a/views/admin/member/social.html +++ b/views/admin/member/social.html @@ -6,10 +6,15 @@
+ {foreach from=$socials key=k item=socialItem} + {if !$socialItem.active.value} + + {/if} + {/foreach} {foreach from=$socials key=k item=socialItem} - {if $socialItem.active} + {if $socialItem.active.value} {$socialField = $socialItem.name|lower}
Social Media TypeIconURL
diff --git a/views/front/social/list.html b/views/front/social/list.html new file mode 100644 index 0000000..ce8abe8 --- /dev/null +++ b/views/front/social/list.html @@ -0,0 +1,7 @@ +{if $memberID} + {foreach $socials as $social} + + {$social.social_name} + + {/foreach} +{/if}