su_shortcode_template

The shortcodes-ultimate su shortcode template function.

Published Date - February 15, 2021

Description

su_shortcode_template( $atts, $content );

Parameters

  1. $atts

  2. $content


Usage

The following example is for adding a hook callback.

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

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

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

Defined

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

shortcodes-ultimate/includes/shortcodes/template.php

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

	$atts = shortcode_atts( array( 'name' => '' ), $atts, 'template' );

	if ( ! $atts['name'] ) {
		return su_error_message( 'Template', __( 'please specify template name', 'shortcodes-ultimate' ) );
	}

	if ( ! su_is_valid_template_name( $atts['name'] ) ) {
		return su_error_message( 'Template', __( 'invalid template name', 'shortcodes-ultimate' ) );
	}

	ob_start();
	get_template_part( su_set_file_extension( $atts['name'], false ) );
	$output = ob_get_clean();

	return $output;

}