YITH_Woocompare_Helper

YITH Woocommerce Compare helper.

Defined (1)

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

/includes/class.yith-woocompare-helper.php  
  1. class YITH_Woocompare_Helper { 
  2.  
  3. /** 
  4. * Set the image size used in the comparison table 
  5. * @since 1.0.0 
  6. */ 
  7. public static function set_image_size() { 
  8. $size = get_option( 'yith_woocompare_image_size' ); 
  9.  
  10. if( ! $size ) { 
  11. return; 
  12.  
  13. $size['crop'] = isset( $size['crop'] ) ? true : false; 
  14. add_image_size( 'yith-woocompare-image', $size['width'], $size['height'], $size['crop'] ); 
  15.  
  16. /** 
  17. * The list of standard fields 
  18. * @since 1.0.0 
  19. * @access public 
  20. */ 
  21. public static function standard_fields( $with_attr = true ) { 
  22.  
  23. $fields = array( 
  24. 'image' => __( 'Image', 'yith-woocommerce-compare' ),  
  25. 'title' => __( 'Title', 'yith-woocommerce-compare' ),  
  26. 'price' => __( 'Price', 'yith-woocommerce-compare' ),  
  27. 'add-to-cart' => __( 'Add to cart', 'yith-woocommerce-compare' ),  
  28. 'description' => __( 'Description', 'yith-woocommerce-compare' ),  
  29. 'stock' => __( 'Availability', 'yith-woocommerce-compare' ),  
  30. 'weight' => __( 'Weight', 'yith-woocommerce-compare' ),  
  31. 'dimensions' => __( 'Dimensions', 'yith-woocommerce-compare' ) 
  32. ); 
  33.  
  34. if( $with_attr ) 
  35. $fields = array_merge( $fields, YITH_Woocompare_Helper::attribute_taxonomies() ); 
  36.  
  37. return $fields; 
  38.  
  39. /** 
  40. * Get Woocommerce Attribute Taxonomies 
  41. * @since 1.0.0 
  42. * @access public 
  43. */ 
  44. public static function attribute_taxonomies() { 
  45. global $woocommerce; 
  46.  
  47. if ( ! isset( $woocommerce ) ) return array(); 
  48.  
  49. $attributes = array(); 
  50.  
  51. if( function_exists( 'wc_get_attribute_taxonomies' ) && function_exists( 'wc_attribute_taxonomy_name' ) ) { 
  52. $attribute_taxonomies = wc_get_attribute_taxonomies(); 
  53. if( empty( $attribute_taxonomies ) ) 
  54. return array(); 
  55. foreach( $attribute_taxonomies as $attribute ) { 
  56. $tax = wc_attribute_taxonomy_name( $attribute->attribute_name ); 
  57. if ( taxonomy_exists( $tax ) ) { 
  58. $attributes[$tax] = ucfirst( $attribute->attribute_name ); 
  59. else{ 
  60. $attribute_taxonomies = $woocommerce->get_attribute_taxonomies(); 
  61. if( empty( $attribute_taxonomies ) ) 
  62. return array(); 
  63. foreach( $attribute_taxonomies as $attribute ) { 
  64. $tax = $woocommerce->attribute_taxonomy_name( $attribute->attribute_name ); 
  65. if ( taxonomy_exists( $tax ) ) { 
  66. $attributes[$tax] = ucfirst( $attribute->attribute_name ); 
  67.  
  68.  
  69. return $attributes; 
  70.  
  71.