woocommerce/plugins/woocommerce-admin/includes/features/dashboard/class-wc-admin-dashboard.php

72 lines
1.7 KiB
PHP

<?php
/**
* WooCommerce Dashboard.
* NOTE: DO NOT edit this file in WooCommerce core, this is generated from woocommerce-admin.
*
* @package Woocommerce Admin
*/
/**
* Contains backend logic for the dashboard feature.
*/
class WC_Admin_Dashboard {
/**
* Class instance.
*
* @var WC_Admin_Dashboard instance
*/
protected static $instance = null;
/**
* Get class instance.
*/
public static function get_instance() {
if ( ! self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Hook into WooCommerce.
*/
public function __construct() {
add_filter( 'woocommerce_component_settings_preload_endpoints', array( $this, 'add_preload_endpoints' ) );
add_filter( 'wc_admin_get_user_data_fields', array( $this, 'add_user_data_fields' ) );
}
/**
* Preload data from the performance indiciators endpoint.
*
* @param array $endpoints Array of preloaded endpoints.
* @return array
*/
public function add_preload_endpoints( $endpoints ) {
$endpoints['performanceIndicators'] = '/wc/v4/reports/performance-indicators/allowed';
$endpoints['leaderboards'] = '/wc/v4/leaderboards/allowed';
return $endpoints;
}
/**
* Adds fields so that we can store performance indiciators, row settings, and chart type settings for users.
*
* @param array $user_data_fields User data fields.
* @return array
*/
public function add_user_data_fields( $user_data_fields ) {
return array_merge(
$user_data_fields,
array(
'dashboard_performance_indicators',
'dashboard_charts',
'dashboard_chart_type',
'dashboard_chart_interval',
'dashboard_leaderboards',
'dashboard_leaderboard_rows',
)
);
}
}
new WC_Admin_Dashboard();