PageRenderTime 26ms CodeModel.GetById 8ms app.highlight 14ms RepoModel.GetById 1ms app.codeStats 0ms

/shared/shortcodes/shortcodes/profile.php

https://github.com/deltafactory/landing-pages
PHP | 184 lines | 162 code | 13 blank | 9 comment | 17 complexity | a148310c19e98126553df7dbbebe7097 MD5 | raw file
  1<?php
  2/**
  3*   Profile Shortcode
  4*/
  5
  6/* 	Shortcode generator config
  7 * 	----------------------------------------------------- */
  8	$shortcodes_config['profile'] = array(
  9		'no_preview' => true,
 10		'options' => array(
 11			'name' => array(
 12				'name' => __('Profile Name', 'leads'),
 13				'desc' => __('Enter the name.', 'leads'),
 14				'type' => 'text',
 15				'std' => ''
 16			),
 17			'meta' => array(
 18				'name' => __('Profile Meta', 'leads'),
 19				'desc' => __('Enter the profile meta. e.g job position etc.', 'leads'),
 20				'type' => 'text',
 21				'std' => ''
 22			),
 23			'image' => array(
 24				'name' => __('Profile Image', 'leads'),
 25				'desc' => __('Paste your profile image URL here.', 'leads'),
 26				'type' => 'text',
 27				'std' => ''
 28			),
 29			'link' => array(
 30				'name' => __('Profile Link', 'leads'),
 31				'desc' => __('Paste your profile link URL here.', 'leads'),
 32				'type' => 'text',
 33				'std' => ''
 34			),
 35			'facebook' => array(
 36				'name' => __('Profile Facebook', 'leads'),
 37				'desc' => __('Paste your facebook URL here.', 'leads'),
 38				'type' => 'text',
 39				'std' => ''
 40			),
 41			'twitter' => array(
 42				'name' => __('Profile Twitter', 'leads'),
 43				'desc' => __('Paste your twitter URL here.', 'leads'),
 44				'type' => 'text',
 45				'std' => ''
 46			),
 47			'email' => array(
 48				'name' => __('Profile Email Address', 'leads'),
 49				'desc' => __('Paste your email address here.', 'leads'),
 50				'type' => 'text',
 51				'std' => ''
 52			),
 53			'content' => array(
 54				'name' => __('Profile Description',  'leads'),
 55				'desc' => __('Enter the profile description text.',  'leads'),
 56				'type' => 'textarea',
 57				'std' => ''
 58			)
 59		),
 60		'shortcode' => '[profile name="{{name}}" meta="{{meta}}" image="{{image}}"]{{content}}[/profile]',
 61		'popup_title' => 'Insert Profile Shortcode'
 62	);
 63
 64/* 	Page builder module config
 65 * 	----------------------------------------------------- */
 66	$freshbuilder_modules['profile'] = array(
 67		'name' => __('Profile', 'leads'),
 68		'size' => 'one_fourth',
 69		'options' => array(
 70			'name' => array(
 71				'name' => __('Profile Name', 'leads'),
 72				'desc' => __('Enter the name.', 'leads'),
 73				'type' => 'text',
 74				'std' => '',
 75				'class' => '',
 76				'is_content' => 0
 77			),
 78			'meta' => array(
 79				'name' => __('Profile Meta', 'leads'),
 80				'desc' => __('Enter the profile meta. e.g job position etc.', 'leads'),
 81				'type' => 'text',
 82				'std' => '',
 83				'class' => '',
 84				'is_content' => 0
 85			),
 86			'image' => array(
 87				'name' => __('Profile Image', 'leads'),
 88				'desc' => __('Paste your profile image URL here.', 'leads'),
 89				'type' => 'text',
 90				'std' => '',
 91				'class' => '',
 92				'is_content' => 0
 93			),
 94			'link' => array(
 95				'name' => __('Profile Link', 'leads'),
 96				'desc' => __('Paste your profile URL here.', 'leads'),
 97				'type' => 'text',
 98				'std' => '',
 99				'class' => '',
100				'is_content' => 0
101			),
102			'facebook' => array(
103				'name' => __('Profile Facebook', 'leads'),
104				'desc' => __('Paste your facebook URL here.', 'leads'),
105				'type' => 'text',
106				'std' => '',
107				'class' => '',
108				'is_content' => 0
109			),
110			'twitter' => array(
111				'name' => __('Profile Twitter', 'leads'),
112				'desc' => __('Paste your twitter URL here.', 'leads'),
113				'type' => 'text',
114				'std' => '',
115				'class' => '',
116				'is_content' => 0
117			),
118			'email' => array(
119				'name' => __('Profile Email Address', 'leads'),
120				'desc' => __('Paste your email address here.', 'leads'),
121				'type' => 'text',
122				'std' => '',
123				'class' => '',
124				'is_content' => 0
125			),
126			'content' => array(
127				'name' => __('Profile Description', 'leads'),
128				'desc' => __('Enter the profile description text.',  'leads'),
129				'type' => 'textarea',
130				'std' => '',
131				'class' => '',
132				'is_content' => 1
133			)
134		)
135	);
136
137/* 	Add shortcode
138 * 	----------------------------------------------------- */
139	add_shortcode('profile', 'inbound_shortcode_profile');
140
141	function inbound_shortcode_profile( $atts, $content = null ) {
142		extract(shortcode_atts(array(
143			'name' => '',
144			'meta' => '',
145			'image' => '',
146			'link' => '',
147			'facebook' => '',
148			'twitter' => '',
149			'email' => ''
150		), $atts));
151
152		$out = '';
153		$out .= '<div class="profile-box clearfix">';
154
155			if($link != '') :
156				$out .= '<figure class="profile-img"><a href="'. $link .'"><img src="'. $image .'" alt="'. $name .'"/></a></figure>';
157			else :
158				$out .= '<figure class="profile-img"><img src="'. $image .'" alt="'. $name .'"/></figure>';
159			endif;
160
161			if($name != '')
162			$out .= '<h3 class="profile-name">'. $name .'</h3>';
163
164			if($meta != '')
165			$out .= '<div class="profile-meta">'. $meta .'</div>';
166
167			$out .= '<div class="profile-desc">'. do_shortcode($content) .'</div>';
168
169			if($facebook || $twitter || $email ) {
170				$out .= '<div class="profile-footer">';
171					if($facebook != '')
172					$out .= '<a href="'. $facebook .'"><i class="icon-facebook-sign"></i> Facebook</a>';
173
174					if($twitter != '')
175					$out .= '<a href="'. $twitter .'"><i class="icon-twitter"></i> Twitter</a>';
176
177					if($email != '' && is_email($email) )
178					$out .= '<a href="mailto:'. $email .'"><i class="icon-envelope-alt"></i> Email</a>';
179				$out .= '</div>';
180			}
181		$out .= '</div>';
182
183		return $out;
184	}