su_get_config

The shortcodes-ultimate su get config function.

Published Date - February 15, 2021

Description

Get plugin config.

su_get_config( $key, $default );

Parameters

  1. $key

  2. $default


Usage

The following example is for adding a hook callback.

if ( !function_exists( 'su_get_config' ) ) {
    require_once ABSPATH . PLUGINDIR . 'shortcodes-ultimateshortcodes-ultimate/includes/functions-helpers.php';
}

// The input(s). 
$key = null;
$default = false;

// NOTICE! Understand what this does before running.
$result = su_get_config( $key, $default );
            

Defined

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

shortcodes-ultimate/includes/functions-helpers.php

function su_get_config( $key = null, $default = false ) {

	static $config = array();

	if (
		empty( $key ) ||
		preg_match( '/^(?!-)[a-z0-9-_]+(?<!-)(\/(?!-)[a-z0-9-_]+(?<!-))*$/', $key ) !== 1
	) {
		return $default;
	}

	if ( isset( $config[ $key ] ) ) {
		return $config[ $key ];
	}

	$config_file = su_get_plugin_path() . 'includes/config/' . $key . '.php';

	if ( ! file_exists( $config_file ) ) {
		return $default;
	}

	$config[ $key ] = include $config_file;

	return $config[ $key ];

}