su_shortcode_box

The shortcodes-ultimate su shortcode box function.

Published Date - February 15, 2021

Description

su_shortcode_box( $atts, $content );

Parameters

  1. $atts

  2. $content


Usage

The following example is for adding a hook callback.

if ( !function_exists( 'su_shortcode_box' ) ) {
    require_once ABSPATH . PLUGINDIR . 'shortcodes-ultimateshortcodes-ultimate/includes/shortcodes/box.php';
}

// The input(s). 
$atts = null;
$content = null;

// NOTICE! Understand what this does before running.
$result = su_shortcode_box( $atts, $content );
            

Defined

The function is defined in the following location(s).

shortcodes-ultimate/includes/shortcodes/box.php

function su_shortcode_box( $atts = null, $content = null ) {

	$atts = shortcode_atts(
		array(
			'title'       => __( 'This is box title', 'shortcodes-ultimate' ),
			'style'       => 'default',
			'box_color'   => '#333333',
			'title_color' => '#FFFFFF',
			'color'       => null, // 3.x
			'radius'      => '3',
			'class'       => '',
			'id'          => '',
		),
		$atts,
		'box'
	);

	if ( null !== $atts['color'] ) {
		$atts['box_color'] = $atts['color'];
	}

	$atts['radius'] = is_numeric( $atts['radius'] )
		? intval( $atts['radius'] )
		: 0;

	$atts['inner_radius'] = $atts['radius'] > 2
		? $atts['radius'] - 2
		: 0;

	su_query_asset( 'css', 'su-shortcodes' );

	// Return result
	return sprintf(
		'<div class="su-box su-box-style-%1$s%2$s" id="%10$s" style="border-color:%3$s;border-radius:%4$spx"><div class="su-box-title" style="background-color:%5$s;color:%6$s;border-top-left-radius:%7$spx;border-top-right-radius:%7$spx">%8$s</div><div class="su-box-content su-u-clearfix su-u-trim" style="border-bottom-left-radius:%7$spx;border-bottom-right-radius:%7$spx">%9$s</div></div>',
		esc_attr( $atts['style'] ),
		su_get_css_class( $atts ),
		su_adjust_brightness( $atts['box_color'], -20 ),
		$atts['radius'],
		$atts['box_color'],
		$atts['title_color'],
		$atts['inner_radius'],
		su_do_attribute( $atts['title'] ),
		su_do_nested_shortcodes( $content, 'box' ),
		sanitize_html_class( $atts['id'] )
	);

}