Skip to content

Instantly share code, notes, and snippets.

@egdoc
Last active July 8, 2024 08:44
Show Gist options
  • Select an option

  • Save egdoc/9b67d95aa095889f975cec64d1e34154 to your computer and use it in GitHub Desktop.

Select an option

Save egdoc/9b67d95aa095889f975cec64d1e34154 to your computer and use it in GitHub Desktop.
Linuxconfig wordpress textbox shortcode
<?php
function linuxconfig_textbox( $atts, $content = null ) {
$defaults = array(
"title" => "This is the box title",
"type" => "warning"
);
$parsed_atts = shortcode_atts( $defaults, $atts );
if ( ! in_array( $parsed_atts['type'], array( "warning", "success", "danger" ) ) ) {
$parsed_atts['type'] = $defaults['type'];
}
ob_start();
?>
<div style="text-align: center;" class="<?php echo esc_attr( "uk-alert uk-alert-{$parsed_atts['type']}" ); ?>">
<p style="text-align: center;">
<b><?php echo strtoupper(esc_html( $parsed_atts['title'] ) ); ?></b>
<br>
<?php echo trim($content); ?></p>
</div>
<?php
return ob_get_clean();
}
add_shortcode('textbox', 'linuxconfig_textbox');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment