• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
Easy Digital Downloads a2z

Easy Digital Downloads a2z

Easy Digital Downloads a2z

  • Home
  • Plugins
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / EDD_Heartbeat::heartbeat_received() – Tie into the heartbeat and append our stats

You appear to be a bot. Output may be restricted

Description

Tie into the heartbeat and append our stats

Usage

$array = EDD_Heartbeat::heartbeat_received( $response, $data );

Parameters

$response
( mixed ) required –
$data
( mixed ) required –

Returns

array

Source

File name: easy-digital-downloads/includes/admin/class-edd-heartbeat.php
Lines:

1 to 27 of 27
  public static function heartbeat_received( $response, $data ) {

    if( ! current_user_can( 'view_shop_reports' ) ) {
      return $response; // Only modify heartbeat if current user can view show reports
    }

    // Make sure we only run our query if the edd_heartbeat key is present
    if( ( isset( $data['edd_heartbeat'] ) ) && ( $data['edd_heartbeat'] == 'dashboard_summary' ) ) {

      // Instantiate the stats class
      $stats = new EDD_Payment_Stats;

      $earnings = edd_get_total_earnings();

      // Send back the number of complete payments
      $response['edd-total-payments'] = edd_format_amount( edd_get_total_sales(), false );
      $response['edd-total-earnings'] = html_entity_decode( edd_currency_filter( edd_format_amount( $earnings ) ), ENT_COMPAT, 'UTF-8' );
      $response['edd-payments-month'] = edd_format_amount( $stats->get_sales( 0, 'this_month', false, array( 'publish', 'revoked' ) ), false );
      $response['edd-earnings-month'] = html_entity_decode( edd_currency_filter( edd_format_amount( $stats->get_earnings( 0, 'this_month' ) ) ), ENT_COMPAT, 'UTF-8' );
      $response['edd-payments-today'] = edd_format_amount( $stats->get_sales( 0, 'today', false, array( 'publish', 'revoked' ) ), false );
      $response['edd-earnings-today'] = html_entity_decode( edd_currency_filter( edd_format_amount( $stats->get_earnings( 0, 'today' ) ) ), ENT_COMPAT, 'UTF-8' );

    }

    return $response;

  }
 

 View on GitHub View on Trac

Published: 26th November 2019 | Last updated: 26th November 2019

Primary Sidebar

Information

Function name: EDD_Heartbeat::heartbeat_received
Class ref: EDD_Heartbeat
Plugin ref: Easy Digital Downloads
Version: 2.11.6
Sourcefile: includes/admin/class-edd-heartbeat.php
File ref: includes/admin/class-edd-heartbeat.php
Deprecated?: No
API Letters: E,H,R

Footer

Easy Digital Downloads a2z
Easy Digital Downloads a2z
Easy Digital Downloads a2z
WordPress 5.9.3
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  edd.wp-a2z.org
© Copyright Easy Digital Downloads a2z 2014-2022. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites