I'd like the have the output of the html return two possible markups based on a parameter the user can set. The parameter text_mode
will be defined by the user by adding basic
or advanced
.
Right now, the $output
is set for testing to show the basic version whereby the user's string is wrapped in a <p>
. If the text_mode
is set to advanced, then it's not wrapped.
<?php
function PCHiddenTextBlock( $settings = array() ) {
//---- Get Settings ----
//The functions default settings will be merged with what's passed in.
$settingsDefault = array(
'small_heading' => '',
'text' => '',
'text_mode' => 'basic', //or advanced
'color_scheme' => 'accent4',//accent4 or accent1
'container_id' => '',
'container_class' => 'x_extraContent',
);
$settings = array_merge($settingsDefault, $settings);
//---- Set Variables ----
//These will allow the markup build up to be as clean as possible.
//If container_id is set, prepare the attribute
$has_container_id = strlen($settings['container_id']) > 0;
$possible_container_id_attribute = ($has_container_id) ? " id='{$settings['container_id']}'" : "";
//Color scheme variables
switch($settings['color_scheme']) {
case 'accent1':
$gcol_color_class = 'bg-color-accent1-C';
$color_accent_class = 'color-accent1-8';
$hover_color_class = 'hover-color-base-4';
break;
default: //accent4
$gcol_color_class = 'bg-color-accent4-D';
$color_accent_class = 'color-accent4-A';
$hover_color_class = 'hover-color-base-4';
}
//---- Build Output ----
//Line by line, concatenating strings with new line and tab characters.
$output = "
<!-- Hidden Text Block -->";
$output .= "
<div class='{$settings['container_class']} gcol-1 {$gcol_color_class}'{$possible_container_id_attribute}>";
$output .= "
\t<div class='padbox-standard-content'>";
$output .= "
\t\t<h2 class='small-heading color-accent1-9'>{$settings['small_heading']}</h2>";
$output .= "
\t\t<p>{$settings['text']}</p>"; // basic version
$output .= "
\t\t<a href='' class='x_extraContentClose box-close-icon {$color_accent_class} {$hover_color_class}'></a>";
$output .= "
\t</div><!-- padbox-standard-content-->";
$output .= "
</div><!-- Hiddent Text Block -->";
//---- Return Output ----
return $output;
}