TitanFramework::getInstance PHP Method

getInstance() public static method

Gets an instance of the framework for the namespace
Since: 1.0
public static getInstance ( string $optionNamespace ) : TitanFramework
$optionNamespace string The namespace to get options from.
return TitanFramework
    public static function getInstance($optionNamespace)
    {
        // Clean namespace.
        $optionNamespace = str_replace(' ', '-', trim(strtolower($optionNamespace)));
        foreach (self::$instances as $instance) {
            if ($instance->optionNamespace == $optionNamespace) {
                return $instance;
            }
        }
        $newInstance = new TitanFramework($optionNamespace);
        self::$instances[] = $newInstance;
        return $newInstance;
    }

Usage Example

Ejemplo n.º 1
0
/**
 * [bootswatch_hook_callback description]
 */
function bootswatch_hook_callback()
{
    $hook = preg_replace('/^bootswatch_/', '', current_filter());
    $content = TitanFramework::getInstance('bootswatch')->getOption($hook);
    printf('<div class="%s">%s</div>', 'bootswatch_' . $hook, do_shortcode($content));
    // WPCS: XSS OK.
}
All Usage Examples Of TitanFramework::getInstance