|
@@ 168-183 (lines=16) @@
|
| 165 |
|
* |
| 166 |
|
* @return int|bool False for failure. True for success. |
| 167 |
|
*/ |
| 168 |
|
public function add_meta( $id = 0, $meta_key = '', $meta_value, $unique = false ) { |
| 169 |
|
$id = $this->sanitize_id( $id ); |
| 170 |
|
|
| 171 |
|
// Bailout. |
| 172 |
|
if ( ! $this->is_valid_post_type( $id ) ) { |
| 173 |
|
return $this->check; |
| 174 |
|
} |
| 175 |
|
|
| 176 |
|
$meta_id = add_metadata( $this->meta_type, $id, $meta_key, $meta_value, $unique ); |
| 177 |
|
|
| 178 |
|
if ( $meta_id ) { |
| 179 |
|
$this->delete_cache( $id ); |
| 180 |
|
} |
| 181 |
|
|
| 182 |
|
return $meta_id; |
| 183 |
|
} |
| 184 |
|
|
| 185 |
|
/** |
| 186 |
|
* Update payment meta field based on Post Type ID. |
|
@@ 205-220 (lines=16) @@
|
| 202 |
|
* |
| 203 |
|
* @return int|bool False on failure, true if success. |
| 204 |
|
*/ |
| 205 |
|
public function update_meta( $id = 0, $meta_key = '', $meta_value, $prev_value = '' ) { |
| 206 |
|
$id = $this->sanitize_id( $id ); |
| 207 |
|
|
| 208 |
|
// Bailout. |
| 209 |
|
if ( ! $this->is_valid_post_type( $id ) ) { |
| 210 |
|
return $this->check; |
| 211 |
|
} |
| 212 |
|
|
| 213 |
|
$meta_id = update_metadata( $this->meta_type, $id, $meta_key, $meta_value, $prev_value ); |
| 214 |
|
|
| 215 |
|
if ( $meta_id ) { |
| 216 |
|
$this->delete_cache( $id ); |
| 217 |
|
} |
| 218 |
|
|
| 219 |
|
return $meta_id; |
| 220 |
|
} |
| 221 |
|
|
| 222 |
|
/** |
| 223 |
|
* Remove metadata matching criteria from a payment. |
|
@@ 239-254 (lines=16) @@
|
| 236 |
|
* |
| 237 |
|
* @return bool False for failure. True for success. |
| 238 |
|
*/ |
| 239 |
|
public function delete_meta( $id = 0, $meta_key = '', $meta_value = '', $delete_all = '' ) { |
| 240 |
|
$id = $this->sanitize_id( $id ); |
| 241 |
|
|
| 242 |
|
// Bailout. |
| 243 |
|
if ( ! $this->is_valid_post_type( $id ) ) { |
| 244 |
|
return $this->check; |
| 245 |
|
} |
| 246 |
|
|
| 247 |
|
$is_meta_deleted = delete_metadata( $this->meta_type, $id, $meta_key, $meta_value, $delete_all ); |
| 248 |
|
|
| 249 |
|
if ( $is_meta_deleted ) { |
| 250 |
|
$this->delete_cache( $id ); |
| 251 |
|
} |
| 252 |
|
|
| 253 |
|
return $is_meta_deleted; |
| 254 |
|
} |
| 255 |
|
|
| 256 |
|
/** |
| 257 |
|
* Rename query clauses of every query for new meta table |