Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
LLMS_Post_Model::update_meta_properties( array $post_meta_properties, boolean $allow_same_meta_value )
Update post meta properties.
Description Description
Logic moved from set_bulk()
method.
Parameters Parameters
- $post_meta_properties
-
(array) (Required) Array of post meta properties to set.
- $allow_same_meta_value
-
(boolean) (Required) Whether or not updating a meta with the same value as stored in the db is allowed. By default
update_post_meta
doesn't allow that.
Return Return
(void|WP_Error)
Source Source
File: includes/abstracts/abstract.llms.post.model.php
1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 | private function update_meta_properties( $post_meta_properties , $allow_same_meta_value ) { if ( empty ( $post_meta_properties ) ) { return ; } $error = new WP_Error(); foreach ( $post_meta_properties as $key => $val ) { if ( $allow_same_meta_value ) { /** * Do pretty much(*) the same check for a duplicate value as in `update_metadata()` * to avoid `update_post_meta()` returning false. * {@see WP_REST_Meta_Fields::update_meta_value()}. * * If the new value to be set equals the old one don't update it. * * (*) This is not exactly the same check you can find in `update_metadata()` as that * account for multiple meta values for the same key, while we don't. */ $old_value = get_post_meta( $this ->id, $this ->meta_prefix . $key , true ); if ( $this ->is_meta_value_same_as_stored_value( $key , $old_value , $val ) ) { continue ; } } $u = update_post_meta( $this ->id, $this ->meta_prefix . $key , $val ); if ( ! ( is_numeric ( $u ) || true === $u ) ) { $error ->add( 'invalid_meta' , sprintf( __( 'Cannot insert/update the %s meta' , 'lifterlms' ), $key ) ); } } if ( $error ->has_errors() ) { return $error ; } } |
Expand full source code Collapse full source code View on GitHub