-
Notifications
You must be signed in to change notification settings - Fork 0
/
woocommerce-action-logging.php
61 lines (50 loc) · 1.79 KB
/
woocommerce-action-logging.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/**
* Plugin Name: WooCommerce Action Logging
* Plugin URI: https://github.com/billrobbins/woocommerce-action-logging
* Description: Logs a stack backtrace whenever a specified WooCommerce hook is used
* Version: 0.1
* Requires at least: 5.2
* Requires PHP: 7.4
* Author: Bill Robbins
* Author URI: https://justabill.blog
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/
// Load REST API Endpoint
require_once plugin_dir_path( __FILE__ ) . '/includes/class-endpoints.php';
// Load Admin Page
require_once plugin_dir_path( __FILE__ ) . '/includes/class-admin-page.php';
// Load Logging
require_once plugin_dir_path( __FILE__ ) . '/includes/class-logging-action.php';
/**
* Register and enqueue JS and CSS
*/
function wc_action_logging_scripts() {
if ( isset( $_GET['page'] ) && ! empty( $_GET['page'] ) && 'action-logging' !== $_GET['page'] ) {
return;
}
$script_path = '/build/index.js';
$script_asset_path = dirname( __FILE__ ) . '/build/index.asset.php';
$script_asset = file_exists( $script_asset_path )
? require( $script_asset_path )
: array( 'dependencies' => array(), 'version' => filemtime( $script_path ) );
$script_url = plugins_url( $script_path, __FILE__ );
wp_register_script(
'action-logging',
$script_url,
$script_asset['dependencies'],
$script_asset['version'],
true
);
wp_register_style(
'action-logging',
plugins_url( '/build/index.css', __FILE__ ),
// Add any dependencies styles may have, such as wp-components.
array(),
filemtime( dirname( __FILE__ ) . '/build/index.css' )
);
wp_enqueue_script( 'action-logging' );
wp_enqueue_style( 'action-logging' );
}
add_action( 'admin_enqueue_scripts', 'wc_action_logging_scripts' );