관리-도구
편집 파일: AnalyticsDashboard.php
<?php /** * Kkart Analytics Dashboard. * NOTE: DO NOT edit this file in Kkart core, this is generated from kkart-admin. */ namespace Automattic\Kkart\Admin\Features; use Automattic\Kkart\Admin\Loader; /** * Contains backend logic for the dashboard feature. */ class AnalyticsDashboard { /** * Menu slug. */ const MENU_SLUG = 'kkart-admin'; /** * Class instance. * * @var AnalyticsDashboard 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 Kkart. */ public function __construct() { add_filter( 'kkart_component_settings_preload_endpoints', array( $this, 'add_preload_endpoints' ) ); add_filter( 'kkart_admin_get_user_data_fields', array( $this, 'add_user_data_fields' ) ); } /** * Preload data from API endpoints. * * @param array $endpoints Array of preloaded endpoints. * @return array */ public function add_preload_endpoints( $endpoints ) { $endpoints['performanceIndicators'] = '/kkart-analytics/reports/performance-indicators/allowed'; $endpoints['leaderboards'] = '/kkart-analytics/leaderboards/allowed'; return $endpoints; } /** * Adds fields so that we can store performance indicators, 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_sections', 'dashboard_chart_type', 'dashboard_chart_interval', 'dashboard_leaderboard_rows', ) ); } }