yit_delete_prop

The YITH WooCommerce Wishlist yit delete prop function.

Description

yit_delete_prop( $object, $key, (string) $value = '' ); 

Parameters (3)

0. $object
The object.
1. $key
The key.
2. $value — Optional. (string) => ''
The value.

Usage

  1. if ( !function_exists( 'yit_delete_prop' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'yith-woocommerce-wishlist/plugin-fw/yit-woocommerce-compatibility.php'; 
  3.  
  4. // The object. 
  5. $object = null; 
  6.  
  7. // The key. 
  8. $key = null; 
  9.  
  10. // The value. 
  11. $value = ''; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = yit_delete_prop($object, $key, $value); 
  15.  

Defined (1)

The function is defined in the following location(s).

/plugin-fw/yit-woocommerce-compatibility.php  
  1. function yit_delete_prop( $object, $key, $value = '' ) { 
  2. $is_wc_data = $object instanceof WC_Data; 
  3.  
  4. if ( $is_wc_data ) { 
  5. $key = ( array_key_exists( $key, $prop_map ) ) ? $prop_map[ $key ] : $key; 
  6.  
  7. if ( ( $setter = "set{$key}" ) && ( $getter = "get{$key}" ) && method_exists( $object, $setter ) && ( !$value || $object->$getter == $value ) ) { 
  8. $object->$setter( '' ); 
  9. } elseif ( ( $setter = "set_{$key}" ) && ( $getter = "get_{$key}" ) && method_exists( $object, $setter ) && ( !$value || $object->$getter == $value ) ) { 
  10. $object->$setter( '' ); 
  11. } elseif ( ( !$value || $object->get_meta( $key ) == $value ) ) { 
  12. $object->delete_meta_data( $key, $value ); 
  13.  
  14. $object->save(); 
  15. } else { 
  16. if ( yit_wc_check_post_columns( $key ) && ( !$value || $object->post->$key == $value ) ) { 
  17. yit_store_changes( $object->post, $key, '' ); 
  18. } else { 
  19. $object_id = is_callable( array( $object, 'get_id' ) ) ? $object->get_id() : $object->id; 
  20.  
  21. delete_post_meta( $object_id, $key, $value );