PluginProbe ʕ •ᴥ•ʔ
Gallery : FooGallery / 3.2.6
Gallery : FooGallery v3.2.6
3.3.2 3.3.3 3.3.0 3.1.31 3.1.32 3.1.34 3.1.36 3.2.0 3.2.6 trunk 1.10.3 2.0.24 2.1.34 2.2.44 2.3.3 2.4.32 3.0.6 3.1.11 3.1.12 3.1.13 3.1.20 3.1.25 3.1.26 3.1.26.1 3.1.26.2
foogallery / includes / foopluginbase / functions / arrays.php
foogallery / includes / foopluginbase / functions Last commit date
arrays.php 4 weeks ago dates.php 4 weeks ago general.php 4 weeks ago index.php 4 weeks ago screen.php 4 weeks ago strings.php 4 weeks ago
arrays.php
51 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 /*
8 * Foo Functions - Arrays
9 * A bunch of common and useful functions related to arrays
10 *
11 * Author: Brad Vincent
12 * Author URI: http://fooplugins.com
13 * License: GPL2
14 */
15
16 if ( !function_exists( 'foo_safe_get' ) ) {
17 /**
18 * safely get a value from an array
19 *
20 * @param array $array The array we want to extract info from.
21 * @param string $key The key of the item within the array.
22 * @param mixed $default The default value toi return if the value is not found in the array.
23 *
24 * @return mixed
25 */
26 function foo_safe_get($array, $key, $default = null) {
27 if ( !is_array( $array ) ) return $default;
28 $value = array_key_exists( $key, $array ) ? $array[$key] : null;
29 if ( $value === null ) {
30 return $default;
31 }
32
33 return $value;
34 }
35 }
36
37 if ( !function_exists( 'safe_get_from_request' ) ) {
38
39 /**
40 * Safely get a value from the global $_REQUEST array
41 *
42 * @param string $key The key of the item within the array.
43 * @param mixed $default The default value toi return if the value is not found in the array.
44 *
45 * @return mixed
46 */
47 function safe_get_from_request($key, $default = null) {
48 return foo_safe_get( $_REQUEST, $key, $default );
49 }
50 }
51