utils->get_registry( 'reports:endpoints' ); if ( empty( $registry ) || is_wp_error( $registry ) ) { return false; } try { $added = $registry->register_endpoint( $endpoint_id, $attributes ); } catch ( \EDD_Exception $exception ) { edd_debug_log_exception( $exception ); $added = false; } return $added; } /** * Retrieves and builds an endpoint object. * * @since 3.0 * * @see \EDD\Reports\Data\Endpoint_Registry::build_endpoint() * * @param string $endpoint_id Endpoint ID. * @param string $view_type View type to use when building the object. * @return Data\Endpoint|\WP_Error Endpoint object on success, otherwise a WP_Error object. */ function get_endpoint( $endpoint_id, $view_type ) { /** @var Data\Endpoint_Registry|\WP_Error $registry */ $registry = EDD()->utils->get_registry( 'reports:endpoints' ); if ( empty( $registry ) || is_wp_error( $registry ) ) { return $registry; } return $registry->build_endpoint( $endpoint_id, $view_type ); } /** * Registers a new report. * * @since 3.0 * * @see \EDD\Reports\Data\Report_Registry::add_report() * * @param string $report_id Report ID. * @param array $attributes { * Reports attributes. All arguments are required unless otherwise noted. * * @type string $label Report label. * @type int $priority Optional. Priority by which to register the report. Default 10. * @type array $filters Filters available to the report. * @type array $endpoints Endpoints to associate with the report. * } * @return bool True if the report was successfully registered, otherwise false. */ function add_report( $report_id, $attributes ) { /** @var Data\Report_Registry|\WP_Error $registry */ $registry = EDD()->utils->get_registry( 'reports' ); if ( empty( $registry ) || is_wp_error( $registry ) ) { return false; } try { $added = $registry->add_report( $report_id, $attributes ); } catch ( \EDD_Exception $exception ) { edd_debug_log_exception( $exception ); $added = false; } return $added; } /** * Retrieves and builds a report object. * * @since 3.0 * * @see \EDD\Reports\Data\Report_Registry::build_report() * * @param string $report_id Report ID. * @param bool $build_endpoints Optional. Whether to build the endpoints (includes registering * any endpoint dependencies, such as registering meta boxes). * Default true. * @return Data\Report|\WP_Error Report object on success, otherwise a WP_Error object. */ function get_report( $report_id = false, $build_endpoints = true ) { /** @var Data\Report_Registry|\WP_Error $registry */ $registry = EDD()->utils->get_registry( 'reports' ); if ( empty( $registry ) || is_wp_error( $registry ) ) { return $registry; } return $registry->build_report( $report_id, $build_endpoints ); } /** Sections ******************************************************************/ /** * Retrieves the list of slug/label report pairs. * * @since 3.0 * * @return array List of reports, otherwise an empty array. */ function get_reports() { /** @var Data\Report_Registry|\WP_Error $registry */ $registry = EDD()->utils->get_registry( 'reports' ); if ( empty( $registry ) || is_wp_error( $registry ) ) { return array(); } else { $reports = $registry->get_reports( 'priority', 'core' ); } // Re-sort by priority. uasort( $reports, array( $registry, 'priority_sort' ) ); /** * Filters the list of report slug/label pairs. * * @since 3.0 * * @param array $reports List of slug/label pairs as representative of reports. */ return apply_filters( 'edd_get_reports', $reports ); } /** * Retrieves the slug for the active report. * * @since 3.0 * * @return string The active report, or the 'overview' report if no view defined */ function get_current_report() { return isset( $_REQUEST['view'] ) ? sanitize_key( $_REQUEST['view'] ) : 'overview'; // Hardcoded default } /** Endpoints *****************************************************************/ /** * Retrieves the list of supported endpoint view types and their attributes. * * @since 3.0 * * @return array List of supported endpoint types. */ function get_endpoint_views() { if ( ! did_action( 'edd_reports_init' ) ) { _doing_it_wrong( __FUNCTION__, 'Endpoint views cannot be retrieved prior to the firing of the edd_reports_init hook.', 'EDD 3.0' ); return array(); } /** @var Data\Endpoint_View_Registry|\WP_Error $registry */ $registry = EDD()->utils->get_registry( 'reports:endpoints:views' ); if ( empty( $registry ) || is_wp_error( $registry ) ) { return array(); } else { $views = $registry->get_endpoint_views(); } return $views; } /** * Retrieves the name of the handler class for a given endpoint view. * * @since 3.0 * * @param string $view Endpoint view. * @return string Handler class name if set and the view exists, otherwise an empty string. */ function get_endpoint_handler( $view ) { $views = get_endpoint_views(); return isset( $views[ $view ]['handler'] ) ? $views[ $view ]['handler'] : ''; } /** * Retrieves the group display callback for a given endpoint view. * * @since 3.0 * * @param string $view Endpoint view. * @return string Group callback if set, otherwise an empty string. */ function get_endpoint_group_callback( $view ) { $views = get_endpoint_views(); return isset( $views[ $view ]['group_callback'] ) ? $views[ $view ]['group_callback'] : ''; } /** * Determines whether an endpoint view is valid. * * @since 3.0 * * @param string $view Endpoint view slug. * @return bool True if the view is valid, otherwise false. */ function validate_endpoint_view( $view ) { return array_key_exists( $view, get_endpoint_views() ); } /** * Parses views for an incoming endpoint. * * @since 3.0 * * @see get_endpoint_views() * * @param array $views View slugs and attributes as dictated by get_endpoint_views(). * * @return array (Maybe) adjusted views slugs and attributes array. */ function parse_endpoint_views( $views ) { $valid_views = get_endpoint_views(); foreach ( $views as $view => $attributes ) { if ( ! empty( $valid_views[ $view ]['fields'] ) ) { $fields = $valid_views[ $view ]['fields']; // Merge the incoming args with the field defaults. $view_args = wp_parse_args( $attributes, $fields ); // Overwrite the view attributes, keeping only the valid fields. $views[ $view ] = array_intersect_key( $view_args, $fields ); if ( $views[ $view ]['display_callback'] === $fields['display_callback'] ) { $views[ $view ]['display_args'] = wp_parse_args( $views[ $view ]['display_args'], $fields['display_args'] ); } } } return $views; } /** Filters *******************************************************************/ /** * Retrieves the list of registered reports filters and their attributes. * * @since 3.0 * * @return array List of supported endpoint filters. */ function get_filters() { $filters = array( 'dates' => array( 'label' => __( 'Date', 'easy-digital-downloads' ), 'display_callback' => __NAMESPACE__ . '\\display_dates_filter' ), 'products' => array( 'label' => __( 'Products', 'easy-digital-downloads' ), 'display_callback' => __NAMESPACE__ . '\\display_products_filter' ), 'product_categories' => array( 'label' => __( 'Product Categories', 'easy-digital-downloads' ), 'display_callback' => __NAMESPACE__ . '\\display_product_categories_filter' ), 'taxes' => array( 'label' => __( 'Exclude Taxes', 'easy-digital-downloads' ), 'display_callback' => __NAMESPACE__ . '\\display_taxes_filter' ), 'gateways' => array( 'label' => __( 'Gateways', 'easy-digital-downloads' ), 'display_callback' => __NAMESPACE__ . '\\display_gateways_filter' ), 'discounts' => array( 'label' => __( 'Discounts', 'easy-digital-downloads' ), 'display_callback' => __NAMESPACE__ . '\\display_discounts_filter' ), 'regions' => array( 'label' => __( 'Regions', 'easy-digital-downloads' ), 'display_callback' => __NAMESPACE__ . '\\display_region_filter' ), 'countries' => array( 'label' => __( 'Countries', 'easy-digital-downloads' ), 'display_callback' => __NAMESPACE__ . '\\display_country_filter' ), 'currencies' => array( 'label' => __( 'Currencies', 'easy-digital-downloads' ), 'display_callback' => __NAMESPACE__ . '\\display_currency_filter' ) ); /** * Filters the list of available report filters. * * @since 3.0 * * @param array[] $filters */ return apply_filters( 'edd_report_filters', $filters ); } /** * Determines whether the given filter is valid. * * @since 3.0 * * @param string $filter Filter key. * @return bool True if the filter is valid, otherwise false. */ function validate_filter( $filter ) { return array_key_exists( $filter, get_filters() ); } /** * Retrieves the value of an endpoint filter for the current session and report. * * @since 3.0 * * @param string $filter Filter key to retrieve the value for. * @return mixed|string Value of the filter if it exists, otherwise an empty string. */ function get_filter_value( $filter ) { $value = ''; // Bail if filter does not validate if ( ! validate_filter( $filter ) ) { return $value; } switch ( $filter ) { // Handle dates. case 'dates': $default_range = 'this_month'; $default_relative_range = 'previous_period'; if ( ! isset( $_GET['range'] ) ) { $dates = parse_dates_for_range( $default_range ); $value = array( 'range' => $default_range, 'relative_range' => $default_relative_range, 'from' => $dates['start']->format( 'Y-m-d' ), 'to' => $dates['end']->format( 'Y-m-d' ), ); } else { $value = array( 'range' => isset( $_GET['range'] ) ? sanitize_text_field( $_GET['range'] ) : $default_range, 'relative_range' => isset( $_GET['relative_range'] ) ? sanitize_text_field( $_GET['relative_range'] ) : $default_relative_range, 'from' => isset( $_GET['filter_from'] ) ? sanitize_text_field( $_GET['filter_from'] ) : '', 'to' => isset( $_GET['filter_to'] ) ? sanitize_text_field( $_GET['filter_to'] ) : '' ); } break; // Handle taxes. case 'taxes': $value = array(); if ( isset( $_GET['exclude_taxes'] ) ) { $value['exclude_taxes'] = true; } break; // Handle default (direct from URL). default: $value = isset( $_GET[ $filter ] ) ? sanitize_text_field( $_GET[ $filter ] ) : ''; /** * Filters the value of a report filter. * * @since 3.0 * * @param string $value Report filter value. * @param string $filter Report filter. */ $value = apply_filters( 'edd_reports_get_filter_value', $value, $filter ); } return $value; } /** * Returns a list of registered report filters that should be persisted across views. * * @since 3.0 * * @return array */ function get_persisted_filters() { $filters = array( 'range', 'relative_range', 'filter_from', 'filter_to', 'exclude_taxes', ); /** * Filters registered report filters that should be persisted across views. * * @since 3.0 * * @param array $filters List of registered filters to persist. */ $filters = apply_filters( 'edd_reports_get_persisted_filters', $filters ); return $filters; } /** * Retrieves key/label pairs of date filter options for use in a drop-down. * * @since 3.0 * * @return array Key/label pairs of date filter options. */ function get_dates_filter_options() { static $options = null; if ( is_null( $options ) ) { $options = array( 'other' => __( 'Custom', 'easy-digital-downloads' ), 'today' => __( 'Today', 'easy-digital-downloads' ), 'yesterday' => __( 'Yesterday', 'easy-digital-downloads' ), 'this_week' => __( 'This Week', 'easy-digital-downloads' ), 'last_week' => __( 'Last Week', 'easy-digital-downloads' ), 'last_30_days' => __( 'Last 30 Days', 'easy-digital-downloads' ), 'this_month' => __( 'Month to Date', 'easy-digital-downloads' ), 'last_month' => __( 'Last Month', 'easy-digital-downloads' ), 'this_quarter' => __( 'Quarter to Date', 'easy-digital-downloads' ), 'last_quarter' => __( 'Last Quarter', 'easy-digital-downloads' ), 'this_year' => __( 'Year to Date', 'easy-digital-downloads' ), 'last_year' => __( 'Last Year', 'easy-digital-downloads' ), ); } /** * Filters the list of key/label pairs of date filter options. * * @since 1.3 * * @param array $date_options Date filter options. */ return apply_filters( 'edd_report_date_options', $options ); } /** * Retrieves the default relative range key for a specific range. * * @since 3.1 * * @return string Relative date range key. */ function get_default_relative_range( $range ) { switch ( $range ) { case 'this_month': case 'last_month': $relative_range = 'previous_month'; break; case 'this_quarter': case 'last_quarter': $relative_range = 'previous_quarter'; break; case 'this_year': case 'last_year': $relative_range = 'previous_year'; break; default: $relative_range = 'previous_period'; break; } return $relative_range; } /** * Retrieves key/label pairs of relative date filter options for use in a drop-down. * * @since 3.1 * * @return array Key/label pairs of relative date filter options. */ function get_relative_dates_filter_options() { static $options = null; if ( is_null( $options ) ) { $options = array( 'previous_period' => __( 'Previous period', 'easy-digital-downloads' ), 'previous_month' => __( 'Previous month', 'easy-digital-downloads' ), 'previous_quarter' => __( 'Previous quarter', 'easy-digital-downloads' ), 'previous_year' => __( 'Previous year', 'easy-digital-downloads' ), ); } return $options; } /** * Retrieves the start and end date filters for use with the Reports API. * * @since 3.0 * * @param string $values Optional. What format to retrieve dates in the resulting array in. * Accepts 'strings' or 'objects'. Default 'strings'. * @param string $timezone Optional. Timezone to force for filter dates. Primarily used for * legacy testing purposes. Default empty. * @return array|\EDD\Utils\Date[] { * Query date range for the current graph filter request. * * @type string|\EDD\Utils\Date $start Start day and time (based on the beginning of the given day). * If `$values` is 'objects', a Carbon object, otherwise a date * time string. * @type string|\EDD\Utils\Date $end End day and time (based on the end of the given day). If `$values` * is 'objects', a Carbon object, otherwise a date time string. * } */ function get_dates_filter( $values = 'strings', $timezone = null ) { $dates = parse_dates_for_range(); if ( 'strings' === $values ) { if ( ! empty( $dates['start'] ) ) { $dates['start'] = $dates['start']->toDateTimeString(); } if ( ! empty( $dates['end'] ) ) { $dates['end'] = $dates['end']->toDateTimeString(); } } /** * Filters the start and end date filters for use with the Graphs API. * * @since 3.0 * * @param array|\EDD\Utils\Date[] $dates { * Query date range for the current graph filter request. * * @type string|\EDD\Utils\Date $start Start day and time (based on the beginning of the given day). * If `$values` is 'objects', a Date object, otherwise a date * time string. * @type string|\EDD\Utils\Date $end End day and time (based on the end of the given day). If `$values` * is 'objects', a Date object, otherwise a date time string. * } */ return apply_filters( 'edd_get_dates_filter', $dates ); } /** * Parses start and end dates for the given range. * * @since 3.0 * * @param string $range Optional. Range value to generate start and end dates for against `$date`. * Default is the current range as derived from the session. * @param string $date Date string converted to `\EDD\Utils\Date` to anchor calculations to. * @param bool $convert_to_utc Optional. If we should convert the results to UTC for Database Queries * @return \EDD\Utils\Date[] Array of start and end date objects. */ function parse_dates_for_range( $range = null, $date = 'now', $convert_to_utc = true ) { // Set the time ranges in the user's timezone, so they ultimately see them in their own timezone. $date = EDD()->utils->date( $date, edd_get_timezone_id(), false ); if ( null === $range || ! array_key_exists( $range, get_dates_filter_options() ) ) { $range = get_dates_filter_range(); } switch ( $range ) { case 'this_month': $dates = array( 'start' => $date->copy()->startOfMonth(), 'end' => $date->copy()->endOfDay(), ); break; case 'last_month': $dates = array( 'start' => $date->copy()->subMonthNoOverflow( 1 )->startOfMonth(), 'end' => $date->copy()->subMonthNoOverflow( 1 )->endOfMonth(), ); break; case 'today': $dates = array( 'start' => $date->copy()->startOfDay(), 'end' => $date->copy()->endOfDay(), ); break; case 'yesterday': $dates = array( 'start' => $date->copy()->subDay( 1 )->startOfDay(), 'end' => $date->copy()->subDay( 1 )->endOfDay(), ); break; case 'this_week': $dates = array( 'start' => $date->copy()->startOfWeek(), 'end' => $date->copy()->endOfDay(), ); break; case 'last_week': $dates = array( 'start' => $date->copy()->subWeek( 1 )->startOfWeek(), 'end' => $date->copy()->subWeek( 1 )->endOfWeek(), ); break; case 'last_30_days': $dates = array( 'start' => $date->copy()->subDay( 30 )->startOfDay(), 'end' => $date->copy()->endOfDay(), ); break; case 'this_quarter': $dates = array( 'start' => $date->copy()->startOfQuarter(), 'end' => $date->copy()->endOfDay(), ); break; case 'last_quarter': $dates = array( 'start' => $date->copy()->subQuarter( 1 )->startOfQuarter(), 'end' => $date->copy()->subQuarter( 1 )->endOfQuarter(), ); break; case 'this_year': $dates = array( 'start' => $date->copy()->startOfYear(), 'end' => $date->copy()->endOfDay(), ); break; case 'last_year': $dates = array( 'start' => $date->copy()->subYear( 1 )->startOfYear(), 'end' => $date->copy()->subYear( 1 )->endOfYear(), ); break; case 'other': default: $dates_from_report = get_filter_value( 'dates' ); if ( ! empty( $dates_from_report ) ) { $start = $dates_from_report['from']; $end = $dates_from_report['to']; } else { $start = $end = 'now'; } $dates = array( 'start' => EDD()->utils->date( $start, edd_get_timezone_id(), false )->startOfDay(), 'end' => EDD()->utils->date( $end, edd_get_timezone_id(), false )->endOfDay(), ); break; } if ( $convert_to_utc ) { // Convert the values to the UTC equivalent so that we can query the database using UTC. $dates['start'] = edd_get_utc_equivalent_date( $dates['start'] ); $dates['end'] = edd_get_utc_equivalent_date( $dates['end'] ); } $dates['range'] = $range; return $dates; } /** * Parses relative start and end dates for the given range. * * @since 3.1 * * @param string $range Optional. Range value to generate start and end dates for against `$date`. * @param string $relative_range Optional. Range value to generate relative start and end dates for against `$date`. * Default is the current range as derived from the session. * @param string $date Date string converted to `\EDD\Utils\Date` to anchor calculations to. * @param bool $convert_to_utc Optional. If we should convert the results to UTC for Database Queries * @return \EDD\Utils\Date[] Array of start and end date objects. */ function parse_relative_dates_for_range( $range = null, $relative_range = null, $date = 'now', $convert_to_utc = true ) { // Set the time ranges in the user's timezone, so they ultimately see them in their own timezone. $date = EDD()->utils->date( $date, edd_get_timezone_id(), false ); if ( null === $range || ! array_key_exists( $range, get_dates_filter_options() ) ) { $range = get_dates_filter_range(); } if ( null === $relative_range || ! array_key_exists( $relative_range, get_relative_dates_filter_options() ) ) { $relative_range = get_relative_dates_filter_range(); } $dates = parse_dates_for_range( $range, $date, false ); switch ( $relative_range ) { case 'previous_period': $days_diff = $dates['start']->copy()->diffInDays( $dates['end'], true ) + 1; $dates = array( 'start' => $dates['start']->copy()->subDays( $days_diff ), 'end' => $dates['end']->copy()->subDays( $days_diff ), ); break; case 'previous_month': $dates = array( 'start' => $dates['start']->copy()->subMonth( 1 ), 'end' => $dates['end']->copy()->subMonth( 1 ), ); break; case 'previous_quarter': $dates = array( 'start' => $dates['start']->copy()->subQuarter( 1 ), 'end' => $dates['end']->copy()->subQuarter( 1 ), ); break; case 'previous_year': $dates = array( 'start' => $dates['start']->copy()->subYear( 1 ), 'end' => $dates['end']->copy()->subYear( 1 ), ); break; } if ( $convert_to_utc ) { // Convert the values to the UTC equivalent so that we can query the database using UTC. $dates['start'] = edd_get_utc_equivalent_date( $dates['start'] ); $dates['end'] = edd_get_utc_equivalent_date( $dates['end'] ); } $dates['range'] = $range; return $dates; } /** * Retrieves the date filter range. * * @since 3.0 * * @return string Date filter range. */ function get_dates_filter_range() { $dates = get_filter_value( 'dates' ); if ( isset( $dates['range'] ) ) { $range = sanitize_key( $dates['range'] ); } else { /** * Filters the report dates default range. * * @since 1.3 * * @param string $range Date range as derived from the session. Default 'last_30_days' * @param array $dates Dates filter data array. */ $range = apply_filters( 'edd_get_report_dates_default_range', 'this_month', $dates ); } /** * Filters the dates filter range. * * @since 3.0 * * @param string $range Dates filter range. * @param array $dates Dates filter data array. */ return apply_filters( 'edd_get_dates_filter_range', $range, $dates ); } /** * Retrieves the date filter for relative range. * * @since 3.1 * * @return string Date filter range. */ function get_relative_dates_filter_range() { $dates = get_filter_value( 'dates' ); if ( isset( $dates['relative_range'] ) ) { $relative_range = sanitize_key( $dates['relative_range'] ); } else { /** * Filters the report dates default range. * * @since 3.1 * * @param string $range Relative daate range as derived from the session. Default 'previous_period' * @param array $dates Dates filter data array. */ $relative_range = apply_filters( 'edd_get_report_dates_default_relative_range', 'previous_period', $dates ); } /** * Filters the dates filter range. * * @since 3.1 * * @param string $range Dates filter relative range. * @param array $dates Dates filter data array. */ return apply_filters( 'edd_get_dates_filter_relative_range', $relative_range, $dates ); } /** * Determines whether results should be displayed hour by hour, or not. * * @since 3.0 * * @return bool True if results should use hour by hour, otherwise false. */ function get_dates_filter_hour_by_hour() { $hour_by_hour = false; // Retrieve the queried dates. $dates = get_dates_filter( 'objects' ); // Determine graph options. switch ( $dates['range'] ) { case 'today': case 'yesterday': $hour_by_hour = true; break; case 'this_week': case 'this_month': case 'this_quarter': case 'this_year': case 'other': $difference = ( $dates['end']->getTimestamp() - $dates['start']->getTimestamp() ); if ( $difference <= ( DAY_IN_SECONDS * 2 ) ) { $hour_by_hour = true; } break; default: $hour_by_hour = false; break; } return $hour_by_hour; } /** * Determines whether results should be displayed day by day or not. * * @since 3.0 * * @return bool True if results should use day by day, otherwise false. */ function get_dates_filter_day_by_day() { // Retrieve the queried dates $dates = get_dates_filter( 'objects' ); // Determine graph options switch ( $dates['range'] ) { case 'today': case 'yesterday': case 'this_year': case 'last_year': $day_by_day = false; break; case 'other': $difference = ( $dates['end']->getTimestamp() - $dates['start']->getTimestamp() ); if ( $difference >= ( YEAR_IN_SECONDS / 4 ) ) { $day_by_day = false; } else { $day_by_day = true; } break; default: $day_by_day = true; break; } return $day_by_day; } /** * Given a function and column, make a timezone converted groupby query. * * @since 3.0 * @since 3.0.4 If MONTH is passed as the function, always add YEAR and MONTH * to avoid issues with spanning multiple years. * * @param string $function The function to run the value through, like DATE, HOUR, MONTH. * @param string $column The column to group by. * * @return string */ function get_groupby_date_string( $function = 'DATE', $column = 'date_created' ) { $function = strtoupper( $function ); $date = EDD()->utils->date( 'now', edd_get_timezone_id(), false ); $gmt_offset = $date->getOffset(); if ( empty( $gmt_offset ) ) { switch ( $function ) { case 'HOUR': $group_by_string = "DAY({$column}), HOUR({$column})"; break; case 'MONTH': $group_by_string = "YEAR({$column}), MONTH({$column})"; break; default: $group_by_string = "{$function}({$column})"; break; } return $group_by_string; } // Output the offset in the proper format. $hours = abs( floor( $gmt_offset / HOUR_IN_SECONDS ) ); $minutes = abs( floor( ( $gmt_offset / MINUTE_IN_SECONDS ) % MINUTE_IN_SECONDS ) ); $math = ( $gmt_offset >= 0 ) ? '+' : '-'; $formatted_offset = ! empty( $minutes ) ? "{$hours}:{$minutes}" : $hours . ':00'; /** * There is a limitation here that we cannot get past due to MySQL not having timezone information. * * When a requested date group spans the DST change. For instance, a 6 month graph will have slightly * different results for each month than if you pulled each of those 6 months individually. This is because * our 'grouping' can only convert the timezone based on the current offset and that can change if the * range spans the DST break, which would have some dates be in a +/- 1 hour state. * * @see https://github.com/awesomemotive/easy-digital-downloads/pull/9449 */ $column_conversion = "CONVERT_TZ({$column}, '+0:00', '{$math}{$formatted_offset}')"; switch ( $function ) { case 'HOUR': $group_by_string = "DAY({$column_conversion}), HOUR({$column_conversion})"; break; case 'MONTH': $group_by_string = "YEAR({$column_conversion}), MONTH({$column_conversion})"; break; default: $group_by_string = "{$function}({$column_conversion})"; break; } return $group_by_string; } /** * Retrieves the tax exclusion filter. * * @since 3.0 * * @return bool True if taxes should be excluded from calculations. */ function get_taxes_excluded_filter() { $taxes = get_filter_value( 'taxes' ); if ( ! isset( $taxes['exclude_taxes'] ) ) { return false; } return (bool) $taxes['exclude_taxes']; } /** Display *******************************************************************/ /** * Handles display of a report. * * @since 3.0 * * @param Data\Report $report Report object. */ function default_display_report( $report ) { // Bail if erroneous report if ( empty( $report ) || is_wp_error( $report ) ) { return; } // Try to output: tiles, tables, and charts $report->display_endpoint_group( 'tiles' ); $report->display_endpoint_group( 'tables' ); $report->display_endpoint_group( 'charts' ); } /** * Displays the default content for a tile endpoint. * * @since 3.0 * * @param Data\Report $report Report object the tile endpoint is being rendered in. * Not always set. * @param array $tile { * Tile display arguments. * * @type Data\Tile_Endpoint $endpoint Endpoint object. * @type mixed|array $data Date for display. By default, will be an array, * but can be of other types. * @type array $display_args Array of any display arguments. * } * @return void Meta box display callbacks only echo output. */ function default_display_tile( $endpoint, $data, $args ) { echo '