bp_legacy_theme_object_template_loader()

Load the template loop for the current object.


Return Return

(string|null) Prints template loop for the specified object


Source Source

File: bp-templates/bp-legacy/buddypress-functions.php

function bp_legacy_theme_object_template_loader() {
	if ( ! bp_is_post_request() ) {
		return;
	}

	// Bail if no object passed.
	if ( empty( $_POST['object'] ) ) {
		return;
	}

	// Sanitize the object.
	$object = sanitize_title( $_POST['object'] );

	// Bail if object is not an active component to prevent arbitrary file inclusion.
	if ( ! bp_is_active( $object ) ) {
		return;
	}

	/**
	 * AJAX requests happen too early to be seen by bp_update_is_directory()
	 * so we do it manually here to ensure templates load with the correct
	 * context. Without this check, templates will load the 'single' version
	 * of themselves rather than the directory version.
	 */
	if ( ! bp_current_action() )
		bp_update_is_directory( true, bp_current_component() );

	// The template part can be overridden by the calling JS function.
	if ( ! empty( $_POST['template'] ) && 'groups/single/members' === $_POST['template'] ) {
		$template_part = 'groups/single/members.php';
	} else {
		$template_part = $object . '/' . $object . '-loop.php';
	}

	$template_path = bp_locate_template( array( $template_part ), false );

	$template_path = apply_filters( 'bp_legacy_object_template_path', $template_path );

	load_template( $template_path );
	exit();
}


Top ↑

Changelog Changelog

Changelog
Version Description
1.2.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.