Current File : /home/kelaby89/sergio-cuchi.tattoo/wp-content/plugins/maori-features/shortcodes.php |
<?php
add_shortcode('mpbutton', 'mpbutton');
add_shortcode('mpalert', 'mpalert');
add_shortcode('mprogress', 'mprogress');
add_shortcode('mpmodal', 'mpmodal');
add_filter("the_content", "maori_content_filter");
add_filter("widget_text", "do_shortcode");
add_filter("widget_text", "maori_content_filter", 9);
function maori_content_filter($content) {
// array of custom shortcodes requiring the fix
$block = join("|",array("contact-form-7","mpbutton","mpalert","mprogress","mpaccordion","mpaccordioncontainer","mpmodal"));
// opening tag
$rep = preg_replace("/(<p>)?\[($block)(\s[^\]]+)?\](<\/p>|<br \/>)?/","[$2$3]",$content);
// closing tag
$rep = preg_replace("/(<p>)?\[\/($block)](<\/p>|<br \/>)?/","[/$2]",$rep);
return $rep;
}
// Modal
function mpmodal($atts, $content = null) {
$random_id = rand();
extract(shortcode_atts(array(
"text" => 'text',
"style" => 'style',
"outline" => 'outline',
"size" => 'size',
"title" => 'title'
), $atts));
if (empty($outline)) {
return '<a href="#" class="btn btn-' . esc_html($style) . ' ' . esc_html($size) . '" data-toggle="modal" data-target="#modal-' . esc_html($random_id) . '">' . esc_html($text) . '</a><div class="modal fade" id="modal-' . esc_html($random_id) . '" tabindex="-1" role="dialog" aria-labelledby="modal-' . esc_html($random_id) . '-label" aria-hidden="true"><div class="modal-dialog modal-dialog-centered" role="document"><div class="modal-content"><div class="modal-header">
<h5 class="modal-title" id="modal-' . esc_html($random_id) . '-label">' . esc_html($title) . '</h5><div class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></div></div><div class="modal-body">' . wp_kses_post($content) . '</div></div></div></div>';
} else {
return '<a href="#" class="btn btn-outline-' . esc_html($style) . ' ' . esc_html($size) . '" data-toggle="modal" data-target="#modal-' . esc_html($random_id) . '">' . esc_html($text) . '</a><div class="modal fade" id="modal-' . esc_html($random_id) . '" tabindex="-1" role="dialog" aria-labelledby="modal-' . esc_html($random_id) . '-label" aria-hidden="true"><div class="modal-dialog modal-dialog-centered" role="document"><div class="modal-content"><div class="modal-header">
<h5 class="modal-title" id="modal-' . esc_html($random_id) . '-label">' . esc_html($title) . '</h5><div class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></div></div><div class="modal-body">' . wp_kses_post($content) . '</div></div></div></div>';
}
}
// Progress
function mprogress($atts, $content = null) {
extract(shortcode_atts(array(
"style" => 'style',
"value" => 'value',
"label" => 'label',
"striped" => 'striped',
"animated" => 'animated'
), $atts));
if (empty($striped)) {
return '<div class="progress"><div class="progress-bar bg-' . esc_html($style) . '" style="width: ' . esc_html($value) . '%" role="progressbar" aria-valuenow="' . esc_html($value) . '" aria-valuemin="0" aria-valuemax="100"><span>' . esc_html($label) . '</span> ' . esc_html($value) . '%</div></div>';
} else {
if (empty($animated)) {
return '<div class="progress"><div class="progress-bar progress-bar-striped bg-' . esc_html($style) . '" style="width: ' . esc_html($value) . '%" role="progressbar" aria-valuenow="' . esc_html($value) . '" aria-valuemin="0" aria-valuemax="100"><span>' . esc_html($label) . '</span> ' . esc_html($value) . '%</div></div>';
} else {
return '<div class="progress"><div class="progress-bar progress-bar-striped bg-' . esc_html($style) . ' progress-bar-animated" style="width: ' . esc_html($value) . '%" role="progressbar" aria-valuenow="' . esc_html($value) . '" aria-valuemin="0" aria-valuemax="100"><span>' . esc_html($label) . '</span> ' . esc_html($value) . '%</div></div>';
}
}
}
// Alert
function mpalert($atts, $content = null) {
extract(shortcode_atts(array(
"style" => 'style',
"dismissible" => 'dismissible'
), $atts));
if (empty($dismissible)) {
return '<div class="alert alert-' . esc_html($style) . '">' . wp_kses_post($content) . '</div>';
} else {
return '<div class="alert alert-' . esc_html($style) . '"><div class="close" data-dismiss="alert">×</div>' . wp_kses_post($content) . '</div>';
}
}
// Button
function mpbutton($atts, $content = null) {
extract(shortcode_atts(array(
"url" => 'url',
"newtab" => 'newtab',
"style" => 'style',
"outline" => 'outline',
"size" => 'size'
), $atts));
if ($newtab != 'yes') {
if (empty($outline)) {
return '<a href="' . esc_url($url) . '" class="btn btn-' . esc_html($style) . ' ' . esc_html($size) . '">' . esc_html($content) . '</a>';
} else {
return '<a href="' . esc_url($url) . '" class="btn btn-outline-' . esc_html($style) . ' ' . esc_html($size) . '">' . esc_html($content) . '</a>';
}
}
else
{
if (empty($outline)) {
return '<a href="' . esc_url($url) . '" target="_blank" class="btn btn-' . esc_html($style) . ' ' . esc_html($size) . '">' . esc_html($content) . '</a>';
} else {
return '<a href="' . esc_url($url) . '" target="_blank" class="btn btn-outline-' . esc_html($style) . ' ' . esc_html($size) . '">' . esc_html($content) . '</a>';
}
}
}
?>