| 1 |
<?php |
| 2 |
/** |
| 3 |
* Merchant_Option Class. |
| 4 |
*/ |
| 5 |
|
| 6 |
if ( ! defined( 'ABSPATH' ) ) { |
| 7 |
exit; // Exit if accessed directly |
| 8 |
} |
| 9 |
|
| 10 |
if ( ! class_exists( 'Merchant_Option' ) ) { |
| 11 |
|
| 12 |
class Merchant_Option { |
| 13 |
|
| 14 |
/** |
| 15 |
* Option name |
| 16 |
*/ |
| 17 |
public static $option = 'merchant'; |
| 18 |
|
| 19 |
/** |
| 20 |
* The single class instance. |
| 21 |
*/ |
| 22 |
private static $instance = null; |
| 23 |
|
| 24 |
/** |
| 25 |
* Instance. |
| 26 |
*/ |
| 27 |
public static function instance() { |
| 28 |
if ( is_null( self::$instance ) ) { |
| 29 |
self::$instance = new self(); |
| 30 |
} |
| 31 |
return self::$instance; |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Constructor. |
| 36 |
*/ |
| 37 |
public function __construct() {} |
| 38 |
|
| 39 |
/** |
| 40 |
* Get option. |
| 41 |
*/ |
| 42 |
public static function get( $module, $setting, $default_val = null ) { |
| 43 |
|
| 44 |
$options = get_option( 'merchant', array() ); |
| 45 |
|
| 46 |
$value = $default_val; |
| 47 |
|
| 48 |
if ( isset( $options[ $module ] ) && isset( $options[ $module ][ $setting ] ) ) { |
| 49 |
$value = $options[ $module ][ $setting ]; |
| 50 |
} |
| 51 |
|
| 52 |
return $value; |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
} |
| 57 |
|