-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
89 lines (77 loc) · 3.61 KB
/
functions.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
<?php
if ( ! defined( 'ABSPATH' ) ) {
return;
}
/**
* Retrieve Ghost metadata for the specified object.
*
* @param int $object_id ID of the object metadata is for
* @param string $meta_key Optional. Metadata key. If not specified, retrieve all metadata for
* the specified object.
* @param bool $single Optional, default is false.
* If true, return only the first value of the specified meta_key.
* This parameter has no effect if meta_key is not specified.
*
* @return mixed Single metadata value, or array of values
*
* @see get_metadata()
*/
function get_ghost_meta( $object_id, $meta_key = '', $single = false ) {
return get_metadata( 'ghost', $object_id, $meta_key, $single );
}
/**
* Add Ghost metadata for the specified object.
*
* @param int $object_id ID of the object metadata is for
* @param string $meta_key Metadata key
* @param mixed $meta_value Metadata value. Must be serializable if non-scalar.
* @param bool $unique Optional, default is false.
* Whether the specified metadata key should be unique for the object.
* If true, and the object already has a value for the specified metadata key,
* no change will be made.
*
* @return int|false The meta ID on success, false on failure.
*
* @see add_metadata()
*/
function add_ghost_meta( $object_id, $meta_key, $meta_value, $unique = false ) {
return add_metadata( 'ghost', $object_id, $meta_key, $meta_value, $unique );
}
/**
* Update Ghost metadata for the specified object. If no value already exists for the specified object
* ID and metadata key, the metadata will be added.
*
* @param int $object_id ID of the object metadata is for
* @param string $meta_key Metadata key
* @param mixed $meta_value Metadata value. Must be serializable if non-scalar.
* @param mixed $prev_value Optional. If specified, only update existing metadata entries with
* the specified value. Otherwise, update all entries.
*
* @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure.
*
* @see update_metadata()
*/
function update_ghost_meta( $object_id, $meta_key, $meta_value, $prev_value = '' ) {
return update_metadata( 'ghost', $object_id, $meta_key, $meta_value, $prev_value );
}
/**
* Delete Ghost metadata for the specified object.
*
* @param int $object_id ID of the object metadata is for
* @param string $meta_key Metadata key
* @param mixed $meta_value Optional. Metadata value. Must be serializable if non-scalar. If specified, only delete
* metadata entries with this value. Otherwise, delete all entries with the specified
* meta_key. Pass `null, `false`, or an empty string to skip this check. (For backward
* compatibility, it is not possible to pass an empty string to delete those entries with an
* empty string for a value.)
* @param bool $delete_all Optional, default is false. If true, delete matching metadata entries for all objects,
* ignoring the specified object_id. Otherwise, only delete matching metadata entries for
* the specified object_id.
*
* @return bool True on successful delete, false on failure.
*
* @see delete_metadata()
*/
function delete_ghost_meta( $object_id, $meta_key, $meta_value = '', $delete_all = false ) {
return delete_metadata( 'ghost', $object_id, $meta_key, $meta_value, $delete_all );
}