WC_Admin_Dashboard::status_widget()publicWC 1.0

Show status widget.

Method of the class: WC_Admin_Dashboard{}

Return

null. Nothing (null).

Usage

$WC_Admin_Dashboard = new WC_Admin_Dashboard();
$WC_Admin_Dashboard->status_widget();

WC_Admin_Dashboard::status_widget() code WC 9.3.3

<?php
public function status_widget() {
	$suffix  = Constants::is_true( 'SCRIPT_DEBUG' ) ? '' : '.min';
	$version = Constants::get_constant( 'WC_VERSION' );

	wp_enqueue_script( 'wc-status-widget', WC()->plugin_url() . '/assets/js/admin/wc-status-widget' . $suffix . '.js', array( 'jquery' ), $version, true );

	include_once dirname( __FILE__ ) . '/reports/class-wc-admin-report.php';

	//phpcs:ignore
	$is_wc_admin_disabled = apply_filters( 'woocommerce_admin_disabled', false ) || ! Features::is_enabled( 'analytics' );

	$reports = new WC_Admin_Report();

	$net_sales_link  = 'admin.php?page=wc-reports&tab=orders&range=month';
	$top_seller_link = 'admin.php?page=wc-reports&tab=orders&report=sales_by_product&range=month&product_ids=';
	$report_data     = $is_wc_admin_disabled ? $this->get_sales_report_data() : $this->get_wc_admin_performance_data();
	if ( ! $is_wc_admin_disabled ) {
		$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=';
	}

	echo '<ul class="wc_status_list">';

	if ( current_user_can( 'view_woocommerce_reports' ) ) {

		if ( $report_data ) {
			?>
		<li class="sales-this-month">
		<a href="<?php echo esc_url( admin_url( $net_sales_link ) ); ?>">
			<?php echo $this->sales_sparkline( $reports, $is_wc_admin_disabled, '' ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped ?>
			<?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 ) {
			?>
		<li class="best-seller-this-month">
		<a href="<?php echo esc_url( admin_url( $top_seller_link . $top_seller->product_id ) ); ?>">
			<?php echo $this->sales_sparkline( $reports, $is_wc_admin_disabled, $top_seller->product_id, 'count' ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped ?>
			<?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( $is_wc_admin_disabled );
	}

	do_action( 'woocommerce_after_dashboard_status_widget', $reports );
	echo '</ul>';
}