Last active
July 8, 2024 08:44
-
-
Save egdoc/9b67d95aa095889f975cec64d1e34154 to your computer and use it in GitHub Desktop.
Linuxconfig wordpress textbox shortcode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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