su_shortcode_divider

The shortcodes-ultimate su shortcode divider function.

Published Date - February 15, 2021

Description

su_shortcode_divider( $atts, $content );

Parameters

  1. $atts

  2. $content


Usage

The following example is for adding a hook callback.

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

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

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

Defined

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

shortcodes-ultimate/includes/shortcodes/divider.php

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

	$atts = su_parse_shortcode_atts( 'divider', $atts );

	$atts['margin']        = intval( $atts['margin'] );
	$atts['size']          = intval( $atts['size'] );
	$atts['divider_color'] = sanitize_text_field( $atts['divider_color'] );
	$atts['link_color']    = sanitize_text_field( $atts['link_color'] );
	$atts['anchor']        = sanitize_html_class( $atts['anchor'] );

	$top_link  = '';
	$div_style = array(
		"margin:{$atts['margin']}px 0",
		"border-width:{$atts['size']}px",
		"border-color:{$atts['divider_color']}",
	);
	$a_style   = array( "color:{$atts['link_color']}" );

	if ( 'yes' === $atts['top'] ) {

		$top_link = sprintf(
			'<a href="#%1$s"%2$s>%3$s</a>',
			$atts['anchor'],
			su_html_style( $a_style ),
			su_do_attribute( $atts['text'] )
		);

	}

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

	return sprintf(
		'<div class="su-divider su-divider-style-%1$s%2$s"%3$s>%4$s</div>',
		sanitize_key( $atts['style'] ),
		su_get_css_class( $atts ),
		su_html_style( $div_style ),
		$top_link
	);

}