Object
9 years ago
Subject
9 years ago
API.php
9 years ago
Cache.php
9 years ago
Compatibility.php
9 years ago
Config.php
9 years ago
ConfigPress.php
9 years ago
Console.php
9 years ago
Media.php
9 years ago
Object.php
9 years ago
Request.php
9 years ago
Subject.php
9 years ago
ConfigPress.php
65 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * ====================================================================== |
| 5 | * LICENSE: This file is subject to the terms and conditions defined in * |
| 6 | * file 'license.txt', which is part of this source code package. * |
| 7 | * ====================================================================== |
| 8 | */ |
| 9 | |
| 10 | /** |
| 11 | * ConfigPress layer |
| 12 | * |
| 13 | * @package AAM |
| 14 | * @author Vasyl Martyniuk <vasyl@vasyltech.com> |
| 15 | * @todo Deprecated - Remove in May 2017 |
| 16 | */ |
| 17 | final class AAM_Core_ConfigPress { |
| 18 | |
| 19 | /** |
| 20 | * Get ConfigPress parameter |
| 21 | * |
| 22 | * @param string $param |
| 23 | * @param mixed $default |
| 24 | * |
| 25 | * @return mixed |
| 26 | * |
| 27 | * @access public |
| 28 | * @static |
| 29 | */ |
| 30 | public static function get($param, $default = null) { |
| 31 | if (class_exists('ConfigPress')) { |
| 32 | $response = ConfigPress::get($param, $default); |
| 33 | } else { |
| 34 | $response = $default; |
| 35 | } |
| 36 | |
| 37 | return self::parseParam($response, $default); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Parse found parameter |
| 42 | * |
| 43 | * @param mixed $param |
| 44 | * @param mixed $default |
| 45 | * |
| 46 | * @return mixed |
| 47 | * |
| 48 | * @access protected |
| 49 | * @static |
| 50 | */ |
| 51 | protected static function parseParam($param, $default) { |
| 52 | if (is_array($param) && isset($param['userFunc'])) { |
| 53 | if (is_callable($param['userFunc'])) { |
| 54 | $response = call_user_func($param['userFunc']); |
| 55 | } else { |
| 56 | $response = $default; |
| 57 | } |
| 58 | } else { |
| 59 | $response = $param; |
| 60 | } |
| 61 | |
| 62 | return $response; |
| 63 | } |
| 64 | |
| 65 | } |