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