su_shortcode_expand

The shortcodes-ultimate su shortcode expand function.

Published Date - February 15, 2021

Description

su_shortcode_expand( $atts, $content );

Parameters

  1. $atts

  2. $content


Usage

The following example is for adding a hook callback.

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

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

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

Defined

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

shortcodes-ultimate/includes/shortcodes/expand.php

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

	$atts = shortcode_atts( array(
			'more_text'  => __( 'Show more', 'shortcodes-ultimate' ),
			'less_text'  => __( 'Show less', 'shortcodes-ultimate' ),
			'height'     => '100',
			'hide_less'  => 'no',
			'text_color' => '#333333',
			'link_color' => '#0088FF',
			'link_style' => 'default',
			'link_align' => 'left',
			'more_icon'  => '',
			'less_icon'  => '',
			'class'      => ''
		), $atts, 'expand' );

	// Prepare more icon
	$more_icon = ( $atts['more_icon'] ) ? su_html_icon( $atts['more_icon'] ) : '';
	$less_icon = ( $atts['less_icon'] ) ? su_html_icon( $atts['less_icon'] ) : '';

	if ( $more_icon || $less_icon ) {
		su_query_asset( 'css', 'su-icons' );
	}

	// Prepare less link
	$less = $atts['hide_less'] !== 'yes'
		? '<div class="su-expand-link su-expand-link-less" style="text-align:' . $atts['link_align'] . '"><a href="javascript:;" style="color:' . $atts['link_color'] . ';border-color:' . $atts['link_color'] . '">' . $less_icon . '<span style="border-color:' . $atts['link_color'] . '">' . $atts['less_text'] . '</span></a></div>'
		: '';

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

	return '<div class="su-expand su-expand-collapsed su-expand-link-style-' . $atts['link_style'] . su_get_css_class( $atts ) . '" data-height="' . $atts['height'] . '"><div class="su-expand-content su-u-trim" style="color:' . $atts['text_color'] . ';max-height:' . intval( $atts['height'] ) . 'px;overflow:hidden">' . do_shortcode( $content ) . '</div><div class="su-expand-link su-expand-link-more" style="text-align:' . $atts['link_align'] . '"><a href="javascript:;" style="color:' . $atts['link_color'] . ';border-color:' . $atts['link_color'] . '">' . $more_icon . '<span style="border-color:' . $atts['link_color'] . '">' . $atts['more_text'] . '</span></a></div>' . $less . '</div>';

}