WC_Admin_Dashboard::status_widget_content │ public │ WC 1.0
Generate the actual status widget content. This contains the original content of the status_widget() method.
Method of the class: WC_Admin_Dashboard{}
Returns
null. Nothing (null).
Usage
$WC_Admin_Dashboard = new WC_Admin_Dashboard();
$WC_Admin_Dashboard->status_widget_content();
WC_Admin_Dashboard::status_widget_content() WC Admin Dashboard::status widget content code
WC 10.3.3
<?php
public function status_widget_content() {
//phpcs:ignore
$is_wc_admin_disabled = apply_filters( 'woocommerce_admin_disabled', false ) || ! Features::is_enabled( 'analytics' );
$status_widget_reports = array(
'net_sales_link' => 'admin.php?page=wc-admin&path=%2Fanalytics%2Frevenue&chart=net_revenue&orderby=net_revenue&period=month&compare=previous_period',
'top_seller_link' => 'admin.php?page=wc-admin&filter=single_product&path=%2Fanalytics%2Fproducts&products=',
'lowstock_link' => 'admin.php?page=wc-admin&type=lowstock&path=%2Fanalytics%2Fstock',
'outofstock_link' => 'admin.php?page=wc-admin&type=outofstock&path=%2Fanalytics%2Fstock',
'report_data' => null,
'get_sales_sparkline' => array( $this, 'get_sales_sparkline' ),
);
if ( $is_wc_admin_disabled ) {
/**
* Filter to change the reports of the status widget on the Dashboard page.
*
* Please note that this filter is mainly for backward compatibility with the legacy reports.
* It's not recommended to use this filter to change the data of this widget.
*
* @since 9.5.0
*/
$status_widget_reports = apply_filters( 'woocommerce_dashboard_status_widget_reports', $status_widget_reports );
} else {
$status_widget_reports['report_data'] = $this->get_wc_admin_performance_data();
}
echo '<ul class="wc_status_list">';
if ( current_user_can( 'view_woocommerce_reports' ) ) {
$report_data = $status_widget_reports['report_data'];
$get_sales_sparkline = $status_widget_reports['get_sales_sparkline'];
$net_sales_link = $status_widget_reports['net_sales_link'];
$top_seller_link = $status_widget_reports['top_seller_link'];
$days = max( 7, (int) gmdate( 'd', current_time( 'timestamp' ) ) ); // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested
$sparkline_allowed_html = array(
'span' => array(
'class' => array(),
'data-color' => array(),
'data-tip' => array(),
'data-barwidth' => array(),
'data-sparkline' => array(),
),
);
if ( $report_data && is_callable( $get_sales_sparkline ) ) {
$sparkline = call_user_func_array( $get_sales_sparkline, array( '', $days ) );
$sparkline = $this->sales_sparkline_markup( 'sales', $days, $sparkline['total'], $sparkline['data'] );
?>
<li class="sales-this-month">
<a href="<?php echo esc_url( admin_url( $net_sales_link ) ); ?>">
<?php echo wp_kses( $sparkline, $sparkline_allowed_html ); ?>
<?php
printf(
/* translators: %s: net sales */
esc_html__( '%s net sales this month', 'woocommerce' ),
'<strong>' . wc_price( $report_data->net_sales ) . '</strong>'
); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
?>
</a>
</li>
<?php
}
$top_seller = $this->get_top_seller();
if ( $top_seller && $top_seller->qty && is_callable( $get_sales_sparkline ) ) {
$sparkline = call_user_func_array( $get_sales_sparkline, array( $top_seller->product_id, $days, 'count' ) );
$sparkline = $this->sales_sparkline_markup( 'count', $days, $sparkline['total'], $sparkline['data'] );
?>
<li class="best-seller-this-month">
<a href="<?php echo esc_url( admin_url( $top_seller_link . $top_seller->product_id ) ); ?>">
<?php echo wp_kses( $sparkline, $sparkline_allowed_html ); ?>
<?php
printf(
/* translators: 1: top seller product title 2: top seller quantity */
esc_html__( '%1$s top seller this month (sold %2$d)', 'woocommerce' ),
'<strong>' . get_the_title( $top_seller->product_id ) . '</strong>',
$top_seller->qty
); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
?>
</a>
</li>
<?php
}
}
$this->status_widget_order_rows();
if ( get_option( 'woocommerce_manage_stock' ) === 'yes' ) {
$this->status_widget_stock_rows( $status_widget_reports['lowstock_link'], $status_widget_reports['outofstock_link'] );
}
/**
* Filter to change the first argument passed to the `woocommerce_after_dashboard_status_widget` action.
*
* Please note that this filter is mainly for backward compatibility with the legacy reports.
* It's not recommended to use this filter as it will soon be deprecated along with the retiring of the legacy reports.
*
* @since 9.5.0
*/
$reports = apply_filters( 'woocommerce_after_dashboard_status_widget_parameter', null );
do_action( 'woocommerce_after_dashboard_status_widget', $reports );
echo '</ul>';
}