bbp_get_global_object( string $name = '', string $type = '', mixed $default = null )

Lookup and return a global variable


Description Description


Parameters Parameters

$name

(Optional) Name of global variable

Default value: ''

$type

(Optional) Type of variable to check with is_a()

Default value: ''

$default

(Optional) Default value to return if no global found

Default value: null


Top ↑

Return Return

(mixed) Verified object if valid, Default or null if invalid


Top ↑

Source Source

File: includes/core/abstraction.php

function bbp_get_global_object( $name = '', $type = '', $default = null ) {

	// If no name passed
	if ( empty( $name ) ) {
		$retval = $default;

	// If no global exists
	} elseif ( ! isset( $GLOBALS[ $name ] ) ) {
		$retval = $default;

	// If not the correct type of global
	} elseif ( ! empty( $type ) && ! is_a( $GLOBALS[ $name ], $type ) ) {
		$retval = $default;

	// Global variable exists
	} else {
		$retval = $GLOBALS[ $name ];
	}

	// Filter & return
	return apply_filters( 'bbp_get_global_object', $retval, $name, $type, $default );
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.5.8 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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