get_core_view( $view_id ); if ( empty( $view_atts ) ) { throw new Utils\Exception( sprintf( 'The \'%1$s\' endpoint view is invalid.', $view_id ) ); } if ( ! empty( $attributes['group_callback'] ) ) { $view_atts['group_callback'] = $attributes['group_callback']; } if ( ! empty( $attributes['handler'] ) ) { $view_atts['handler'] = $attributes['handler']; } if ( ! empty( $attributes['fields']['display_callback'] ) ) { $view_atts['fields']['display_callback'] = $attributes['fields']['display_callback']; } try { $this->validate_attributes( $view_atts, $view_id ); } catch ( \EDD_Exception $exception ) { $error = true; throw $exception; } if ( true === $error ) { return false; } else { return parent::add_item( $view_id, $view_atts ); } } /** * Retrieves registered endpoint views. * * @since 3.0 * * @return array Endpoint view records. */ public function get_endpoint_views() { return $this->get_items_sorted( 'ID' ); } /** * Prevents removing items from the registry. * * @since 3.0 * * @param string $item_id Item ID. */ public function remove_item( $item_id ) { return; } /** * Prevents removing items from the registry. * * @since 3.0 * * @param mixed $index Item index to check. */ public function offsetUnset( $index ) { return; } /** * Retrieves the core-defined views and their (mostly) immutable defaults. * * @since 3.0 * * @param string $view_id View ID. * @return array List of attributes for the given view ID if it exists, otherwise an empty array. */ public function get_core_view( $view_id ) { $views = $this->get_core_views(); $attributes = array(); if ( array_key_exists( $view_id, $views ) ) { $attributes = $views[ $view_id ]; } return $attributes; } /** * Retrieves the core-defined views and their (mostly) immutable defaults. * * @since 3.0 * * @return array List of supported endpoint types and their attributes. */ public function get_core_views() { return array( 'tile' => array( 'group' => 'tiles', 'group_callback' => 'EDD\Reports\default_display_tiles_group', 'handler' => 'EDD\Reports\Data\Tile_Endpoint', 'fields' => array( 'data_callback' => '::get_data', 'display_callback' => 'EDD\Reports\default_display_tile', 'display_args' => array( 'type' => '', 'context' => 'primary', 'comparison_label' => __( 'All time', 'easy-digital-downloads' ), ), ), ), 'chart' => array( 'group' => 'charts', 'group_callback' => 'EDD\Reports\default_display_charts_group', 'handler' => 'EDD\Reports\Data\Chart_Endpoint', 'fields' => array( 'type' => 'line', 'options' => array(), 'data_callback' => '::get_data', 'display_callback' => '::display', 'display_args' => array( 'colors' => 'core', ), ), ), 'table' => array( 'group' => 'tables', 'group_callback' => 'EDD\Reports\default_display_tables_group', 'handler' => 'EDD\Reports\Data\Table_Endpoint', 'fields' => array( 'data_callback' => '::prepare_items', 'display_callback' => '::display', 'display_args' => array( 'class_name' => '', 'class_file' => '', ), ), ), ); } }