From 177592661cb897aaf9ed2e4cd545d017265e8b24 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Fri, 24 Aug 2012 18:22:21 +0100 Subject: [PATCH] cleanup #1418 --- classes/class-wc-order.php | 62 ++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 32 deletions(-) diff --git a/classes/class-wc-order.php b/classes/class-wc-order.php index 077c7d72f31..62cc922e4f2 100644 --- a/classes/class-wc-order.php +++ b/classes/class-wc-order.php @@ -1452,60 +1452,58 @@ class WC_Order_Item_Meta { * @access public * @param bool $flat (default: false) * @param bool $return (default: false) - * @param string $hideprefix (default: blank) + * @param string $hideprefix (default: _) * @return void */ - function display( $flat = false, $return = false, $hideprefix = '' ) { + function display( $flat = false, $return = false, $hideprefix = '_' ) { global $woocommerce; - if ( $this->meta && is_array( $this->meta ) ) : - - if ( ! $flat ) $output = '
'; else $output = ''; + if ( $this->meta && is_array( $this->meta ) ) { + + $output = $flat ? '' : '
'; $meta_list = array(); - foreach ( $this->meta as $meta ) : - if ( !empty( $hideprefix) ) { - if ( substr( $meta['meta_name'], 0, 1 ) <> $hideprefix ) { - $name = $meta['meta_name']; - $value = $meta['meta_value']; - } else continue; + foreach ( $this->meta as $meta ) { + + if ( ! empty( $hideprefix ) && substr( $meta['meta_name'], 0, 1 ) == $hideprefix ) { + // Skip + continue; } else { $name = $meta['meta_name']; $value = $meta['meta_value']; } - if ( ! $value ) continue; + if ( ! $value ) + continue; // If this is a term slug, get the term's nice name - if ( taxonomy_exists( esc_attr( str_replace( 'attribute_', '', $name ) ) ) ) : - $term = get_term_by('slug', $value, esc_attr(str_replace('attribute_', '', $name))); - if (!is_wp_error($term) && $term->name) : + if ( taxonomy_exists( esc_attr( str_replace( 'attribute_', '', $name ) ) ) ) { + $term = get_term_by('slug', $value, esc_attr( str_replace( 'attribute_', '', $name ) ) ); + if ( ! is_wp_error( $term ) && $term->name ) $value = $term->name; - endif; - else : + } else { $value = ucfirst($value); - endif; + } - if ($flat) : - $meta_list[] = $woocommerce->attribute_label(str_replace('attribute_', '', $name)).': '.$value; - else : - $meta_list[] = '
'.$woocommerce->attribute_label(str_replace('attribute_', '', $name)).':
'.$value.'
'; - endif; + if ( $flat ) + $meta_list[] = $woocommerce->attribute_label( str_replace( 'attribute_', '', $name ) ) . ': ' . $value; + else + $meta_list[] = '
' . $woocommerce->attribute_label( str_replace( 'attribute_', '', $name ) ) . ':
' . $value . '
'; - endforeach; + } - if ($flat) : - $output .= implode(", \n", $meta_list); - else : - $output .= implode('', $meta_list); - endif; + if ( $flat ) + $output .= implode( ", \n", $meta_list ); + else + $output .= implode( '', $meta_list ); - if (!$flat) $output .= '
'; + if ( ! $flat ) + $output .= '
'; - if ($return) return $output; else echo $output; + if ( $return ) return $output; else echo $output; - endif; + } } }