| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'BVS_VERSION' ) ) { |
| 4 |
define( 'BVS_VERSION', '1.1.1' ); |
| 5 |
} |
| 6 |
|
| 7 |
if ( ! defined( 'BVS_DIR' ) ) { |
| 8 |
define( 'BVS_DIR', trailingslashit( dirname( __FILE__ ) ) ); |
| 9 |
} |
| 10 |
|
| 11 |
if ( ! defined( 'BVS_URL' ) ) { |
| 12 |
define( 'BVS_URL', plugin_dir_url( __FILE__ ) ); |
| 13 |
} |
| 14 |
|
| 15 |
if ( ! function_exists( 'bv_settings_register_component' ) ) { |
| 16 |
/** |
| 17 |
* Register a BV Settings component implementation. |
| 18 |
* |
| 19 |
* @since 1.1.0 |
| 20 |
* @param string $version Component version. |
| 21 |
* @param string $dir Component base directory. |
| 22 |
* @param string $url Component base URL. |
| 23 |
* @param string $loader Loader file for the implementation. |
| 24 |
* @param string $class Implementation class name. |
| 25 |
*/ |
| 26 |
function bv_settings_register_component( $version, $dir, $url, $loader, $class ) { |
| 27 |
if ( ! isset( $GLOBALS['bv_settings_components'] ) || ! is_array( $GLOBALS['bv_settings_components'] ) ) { |
| 28 |
$GLOBALS['bv_settings_components'] = array(); |
| 29 |
} |
| 30 |
|
| 31 |
$component = array( |
| 32 |
'version' => $version, |
| 33 |
'dir' => trailingslashit( $dir ), |
| 34 |
'url' => trailingslashit( $url ), |
| 35 |
'loader' => $loader, |
| 36 |
'class' => $class, |
| 37 |
); |
| 38 |
|
| 39 |
$GLOBALS['bv_settings_components'][ $version ] = $component; |
| 40 |
|
| 41 |
if ( |
| 42 |
! isset( $GLOBALS['bv_settings_active_component'] ) |
| 43 |
|| version_compare( $version, $GLOBALS['bv_settings_active_component']['version'], '>' ) |
| 44 |
) { |
| 45 |
$GLOBALS['bv_settings_active_component'] = $component; |
| 46 |
} |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
if ( ! function_exists( 'bv_settings_get_active_component' ) ) { |
| 51 |
/** |
| 52 |
* Get the active BV Settings component implementation. |
| 53 |
* |
| 54 |
* @since 1.1.0 |
| 55 |
* @return array|null |
| 56 |
*/ |
| 57 |
function bv_settings_get_active_component() { |
| 58 |
if ( isset( $GLOBALS['bv_settings_active_component'] ) ) { |
| 59 |
return $GLOBALS['bv_settings_active_component']; |
| 60 |
} |
| 61 |
|
| 62 |
return null; |
| 63 |
} |
| 64 |
} |
| 65 |
|
| 66 |
if ( ! class_exists( 'BV_Settings' ) ) { |
| 67 |
require_once dirname( __FILE__ ) . '/includes/class-bv-settings.php'; |
| 68 |
} |
| 69 |
|
| 70 |
bv_settings_register_component( |
| 71 |
'1.1.1', |
| 72 |
dirname( __FILE__ ), |
| 73 |
plugin_dir_url( __FILE__ ), |
| 74 |
trailingslashit( dirname( __FILE__ ) ) . 'includes/class-bv-settings-implementation.php', |
| 75 |
'BV_Settings_V1_1_0' |
| 76 |
); |
| 77 |
|