PluginProbe ʕ •ᴥ•ʔ
Meta Box / 4.18.0
Meta Box v4.18.0
trunk 4.1.10 4.1.11 4.10 4.10.1 4.10.2 4.10.3 4.10.4 4.11 4.11.1 4.11.2 4.12.1 4.12.4 4.12.5 4.12.6 4.13.0 4.13.1 4.13.2 4.13.3 4.13.4 4.14.0 4.14.1 4.14.10 4.14.11 4.14.2 4.14.4 4.14.5 4.14.6 4.14.7 4.14.8 4.14.9 4.15.0 4.15.1 4.15.2 4.15.3 4.15.4 4.15.5 4.15.6 4.15.7 4.15.8 4.15.9 4.16.0 4.16.1 4.16.2 4.16.3 4.17.0 4.17.1 4.17.2 4.17.3 4.18.0 4.18.1 4.18.2 4.18.3 4.18.4 4.2 4.2.1 4.2.2 4.2.3 4.2.4 4.3 4.3.1 4.3.10 4.3.11 4.3.2 4.3.3 4.3.4 4.3.5 4.3.6 4.3.7 4.3.8 4.3.9 4.4.0 4.4.1 4.4.3 4.5 4.5.1 4.5.2 4.5.3 4.5.4 4.5.5 4.5.6 4.5.7 4.6 4.7 4.7.1 4.7.2 4.7.3 4.8.0 4.8.1 4.8.2 4.8.3 4.8.4 4.8.5 4.8.6 4.8.7 4.9 4.9.1 4.9.2 4.9.3 4.9.4 4.9.5 4.9.6 4.9.7 4.9.8 5.0.0 5.0.1 5.1.0 5.1.1 5.1.2 5.10.0 5.10.1 5.10.10 5.10.11 5.10.12 5.10.13 5.10.14 5.10.15 5.10.16 5.10.17 5.10.18 5.10.19 5.10.2 5.10.3 5.10.4 5.10.5 5.10.6 5.10.7 5.10.8 5.10.9 5.11.0 5.11.1 5.11.2 5.11.3 5.11.4 5.12.0 5.2.0 5.2.1 5.2.10 5.2.2 5.2.3 5.2.4 5.2.5 5.2.6 5.2.7 5.2.8 5.2.9 5.3.0 5.3.1 5.3.10 5.3.2 5.3.3 5.3.4 5.3.5 5.3.6 5.3.7 5.3.8 5.3.9 5.4.0 5.4.1 5.4.2 5.4.3 5.4.4 5.4.5 5.4.6 5.4.7 5.4.8 5.5.0 5.5.1 5.6.0 5.6.1 5.6.10 5.6.11 5.6.12 5.6.13 5.6.14 5.6.15 5.6.16 5.6.17 5.6.18 5.6.2 5.6.3 5.6.4 5.6.5 5.6.6 5.6.7 5.6.8 5.6.9 5.7.0 5.7.1 5.7.2 5.7.3 5.7.4 5.7.5 5.8.0 5.8.1 5.8.2 5.9.0 5.9.1 5.9.10 5.9.11 5.9.2 5.9.3 5.9.4 5.9.5 5.9.6 5.9.7 5.9.8 5.9.9
meta-box / inc / storages / base.php
meta-box / inc / storages Last commit date
base.php 7 years ago post.php 8 years ago
base.php
99 lines
1 <?php
2 /**
3 * Base storage
4 *
5 * @package Meta Box
6 */
7
8 /**
9 * Class RWMB_Base_Storage
10 */
11 class RWMB_Base_Storage implements RWMB_Storage_Interface {
12
13 /**
14 * Object type.
15 *
16 * @var string
17 */
18 protected $object_type;
19
20 /**
21 * Retrieve metadata for the specified object.
22 *
23 * @param int $object_id ID of the object metadata is for.
24 * @param string $meta_key Optional. Metadata key. If not specified, retrieve all metadata for
25 * the specified object.
26 * @param bool|array $args Optional, default is false.
27 * If true, return only the first value of the specified meta_key.
28 * If is array, use the `single` element.
29 * This parameter has no effect if meta_key is not specified.
30 * @return mixed Single metadata value, or array of values.
31 *
32 * @see get_metadata()
33 */
34 public function get( $object_id, $meta_key, $args = false ) {
35 if ( is_array( $args ) ) {
36 $single = ! empty( $args['single'] );
37 } else {
38 $single = (bool) $args;
39 }
40
41 return get_metadata( $this->object_type, $object_id, $meta_key, $single );
42 }
43
44 /**
45 * Add metadata
46 *
47 * @param int $object_id ID of the object metadata is for.
48 * @param string $meta_key Metadata key.
49 * @param mixed $meta_value Metadata value. Must be serializable if non-scalar.
50 * @param bool $unique Optional, default is false.
51 * Whether the specified metadata key should be unique for the object.
52 * If true, and the object already has a value for the specified metadata key,
53 * no change will be made.
54 * @return int|false The meta ID on success, false on failure.
55 *
56 * @see add_metadata()
57 */
58 public function add( $object_id, $meta_key, $meta_value, $unique = false ) {
59 return add_metadata( $this->object_type, $object_id, $meta_key, $meta_value, $unique );
60 }
61
62 /**
63 * Update metadata.
64 *
65 * @param int $object_id ID of the object metadata is for.
66 * @param string $meta_key Metadata key.
67 * @param mixed $meta_value Metadata value. Must be serializable if non-scalar.
68 * @param mixed $prev_value Optional. If specified, only update existing metadata entries with
69 * the specified value. Otherwise, update all entries.
70 * @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure.
71 *
72 * @see update_metadata()
73 */
74 public function update( $object_id, $meta_key, $meta_value, $prev_value = '' ) {
75 return update_metadata( $this->object_type, $object_id, $meta_key, $meta_value, $prev_value );
76 }
77
78 /**
79 * Delete metadata.
80 *
81 * @param int $object_id ID of the object metadata is for.
82 * @param string $meta_key Metadata key.
83 * @param mixed $meta_value Optional. Metadata value. Must be serializable if non-scalar. If specified, only delete
84 * metadata entries with this value. Otherwise, delete all entries with the specified meta_key.
85 * Pass `null, `false`, or an empty string to skip this check. (For backward compatibility,
86 * it is not possible to pass an empty string to delete those entries with an empty string
87 * for a value).
88 * @param bool $delete_all Optional, default is false. If true, delete matching metadata entries for all objects,
89 * ignoring the specified object_id. Otherwise, only delete matching metadata entries for
90 * the specified object_id.
91 * @return bool True on successful delete, false on failure.
92 *
93 * @see delete_metadata()
94 */
95 public function delete( $object_id, $meta_key, $meta_value = '', $delete_all = false ) {
96 return delete_metadata( $this->object_type, $object_id, $meta_key, $meta_value, $delete_all );
97 }
98 }
99