WC_Admin_Dashboard::sales_sparkline_markup()
Prepares the markup for a sparkline to show sales in the last X days with the given data.
Method of the class: WC_Admin_Dashboard{}
No Hooks.
Return
String
.
Usage
// private - for code of main (parent) class only $result = $this->sales_sparkline_markup( $type, $days, $total, $sparkline_data );
- $type(string) (required)
- Type of sparkline to form the markup.
- $days(int) (required)
- Days of stats to form the markup.
- $total(int) (required)
- Total income or items sold to form the markup.
- $sparkline_data(array) (required)
- Sparkline data to form the markup.
WC_Admin_Dashboard::sales_sparkline_markup() WC Admin Dashboard::sales sparkline markup code WC 9.5.1
private function sales_sparkline_markup( $type, $days, $total, $sparkline_data ) { if ( 'sales' === $type ) { /* translators: 1: total income 2: days */ $tooltip = sprintf( __( 'Sold %1$s worth in the last %2$d days', 'woocommerce' ), strip_tags( wc_price( $total ) ), $days ); } else { /* translators: 1: total items sold 2: days */ $tooltip = sprintf( _n( 'Sold %1$d item in the last %2$d days', 'Sold %1$d items in the last %2$d days', $total, 'woocommerce' ), $total, $days ); } return '<span class="wc_sparkline ' . ( ( 'sales' === $type ) ? 'lines' : 'bars' ) . ' tips" data-color="#777" data-tip="' . esc_attr( $tooltip ) . '" data-barwidth="' . 60 * 60 * 16 * 1000 . '" data-sparkline="' . wc_esc_json( wp_json_encode( $sparkline_data ) ) . '"></span>'; }