-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcompat.php
93 lines (76 loc) · 2.33 KB
/
compat.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
/**
* Compatibility functions for older version of PHP and/or WordPress.
* @package now-reading
*/
if ( !class_exists('WP_Error') ) {
class WP_Error {
var $errors = array();
function WP_Error($code = '', $message = '') {
if ( ! empty($code) )
$this->errors[$code][] = $message;
}
function get_error_codes() {
if ( empty($this->errors) )
return array();
return array_keys($this->errors);
}
function get_error_code() {
$codes = $this->get_error_codes();
if ( empty($codes) )
return '';
return $codes[0];
}
function get_error_messages($code = '') {
// Return all messages if no code specified.
if ( empty($code) ) {
$all_messages = array();
foreach ( (array) $this->errors as $code => $messages )
$all_messages = array_merge($all_messages, $messages);
return $all_messages;
}
if ( isset($this->errors[$code]) )
return $this->errors[$code];
else
return array();
}
function get_error_message($code = '') {
if ( empty($code) )
$code = $this->get_error_code();
$messages = $this->get_error_messages($code);
if ( empty($messages) )
return '';
return $messages[0];
}
function add($code, $message) {
$this->errors[$code][] = $message;
}
}
function is_wp_error($thing) {
return ( is_object($thing) && is_a($thing, 'WP_Error') );
}
}
if ( !function_exists('wp_get_referer') ) {
function wp_get_referer() {
return '';
}
}
if ( !function_exists('nr_reset_vars') ) {
function nr_reset_vars($vars) {
for ($i=0; $i<count($vars); $i += 1) {
$var = $vars[$i];
global $$var;
if (!isset($$var)) {
if (empty($_POST["$var"])) {
if (empty($_GET["$var"]))
$$var = '';
else
$$var = $_GET["$var"];
} else {
$$var = $_POST["$var"];
}
}
}
}
}
?>