2019-04-09 00:39:11 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Plugin Name: WooCommerce Admin Add Report Example
|
|
|
|
*
|
|
|
|
* @package WC_Admin
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register the JS.
|
|
|
|
*/
|
|
|
|
function add_report_register_script() {
|
|
|
|
|
|
|
|
if ( ! class_exists( 'WC_Admin_Loader' ) || ! WC_Admin_Loader::is_admin_page() ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
wp_register_script(
|
|
|
|
'add-report',
|
|
|
|
plugins_url( '/dist/index.js', __FILE__ ),
|
|
|
|
array(
|
|
|
|
'wp-hooks',
|
|
|
|
'wp-element',
|
|
|
|
'wp-i18n',
|
|
|
|
'wc-components',
|
|
|
|
),
|
|
|
|
filemtime( dirname( __FILE__ ) . '/dist/index.js' ),
|
|
|
|
true
|
|
|
|
);
|
|
|
|
|
|
|
|
wp_enqueue_script( 'add-report' );
|
|
|
|
}
|
|
|
|
add_action( 'admin_enqueue_scripts', 'add_report_register_script' );
|
2019-04-17 02:31:55 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Add "Example" as a Analytics submenu item.
|
|
|
|
*
|
|
|
|
* @param array $report_pages Report page menu items.
|
|
|
|
* @return array Updated report page menu items.
|
|
|
|
*/
|
|
|
|
function add_report_add_report_menu_item( $report_pages ) {
|
|
|
|
$report_pages[] = array(
|
2019-05-23 23:42:01 +00:00
|
|
|
'id' => 'example-analytics-report',
|
2019-04-17 02:31:55 +00:00
|
|
|
'title' => __( 'Example', 'woocommerce-admin' ),
|
2019-05-23 23:42:01 +00:00
|
|
|
'parent' => 'woocommerce-analytics',
|
2019-04-17 02:31:55 +00:00
|
|
|
'path' => '/analytics/example',
|
|
|
|
);
|
|
|
|
|
|
|
|
return $report_pages;
|
|
|
|
}
|
|
|
|
add_filter( 'woocommerce_admin_report_menu_items', 'add_report_add_report_menu_item' );
|