forked from marcusig/pc-custom-code-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigurator-custom-code.php
More file actions
55 lines (47 loc) · 1.41 KB
/
configurator-custom-code.php
File metadata and controls
55 lines (47 loc) · 1.41 KB
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
<?php
/**
* Plugin Name: Configurator - Custom code bootstrap
* Plugin URI: http://wc-product-configurator.com/
* Description: Use this plugin to start adding custom code to the configurator
* Version: 1.0.1
* Author: marcusig
* Author URI: https://mklacroix.com
*/
// If this file is called directly, abort.
if ( ! defined( 'ABSPATH' ) ) {
die;
}
add_action( 'mkl_pc_scripts_product_page_after', 'mkl_custom_add_scripts' );
function mkl_custom_add_scripts() {
// List of dependencies
$dependencies = [
'jquery',
'wp-util',
'wp-hooks',
'mkl_pc/js/views/configurator'
];
// Enqueue a script
wp_enqueue_script(
'mkl_pc/Custom/js',
trailingslashit( plugin_dir_url( __FILE__ ) ) . 'assets/js/custom.js',
$dependencies,
filemtime( trailingslashit( plugin_dir_path ( __FILE__ ) ) . 'assets/js/custom.js' ),
true
);
// Enqueue a CSS file
wp_enqueue_style(
'mkl_pc/Custom/css',
trailingslashit( plugin_dir_url( __FILE__ ) ) . 'assets/css/custom.css',
[],
filemtime( trailingslashit( plugin_dir_path ( __FILE__ ) ) . 'assets/css/custom.css' )
);
}
/**
* Force loading the configurator assets on the frontpage
add_filter( 'load_configurator_on_page', function( $load ) {
if ( is_front_page() ) return true;
return $load;
} );
// Force loading the configurator assets on every page
// add_filter( 'load_configurator_on_page', '__return_true' );
*/