Merge pull request #4555 from claudiosmweb/added_placeholder_for_category_reports

Fixed untranslatable string in reports by category
This commit is contained in:
Mike Jolley 2014-01-21 15:39:06 -08:00
commit 8f11a4440d
1 changed files with 37 additions and 34 deletions

View File

@ -10,10 +10,11 @@ class WC_Report_Sales_By_Category extends WC_Admin_Report {
* Constructor * Constructor
*/ */
public function __construct() { public function __construct() {
if ( isset( $_GET['show_categories'] ) && is_array( $_GET['show_categories'] ) ) if ( isset( $_GET['show_categories'] ) && is_array( $_GET['show_categories'] ) ) {
$this->show_categories = array_map( 'absint', $_GET['show_categories'] ); $this->show_categories = array_map( 'absint', $_GET['show_categories'] );
elseif ( isset( $_GET['show_categories'] ) ) } elseif ( isset( $_GET['show_categories'] ) ) {
$this->show_categories = array( absint( $_GET['show_categories'] ) ); $this->show_categories = array( absint( $_GET['show_categories'] ) );
}
} }
/** /**
@ -21,13 +22,14 @@ class WC_Report_Sales_By_Category extends WC_Admin_Report {
* @return array * @return array
*/ */
public function get_chart_legend() { public function get_chart_legend() {
if ( ! $this->show_categories ) if ( ! $this->show_categories ) {
return array(); return array();
}
$legend = array(); $legend = array();
$index = 0; $index = 0;
foreach( $this->show_categories as $category ) { foreach ( $this->show_categories as $category ) {
$category = get_term( $category, 'product_cat' ); $category = get_term( $category, 'product_cat' );
$term_ids = get_term_children( $category->term_id, 'product_cat' ); $term_ids = get_term_children( $category->term_id, 'product_cat' );
$term_ids[] = $category->term_id; $term_ids[] = $category->term_id;
@ -72,8 +74,9 @@ class WC_Report_Sales_By_Category extends WC_Admin_Report {
$current_range = ! empty( $_GET['range'] ) ? $_GET['range'] : '7day'; $current_range = ! empty( $_GET['range'] ) ? $_GET['range'] : '7day';
if ( ! in_array( $current_range, array( 'custom', 'year', 'last_month', 'month', '7day' ) ) ) if ( ! in_array( $current_range, array( 'custom', 'year', 'last_month', 'month', '7day' ) ) ) {
$current_range = '7day'; $current_range = '7day';
}
$this->calculate_current_range( $current_range ); $this->calculate_current_range( $current_range );
@ -125,7 +128,7 @@ class WC_Report_Sales_By_Category extends WC_Admin_Report {
} }
} }
include( WC()->plugin_path() . '/includes/admin/views/html-report-by-date.php'); include( WC()->plugin_path() . '/includes/admin/views/html-report-by-date.php' );
} }
/** /**
@ -150,7 +153,7 @@ class WC_Report_Sales_By_Category extends WC_Admin_Report {
?> ?>
<form method="GET"> <form method="GET">
<div> <div>
<select multiple="multiple" class="chosen_select" id="show_categories" name="show_categories[]" style="width: 205px;"> <select multiple="multiple" data-placeholder="<?php _e( 'Select categories&hellip;', 'woocommerce' ); ?>" class="chosen_select" id="show_categories" name="show_categories[]" style="width: 205px;">
<?php <?php
$r = array(); $r = array();
$r['pad_counts'] = 1; $r['pad_counts'] = 1;
@ -325,41 +328,41 @@ class WC_Report_Sales_By_Category extends WC_Admin_Report {
legend: { legend: {
show: false show: false
}, },
grid: { grid: {
color: '#aaa', color: '#aaa',
borderColor: 'transparent', borderColor: 'transparent',
borderWidth: 0, borderWidth: 0,
hoverable: true hoverable: true
}, },
xaxes: [ { xaxes: [ {
color: '#aaa', color: '#aaa',
reserveSpace: true, reserveSpace: true,
position: "bottom", position: "bottom",
tickColor: 'transparent', tickColor: 'transparent',
mode: "time", mode: "time",
timeformat: "<?php if ( $this->chart_groupby == 'day' ) echo '%d %b'; else echo '%b'; ?>", timeformat: "<?php if ( $this->chart_groupby == 'day' ) echo '%d %b'; else echo '%b'; ?>",
monthNames: <?php echo json_encode( array_values( $wp_locale->month_abbrev ) ) ?>, monthNames: <?php echo json_encode( array_values( $wp_locale->month_abbrev ) ); ?>,
tickLength: 1, tickLength: 1,
minTickSize: [1, "<?php echo $this->chart_groupby; ?>"], minTickSize: [1, "<?php echo $this->chart_groupby; ?>"],
tickSize: [1, "<?php echo $this->chart_groupby; ?>"], tickSize: [1, "<?php echo $this->chart_groupby; ?>"],
font: { font: {
color: "#aaa" color: "#aaa"
} }
} ], } ],
yaxes: [ yaxes: [
{ {
min: 0, min: 0,
tickDecimals: 2, tickDecimals: 2,
color: 'transparent', color: 'transparent',
font: { color: "#aaa" } font: { color: "#aaa" }
} }
], ],
} }
); );
jQuery('.chart-placeholder').resize(); jQuery('.chart-placeholder').resize();
} }
drawGraph(); drawGraph();
@ -376,4 +379,4 @@ class WC_Report_Sales_By_Category extends WC_Admin_Report {
<?php <?php
} }
} }
} }