Skip to content

Instantly share code, notes, and snippets.

@DrewAPicture
Last active April 27, 2018 09:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DrewAPicture/d0717133deb5c1c7b569dfdbdd730676 to your computer and use it in GitHub Desktop.
Save DrewAPicture/d0717133deb5c1c7b569dfdbdd730676 to your computer and use it in GitHub Desktop.
<?php
/**
* Plugin Name: Easy Digital Downloads - Example Report (standalone)
* Plugin URI: https://easydigitaldownloads.com
* Description: Implements an example report for the 3DD reports API.
* License: GPL
* Author: Bulk WP
* Version: 1.0.0
* Text Domain: edd-example-report
* Domain Path: languages/
*
* Easy Digital Downloads is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* any later version.
*
* Easy Digital Downloads is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Easy Digital Downloads. If not, see <http://www.gnu.org/licenses/>.
*
* @package EDD
* @category Core
* @author Drew Jaynes
* @version 1.0.0
*/
use EDD\Reports;
/**
* Sets up the 'Example Standalone' report and endpoints.
*
* @since 1.0.0
*/
function edd_example_setup_report() {
Reports\add_report( 'standalone_example', array(
'label' => __( 'Standalone Example Report', 'edd-example-report' ),
'priority' => 7,
'endpoints' => array(
'tiles' => array( 'standalone_data_1', 'standalone_data_2', 'standalone_data_3' ),
'tables' => array( 'standalone_data_2' )
),
) );
Reports\register_endpoint( 'standalone_data_1', array(
'label' => __( 'Standalone Data 1', 'edd-example-report' ),
'views' => array(
'tile' => array(
'data_callback' => '__return_true',
)
)
) );
Reports\register_endpoint( 'standalone_data_2', array(
'label' => __( 'Standalone Data 2', 'edd-example-report' ),
'views' => array(
'tile' => array(
'data_callback' => '__return_true',
'display_args' => array(
'context' => 'secondary',
'comparison_label' => 'Nothing to see here.'
)
),
'table' => array(
'data_callback' => '__return_true',
)
)
) );
Reports\register_endpoint( 'standalone_data_3', array(
'label' => __( 'Standalone Data 3', 'edd-example-report' ),
'views' => array(
'tile' => array(
'data_callback' => '__return_true',
'display_args' => array(
'context' => 'tertiary',
'comparison_label' => 'Nothing to see here either.'
)
),
),
) );
}
add_action( 'edd_reports_init', 'edd_example_setup_report' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment