# easy-bootstrap-shortcodes/trunk/shortcode/oscpopover/plugin_shortcode.php

Easy Bootstrap Shortcode, version trunk. 114 lines.

- Page: https://pluginprobe.com/plugins/easy-bootstrap-shortcodes/trunk/code/shortcode/oscpopover/plugin_shortcode.php
- Raw: https://pluginprobe.com/plugins/easy-bootstrap-shortcodes/trunk/raw/shortcode/oscpopover/plugin_shortcode.php
- Modified: 2026-08-06T19:58:08+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/easy-bootstrap-shortcodes/trunk/code/shortcode/oscpopover/plugin_shortcode.php#L10-L20`.

```php
<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
use EBS\Security\Sanitizer;

function osc_theme_popover($params, $content = 'Popover') {
    $atts = shortcode_atts(array(
        'trigger' => '',
        'title' => '',
        'pop_content' => '',
        'style' => '',
        'size' => '',
        'type' => '',
        'class' => ''
    ), $params);

    $trigger     = Sanitizer::attr( $atts['trigger'] );
    $title       = Sanitizer::attr( $atts['title'] );
    $pop_content = Sanitizer::attr( $atts['pop_content'] );
    $style       = Sanitizer::attr( $atts['style'] );
    $size        = Sanitizer::class_list( $atts['size'] );
    $type        = Sanitizer::class_list( $atts['type'] );
    $class       = Sanitizer::class_list( $atts['class'] );

    $out = '';
    $out = '<button class="osc_popover btn ' . $size . ' ' . $type . ' ' . $class . EBS_CONTAINER_CLASS . '" data-content="' . $pop_content . '" data-placement="' . $style . '" data-toggle="popover" data-trigger="' . $trigger . '" data-container="body" type="button" data-title="' . $title . '"> ' . do_shortcode( $content ) . ' </button>';

    if ( EBS_POPOVER_TEMPLATE === '' ) {
        $out .= "
    <script>
       jQuery(document).ready(function(){
        jQuery('.osc_popover').popover();
        });
    </script>
    ";

    } else {
        $out .= "
    <script>
       jQuery(document).ready(function(){
        jQuery('.osc_popover').popover({template:'" . EBS_POPOVER_TEMPLATE . "'});
        });
    </script>
    ";
    }
    return $out;
}

$_osc_popover_array = array( 'count' => 0 );

function osc_theme_popover_new($params, $content = '') {
    global $_osc_popover_array;
    $atts = shortcode_atts(array(
        'id' => count( $_osc_popover_array ),
        'trigger' => '',
        'title' => '',
        'button_text' => 'Popover',
        'style' => '',
        'size' => '',
        'type' => '',
        'class' => ''
    ), $params);

    $id          = Sanitizer::int( $atts['id'] );
    $trigger     = Sanitizer::attr( $atts['trigger'] );
    $title       = Sanitizer::attr( $atts['title'] );
    $button_text = Sanitizer::html( $atts['button_text'] );
    $style       = Sanitizer::attr( $atts['style'] );
    $size        = Sanitizer::class_list( $atts['size'] );
    $type        = Sanitizer::class_list( $atts['type'] );
    $class       = Sanitizer::class_list( $atts['class'] );

    $_osc_popover_array[ $id ] = array();
    $out = '';
    $out = '<button class="osc_popover_new btn ' . $size . ' ' . $type . ' ' . $class . EBS_CONTAINER_CLASS . '" data-placement="' . $style . '" data-toggle="popover" data-trigger="' . $trigger . '" data-container="body" type="button" data-title="' . $title . '" data-contentwrapper="osc_popover_' . $id . '"> ' . $button_text . ' </button>';
    $out .= '<div id="osc_popover_' . $id . '" style="display:none;">' . do_shortcode( $content ) . '</div>';

    if ( EBS_POPOVER_TEMPLATE === '' ) {
        $out .= "
    <script>
       jQuery(document).ready(function(){
        jQuery('.osc_popover_new').popover({
            html:true,
            content:function(){
                return jQuery('#'+jQuery(this).data('contentwrapper')).html();
            }

        });
        });
    </script>
    ";

    } else {
        $out .= "
    <script>
        jQuery(document).ready(function(){
            jQuery('.osc_popover_new').popover({
                template:'" . EBS_POPOVER_TEMPLATE . "',
                html:true,
                content:function(){
                     return jQuery('#'+jQuery(this).data('contentwrapper')).html();
                }
            });
        });
    </script>
    ";
    }
    return $out;
}

ebs_backward_compatibility_callback('popover', 'osc_theme_popover');
ebs_backward_compatibility_callback('popovernew', 'osc_theme_popover_new');

```
