0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
function jma_popup($popup_id, $trigger_text, $popup_title = '', $popup_content, $trigger_class = 'btn btn-default', $fade = true, $trigger_wrap_el = '') { $x = $open = $close= ''; if($trigger_wrap_el){ $open = '<'. $trigger_wrap_el . '>'; $close = '</'. $trigger_wrap_el . '>'; } $fade = $fade? ' fade': ''; $x .= sprintf('%s<a href="#popup_' . $popup_id . '" title="' . $popup_title . '" class="' . $trigger_class . '" target="" data-toggle="modal">' . $trigger_text . '</a>%s',$open, $close); $x .= '<div class="modal' . $fade . '" id="popup_' . $popup_id . '" tabindex="-1" role="dialog" aria-hidden="true">'; $x .= '<div class="modal-dialog">'; $x .= '<div class="modal-content">'; $x .= '<div class="modal-header">'; $x .= '<button type="button" class="close" data-dismiss="modal">×</button>'; $x .= '<h3>' . $popup_title . '</h3>'; $x .= '</div><!-- modal-header (end) -->'; $x .= '<div class="modal-body">'; $x .= '<p>'; $x .= $popup_content; $x .= '</p>'; $x .= '</div><!-- .modal-body (end) -->'; $x .= '<div class="modal-footer">'; $x .= '<a href="#" class="btn btn-default" data-dismiss="modal">Close</a>'; $x .= '</div><!-- .modal-footer (end) -->'; $x .= '</div><!-- .modal-content (end) -->'; $x .= '</div><!-- .modal-dialog (end) -->'; $x .= '</div><!-- .modal (end) -->'; return $x; } |
The popup piggybacking on Themeblvd plugin:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
function jma_shortcode_popup( $atts, $content = null ) { $default = array( 'header' => '', // Header text for popup 'animate' => 'false', // Whether popup slides in or not - true, false 'image' => '' // html image element ); $atts = shortcode_atts( $default, $atts ); // ID for popup $atts['id'] = uniqid( 'popup_'.rand() ); // Set content $atts['content'] = $content; // Queue modal to be outputted in footer $popups = Theme_Blvd_Popup_Shortcode::get_instance(); $popups->add($atts); // Set button as output return apply_filters( 'themeblvd_the_content', '<a href="#'.$atts['id'].'" data-toggle="modal">' . $atts['image'] . '</a>' ); }; add_shortcode('jma_image_popup', 'jma_shortcode_popup'); |
then the shortcode is:
0 1 2 3 4 |
[jma_image_popup header="popup header" animate="true" image='<img src="http://whatever" alt="seo alt optional" />']//SINGLE QUOTES popup Content here... [/jma_image_popup] |