| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
exit; // Exit if accessed directly |
| 5 |
} |
| 6 |
|
| 7 |
/** |
| 8 |
* Head custom JS |
| 9 |
* |
| 10 |
*/ |
| 11 |
function merchant_head_custom_js_first() { |
| 12 |
|
| 13 |
// Custom JS First - runs at the beginning of Merchant |
| 14 |
$custom_js_first = Merchant_Option::get( 'global-settings', 'custom_js_first', '' ); |
| 15 |
|
| 16 |
if ( ! empty( $custom_js_first ) ) { |
| 17 |
wp_add_inline_script( 'merchant', wp_kses( $custom_js_first, array() ), 'before' ); |
| 18 |
} |
| 19 |
|
| 20 |
} |
| 21 |
add_action( 'wp_enqueue_scripts', 'merchant_head_custom_js_first', 11 ); |
| 22 |
|
| 23 |
/** |
| 24 |
* Head Custom JS |
| 25 |
* |
| 26 |
*/ |
| 27 |
function merchant_head_custom_js() { |
| 28 |
|
| 29 |
// Custom JS |
| 30 |
$custom_js = Merchant_Option::get( 'global-settings', 'custom_js', '' ); |
| 31 |
|
| 32 |
if ( ! empty( $custom_js ) ) { |
| 33 |
wp_add_inline_script( 'merchant', wp_kses( $custom_js, array() ), 'after' ); |
| 34 |
} |
| 35 |
|
| 36 |
} |
| 37 |
add_action( 'wp_enqueue_scripts', 'merchant_head_custom_js', 12 ); |
| 38 |
|
| 39 |
/** |
| 40 |
* Head Custom JS Later |
| 41 |
* |
| 42 |
*/ |
| 43 |
function merchant_head_custom_js_later() { |
| 44 |
|
| 45 |
// Custom JS Last - runs at the end of Merchant |
| 46 |
$custom_js_last = Merchant_Option::get( 'global-settings', 'custom_js_last', '' ); |
| 47 |
|
| 48 |
if ( ! empty( $custom_js_last ) ) { |
| 49 |
wp_add_inline_script( 'merchant', wp_kses( $custom_js_last, array() ), 'after' ); |
| 50 |
} |
| 51 |
|
| 52 |
} |
| 53 |
add_action( 'wp_enqueue_scripts', 'merchant_head_custom_js_later', 13 ); |