su_shortcode_display_posts_locate_template

The shortcodes-ultimate su shortcode display posts locate template function.

Published Date - February 15, 2021

Description

su_shortcode_display_posts_locate_template( $template );

Parameters

  1. $template


Usage

The following example is for adding a hook callback.

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

// The input(s). 
$template = null;

// NOTICE! Understand what this does before running.
$result = su_shortcode_display_posts_locate_template( $template );
            

Defined

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

shortcodes-ultimate/includes/shortcodes/display-posts.php

function su_shortcode_display_posts_locate_template( $template ) {

	$template = su_set_file_extension( $template, 'php' );
	$template = ltrim( $template, '\\/' );

	$locations = array(
		path_join( get_stylesheet_directory(), 'su-display-posts' ),
		path_join( get_template_directory(), 'su-display-posts' ),
		path_join( su_get_plugin_path(), 'includes/partials/shortcodes/display-posts' ),
	);

	foreach ( $locations as $location ) {

		$path = path_join( $location, $template );
		$path = realpath( $path );

		if ( strpos( $path, $location ) === 0 && file_exists( $path ) ) {
			return $path;
		}

	}

	return false;

}