WC_Admin_Dashboard_Setup::get_task_header │ private │ WC 1.0

Get dashboard widget header data for a task.

Method of the class: WC_Admin_Dashboard_Setup{}

No Hooks.

Returns

array.

Usage

// private - for code of main (parent) class only
$result = $this->get_task_header( $task );
$task(Task) (required)
Task.

WC_Admin_Dashboard_Setup::get_task_header() code WC 11.1.2

private function get_task_header( $task ) {
	$asset_url = WC()->plugin_url() . '/assets/';
	$task_json = $task->get_json();

	$image_url = method_exists( $task, 'get_image_url' ) ? (string) $task->get_image_url() : '';
	$image_alt = method_exists( $task, 'get_image_alt' ) ? (string) $task->get_image_alt() : '';

	// Fallback to the generic WooCommerce setup illustration.
	if ( '' === $image_url ) {
		$image_url = $asset_url . 'images/dashboard-widget-setup.png';
		$image_alt = __( 'WooCommerce setup illustration', 'woocommerce' );
	}

	return array(
		'title'        => $task->get_title(),
		'content'      => $task_json['content'] ?? '',
		'button_label' => $task_json['actionLabel'] ?? $task->get_title(),
		'image_url'    => $image_url,
		'image_alt'    => $image_alt,
	);
}