PluginProbe
The WP Remote WordPress Plugin / 5.47
The WP Remote WordPress Plugin v5.47
6.72 6.69 6.65 6.62 6.48 6.47 4.87 4.97 5.05 5.09 5.16 5.22 5.24 5.25 5.38 5.41 5.42 5.45 5.47 5.53 5.56 5.65 5.68 5.72 5.73 All 53 releases
wpremote / helper.php

helper.php in The WP Remote WordPress Plugin 5.47, at helper.php

53 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH') && !defined('MCDATAPATH')) exit;
3
4 if (!class_exists('WPRHelper')) :
5 class WPRHelper {
6 public static function safePregMatch($pattern, $subject, &$matches = null, $flags = 0, $offset = 0) {
7 if (!is_string($pattern) || !is_string($subject)) {
8 return false;
9 }
10 return preg_match($pattern, $subject, $matches, $flags, $offset);
11 }
12
13 # XNOTE - The below function assumes valid input
14 # $array should be an array and $keys should be an array of string, or integer data
15 public static function filterArray($array, $keys) {
16 $filteredArray = array();
17 foreach ($keys as $key) {
18 if (array_key_exists($key, $array)) {
19 $filteredArray[$key] = $array[$key];
20 }
21 }
22 return $filteredArray;
23 }
24
25 # XNOTE - The below function assumes valid input
26 # $array should be an array and $keys should be an array of string, or integer data
27 public static function digArray($array, $keys) {
28 if (empty($keys)) {
29 return null;
30 }
31 $curr_array = $array;
32 foreach ($keys as $key) {
33 if (is_array($curr_array) && array_key_exists($key, $curr_array)) {
34 $curr_array = $curr_array[$key];
35 } else {
36 return null;
37 }
38 }
39 return $curr_array;
40 }
41
42 public static function arrayKeyFirst($array) {
43 if (!function_exists('array_key_first')) {
44 foreach ($array as $key => $value) {
45 return $key;
46 }
47 return null;
48 }
49
50 return array_key_first($array);
51 }
52 }
53 endif;