PageRenderTime 37ms CodeModel.GetById 8ms app.highlight 22ms RepoModel.GetById 1ms app.codeStats 1ms

/shared/shortcodes/shortcodes/callout.php

https://github.com/deltafactory/landing-pages
PHP | 167 lines | 151 code | 7 blank | 9 comment | 2 complexity | f9365d8fc78bc82c71c55cee7a5eee43 MD5 | raw file
  1<?php
  2/**
  3*   Call Out Shortcode
  4*/
  5
  6/* 	Shortcode generator config
  7 * 	----------------------------------------------------- */
  8	$shortcodes_config['callout'] = array(
  9		'no_preview' => true,
 10		'options' => array(
 11			'title' => array(
 12				'name' => __('Title', 'leads'),
 13				'desc' => __('Enter the heading text.', 'leads'),
 14				'type' => 'text',
 15				'std' => ''
 16			),
 17			'subtitle' => array(
 18				'name' => __('Sub Title', 'leads'),
 19				'desc' => __('Enter the sub title.', 'leads'),
 20				'type' => 'textarea',
 21				'std' => ''
 22			),
 23			'button_color' => array(
 24				'name' => __('Button Color', 'leads'),
 25				'desc' => __('Select the button color.', 'leads'),
 26				'type' => 'select',
 27				'options' => array(
 28					'default' => 'Default',
 29					'black' => 'Black',
 30					'blue' => 'Blue',
 31					'brown' => 'Brown',
 32					'green' => 'Green',
 33					'orange' => 'Orange',
 34					'pink' => 'Pink',
 35					'purple' => 'Purple',
 36					'red' => 'Red',
 37					'silver' => 'Silver',
 38					'yellow' => 'Yellow',
 39					'white' => 'White'
 40				),
 41				'std' => 'default'
 42			),
 43			'button_label' => array(
 44				'name' => __('Button Text Label', 'leads'),
 45				'desc' => __('Enter the button text label.', 'leads'),
 46				'type' => 'text',
 47				'std' => ''
 48			),
 49			'button_icon' => array(
 50				'name' => __('Button Icon', 'leads'),
 51				'desc' => __('Select an icon.', 'leads'),
 52				'type' => 'select',
 53				'options' => $fontawesome,
 54				'std' => 'none'
 55			),
 56			'link' => array(
 57				'name' => __('Link', 'leads'),
 58				'desc' => __('Enter the button link destination URL.', 'leads'),
 59				'type' => 'text',
 60				'std' => ''
 61			)
 62		),
 63		'shortcode' => '[callout title="{{title}}" subtitle="{{subtitle}}" button_label="{{button_label}}" button_icon="{{button_icon}}" link="{{link}}"]',
 64		'popup_title' => 'Insert Call Out Shortcode'
 65	);
 66
 67/* 	Page builder module config
 68 * 	----------------------------------------------------- */
 69	$freshbuilder_modules['callout'] = array(
 70		'name' => __('Call Out', 'leads'),
 71		'size' => 'one_full',
 72		'options' => array(
 73			'title' => array(
 74				'name' => __('Title', 'leads'),
 75				'desc' => __('Enter the heading text.', 'leads'),
 76				'type' => 'text',
 77				'class' => '',
 78				'is_content' => '0'
 79			),
 80			'subtitle' => array(
 81				'name' => __('Sub Title', 'leads'),
 82				'desc' => __('Enter the sub title.', 'leads'),
 83				'type' => 'textarea',
 84				'class' => '',
 85				'is_content' => '0'
 86			),
 87			'button_color' => array(
 88				'name' => __('Button Color', 'leads'),
 89				'desc' => __('Select the button color.', 'leads'),
 90				'type' => 'select',
 91				'options' => array(
 92					'default' => 'Default',
 93					'black' => 'Black',
 94					'blue' => 'Blue',
 95					'brown' => 'Brown',
 96					'green' => 'Green',
 97					'orange' => 'Orange',
 98					'pink' => 'Pink',
 99					'purple' => 'Purple',
100					'red' => 'Red',
101					'silver' => 'Silver',
102					'yellow' => 'Yellow',
103					'white' => 'White'
104				),
105				'std' => 'default',
106				'class' => '',
107				'is_content' => '0'
108			),
109			'button_label' => array(
110				'name' => __('Button Text Label', 'leads'),
111				'desc' => __('Enter the button text label.', 'leads'),
112				'type' => 'text',
113				'class' => '',
114				'is_content' => '0'
115			),
116			'button_icon' => array(
117				'name' => __('Button Icon', 'leads'),
118				'desc' => __('Select an icon.', 'leads'),
119				'type' => 'select',
120				'options' => $fontawesome,
121				'std' => 'none',
122				'class' => '',
123				'is_content' => '0'
124			),
125			'link' => array(
126				'name' => __('Link', 'leads'),
127				'desc' => __('Enter the button link destination URL.', 'leads'),
128				'type' => 'text',
129				'class' => '',
130				'is_content' => '0'
131			)
132		)
133	);
134
135/* 	Add shortcode
136 * 	----------------------------------------------------- */
137	add_shortcode('callout', 'inbound_shortcode_callout');
138	if (!function_exists('inbound_shortcode_callout')) {
139		function inbound_shortcode_callout( $atts, $content = null ) {
140			extract(shortcode_atts(array(
141				'title' => '',
142				'subtitle' => '',
143				'button_color' => '',
144				'button_label' => '',
145				'button_icon' => '',
146				'link' => ''
147			), $atts));
148
149			$icon = ($button_icon) ? '<i class="icon-'. $button_icon .'"></i>&nbsp;&nbsp;' : '';
150
151			$out = '';
152			$out .= '<div class="callout clearfix">';
153				$out .= '<div class="left">';
154					$out .= '<h2>'. $title .'</h2>';
155					$out .= '<div class="subtitle">'. $subtitle .'</div>';
156				$out .= '</div>';
157
158				if ($link ) :
159				$out .= '<div class="right">';
160					$out .= '<a class="button '. $button_color .'" href="'. $link .'">'. $icon . $button_label .'</a>';
161				$out .= '</div>';
162				endif;
163			$out .= '</div>';
164
165			return $out;
166		}
167	}