PageRenderTime 15ms CodeModel.GetById 12ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/shared/shortcodes/shortcodes/alert.php

https://github.com/deltafactory/landing-pages
PHP | 46 lines | 36 code | 3 blank | 7 comment | 1 complexity | eb3d4e4ba8f85cb2f68cb71b3d98b5aa MD5 | raw file
 1<?php
 2/**
 3*	Alert Shortcode
 4*/
 5
 6/* 	Shortcode generator config
 7 * 	----------------------------------------------------- */
 8	$shortcodes_config['alert'] = array(
 9		'no_preview' => true,
10		'options' => array(
11			'color' => array(
12				'name' => __('Color Style', 'leads'),
13				'desc' => __('Select the style.', 'leads'),
14				'type' => 'select',
15				'options' => array(
16					'default' => __('Default', 'leads'),
17					'blue' => __('Blue', 'leads'),
18					'green' => __('Green', 'leads'),
19					'red' => __('Red', 'leads'),
20					'yellow' => __('Yellow', 'leads')
21				),
22				'std' => ''
23			),
24			'content' => array(
25				'name' => __('Message', 'leads'),
26				'desc' => __('Your message here.', 'leads'),
27				'type' => 'textarea',
28				'std' => ''
29			)
30		),
31		'shortcode' => '[alert color="{{color}}"]{{content}}[/alert]',
32		'popup_title' => 'Insert Alert Message Shortcode'
33	);
34
35/* 	Add shortcode
36 * 	----------------------------------------------------- */
37	add_shortcode('alert', 'inbound_shortcode_alert');
38	if (!function_exists('inbound_shortcode_alert')) {
39		function inbound_shortcode_alert( $atts, $content = null ) {
40			extract(shortcode_atts(array(
41				'color' => ''
42			), $atts));
43
44			return '<div class="alert-message '.$color.'">'.do_shortcode($content).'</div>';
45		}
46	}