# bbp-core/2.0.0/includes/template-functions.php

Forumax – AI Powered Advanced Community Forum Plugin, version 2.0.0. 122 lines.

- Page: https://pluginprobe.com/plugins/bbp-core/2.0.0/code/includes/template-functions.php
- Raw: https://pluginprobe.com/plugins/bbp-core/2.0.0/raw/includes/template-functions.php
- Modified: 2026-01-01T11:09:22+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/bbp-core/2.0.0/code/includes/template-functions.php#L10-L20`.

```php
<?php
/**
 * Template Functions for Forumax
 *
 * @package Forumax
 */

defined( 'ABSPATH' ) || exit;

/**
 * Register external template stack locations
 * @return void
 */
add_action( 'after_setup_theme', 'forumax_register_external_templates', 5 );
function forumax_register_external_templates() {

	/** 
	 * External templates (themes + plugins) - HIGHEST PRIORITY
	 * This allows theme templates to override plugin templates
	 * @return void
	 */
	foreach ( forumax_get_external_template_dirs() as $dir ) {
		bbp_register_template_stack( fn() => trailingslashit( $dir ), 1 );
	}

	/**
	 * Plugin fallback templates - LOWER PRIORITY
	 * (runs if theme doesn't override)
	 * @return void
	 */
	bbp_register_template_stack( fn() => trailingslashit( FORUMAX_PATH . 'templates' ), 5 );
}

/**
 * Get template directories from themes, child themes, and plugins
 * using /forumax or /bbpress folders (when supported).
 *
 * @return array
 */
function forumax_get_external_template_dirs() {
	$dirs   = [];
	$slugs  = [ 'forumax', 'bbpress' ];
	$themes = [ get_template_directory(), get_stylesheet_directory() ];

	// === Themes ===
	foreach ( array_unique( $themes ) as $theme ) {
		foreach ( $slugs as $slug ) {
			$path = trailingslashit( $theme ) . $slug . '/';
			if ( is_dir( $path ) ) {
				$dirs[] = $path;
			}
		}
	}

	// === Plugins ===
	foreach ( glob( WP_PLUGIN_DIR . '/*', GLOB_ONLYDIR ) as $plugin ) {
		if ( basename( $plugin ) === 'forumax' ) {
			continue;
		}

		foreach ( $slugs as $slug ) {
			$path = trailingslashit( $plugin ) . $slug . '/';
			if ( is_dir( $path ) ) {
				$dirs[] = $path;
			}
		}
	}

	return $dirs;
}

/**
 * Extend bbPress template locations
 */
add_filter( 'bbp_get_template_locations', 'forumax_extend_template_locations', 10, 2 );
function forumax_extend_template_locations( $locations ) {

	foreach ( [ 'forumax', 'bbpress' ] as $slug ) {
		if ( ! in_array( $slug, $locations, true ) ) {
			array_unshift( $locations, $slug );
		}
	}

	return $locations;
}

/**
 * Banner preset background styles
 *
 * @return array[]|string[]
 */
function forumax_banner_bg_style() {
	return array(
		'color'           => FORUMAX_IMG . '/options/color.png',
		'faded-sun'       => FORUMAX_IMG . '/options/faded-sun.jpg',
		'happy-journey'   => FORUMAX_IMG . '/options/happy-journey.jpg',
		'apparent-circle' => FORUMAX_IMG . '/options/apparent-circle.jpg',
		'soft-weather'    => FORUMAX_IMG . '/options/soft-weather.jpg',
		'romantic-sun'    => FORUMAX_IMG . '/options/romantic-sun.jpg',
		'teal-eclipse'    => FORUMAX_IMG . '/options/teal-eclipse.jpg',
	);
}


	
/**
* Image from Settings
*
* @param string $option_id
* @param string $class
* @param string $alt
*/
function get_image_from_settings( string $option_id = '', string $class = '', string $alt = '' ):void {		
	$image = forumax_get_opt($option_id) ?? '';

	// Check if the image has an 'id' or a 'url' and display accordingly
	if ( ! empty($image['id']) ) {
		echo wp_get_attachment_image($image['id'], 'full', '' );
	} elseif ( !empty($image['url']) ) {
		echo "<img src='{$image['url']}'>";
	}
}
```
