yit_get_prop

The YITH WooCommerce Wishlist yit get prop function.

Description

yit_get_prop( $object, $key, (constant) $single = true, (string) $context = 'view' ); 

Parameters (4)

0. $object
The object.
1. $key
The key.
2. $single — Optional. (constant) => true
The single.
3. $context — Optional. (string) => 'view'
The context.

Usage

  1. if ( !function_exists( 'yit_get_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 single. 
  11. $single = true; 
  12.  
  13. // The context. 
  14. $context = 'view'; 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = yit_get_prop($object, $key, $single, $context); 
  18.  

Defined (1)

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

/plugin-fw/yit-woocommerce-compatibility.php  
  1. function yit_get_prop( $object, $key, $single = true, $context = 'view' ) { 
  2.  
  3. $is_wc_data = $object instanceof WC_Data; 
  4.  
  5. if ( $is_wc_data ) { 
  6. $key = ( array_key_exists( $key, $prop_map ) ) ? $prop_map[ $key ] : $key; 
  7.  
  8. if ( ( $getter = "get{$key}" ) && method_exists( $object, $getter ) ) { 
  9. return $object->$getter( $context ); 
  10. } elseif ( ( $getter = "get_{$key}" ) && method_exists( $object, $getter ) ) { 
  11. return $object->$getter( $context ); 
  12. } else { 
  13. return $object->get_meta( $key, $single ); 
  14. } else { 
  15. $key = ( in_array( $key, $prop_map ) ) ? array_search( $key, $prop_map ) : $key; 
  16.  
  17. if ( isset( $object->$key ) ) { 
  18. return $object->$key; 
  19. } elseif ( yit_wc_check_post_columns( $key ) ) { 
  20. return $object->post->$key; 
  21. } else { 
  22. $getter = 'get_user_meta'; 
  23. !$object instanceof WC_Customer && $getter = 'get_post_meta'; 
  24.  
  25. $object_id = is_callable( array( $object, 'get_id' ) ) ? $object->get_id() : $object->id; 
  26.  
  27. return $getter( $object_id, $key, true );