/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. /* Shortcode generator config
  6. * ----------------------------------------------------- */
  7. $shortcodes_config['alert'] = array(
  8. 'no_preview' => true,
  9. 'options' => array(
  10. 'color' => array(
  11. 'name' => __('Color Style', 'leads'),
  12. 'desc' => __('Select the style.', 'leads'),
  13. 'type' => 'select',
  14. 'options' => array(
  15. 'default' => __('Default', 'leads'),
  16. 'blue' => __('Blue', 'leads'),
  17. 'green' => __('Green', 'leads'),
  18. 'red' => __('Red', 'leads'),
  19. 'yellow' => __('Yellow', 'leads')
  20. ),
  21. 'std' => ''
  22. ),
  23. 'content' => array(
  24. 'name' => __('Message', 'leads'),
  25. 'desc' => __('Your message here.', 'leads'),
  26. 'type' => 'textarea',
  27. 'std' => ''
  28. )
  29. ),
  30. 'shortcode' => '[alert color="{{color}}"]{{content}}[/alert]',
  31. 'popup_title' => 'Insert Alert Message Shortcode'
  32. );
  33. /* Add shortcode
  34. * ----------------------------------------------------- */
  35. add_shortcode('alert', 'inbound_shortcode_alert');
  36. if (!function_exists('inbound_shortcode_alert')) {
  37. function inbound_shortcode_alert( $atts, $content = null ) {
  38. extract(shortcode_atts(array(
  39. 'color' => ''
  40. ), $atts));
  41. return '<div class="alert-message '.$color.'">'.do_shortcode($content).'</div>';
  42. }
  43. }