| 1 |
<?php |
| 2 |
/** |
| 3 |
* Scripts |
| 4 |
* |
| 5 |
* @package AutomatorWP\Integrations\WordPress\Scripts |
| 6 |
* @author AutomatorWP <contact@automatorwp.com>, Ruben Garcia <rubengcdev@gmail.com> |
| 7 |
* @since 1.0.0 |
| 8 |
*/ |
| 9 |
// Exit if accessed directly |
| 10 |
if( !defined( 'ABSPATH' ) ) exit; |
| 11 |
|
| 12 |
/** |
| 13 |
* Register admin scripts |
| 14 |
* |
| 15 |
* @since 1.0.0 |
| 16 |
* @return void |
| 17 |
*/ |
| 18 |
function automatorwp_wordpress_admin_register_scripts() { |
| 19 |
|
| 20 |
// Use minified libraries if SCRIPT_DEBUG is turned off |
| 21 |
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
| 22 |
|
| 23 |
// Scripts |
| 24 |
wp_register_script( 'automatorwp-wordpress-js', AUTOMATORWP_WORDPRESS_URL . 'assets/js/automatorwp-wordpress' . $suffix . '.js', array( 'jquery' ), '1.0.0', true ); |
| 25 |
|
| 26 |
} |
| 27 |
add_action( 'admin_init', 'automatorwp_wordpress_admin_register_scripts' ); |
| 28 |
|
| 29 |
/** |
| 30 |
* Enqueue admin scripts |
| 31 |
* |
| 32 |
* @since 1.0.0 |
| 33 |
* @return void |
| 34 |
*/ |
| 35 |
function automatorwp_wordpress_admin_enqueue_scripts( $hook ) { |
| 36 |
|
| 37 |
// Scripts |
| 38 |
wp_localize_script( 'automatorwp-wordpress-js', 'automatorwp_wordpress', array( |
| 39 |
'nonce' => automatorwp_get_admin_nonce(), |
| 40 |
) ); |
| 41 |
|
| 42 |
wp_enqueue_script( 'automatorwp-wordpress-js' ); |
| 43 |
|
| 44 |
} |
| 45 |
add_action( 'admin_enqueue_scripts', 'automatorwp_wordpress_admin_enqueue_scripts', 100 ); |