| 1 |
<?php |
| 2 |
/** |
| 3 |
* Scripts |
| 4 |
* |
| 5 |
* @package GamiPress\Gravity_Forms\Scripts |
| 6 |
* @since 1.0.0 |
| 7 |
*/ |
| 8 |
// Exit if accessed directly |
| 9 |
if( !defined( 'ABSPATH' ) ) exit; |
| 10 |
|
| 11 |
/** |
| 12 |
* Register admin scripts |
| 13 |
* |
| 14 |
* @since 1.0.0 |
| 15 |
* @return void |
| 16 |
*/ |
| 17 |
function gamipress_gf_admin_register_scripts() { |
| 18 |
// Use minified libraries if SCRIPT_DEBUG is turned off |
| 19 |
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
| 20 |
|
| 21 |
// Scripts |
| 22 |
wp_register_script( 'gamipress-gf-admin-js', GAMIPRESS_GF_URL . 'assets/js/gamipress-gf-admin' . $suffix . '.js', array( 'jquery' ), GAMIPRESS_GF_VER, true ); |
| 23 |
|
| 24 |
} |
| 25 |
add_action( 'admin_init', 'gamipress_gf_admin_register_scripts' ); |
| 26 |
|
| 27 |
/** |
| 28 |
* Enqueue admin scripts |
| 29 |
* |
| 30 |
* @since 1.0.0 |
| 31 |
* @return void |
| 32 |
*/ |
| 33 |
function gamipress_gf_admin_enqueue_scripts( $hook ) { |
| 34 |
|
| 35 |
global $post_type; |
| 36 |
|
| 37 |
// Requirements ui script |
| 38 |
if ( $post_type === 'points-type' || in_array( $post_type, gamipress_get_achievement_types_slugs() ) || in_array( $post_type, gamipress_get_rank_types_slugs() ) ) { |
| 39 |
wp_enqueue_script( 'gamipress-gf-admin-js' ); |
| 40 |
} |
| 41 |
|
| 42 |
} |
| 43 |
add_action( 'admin_enqueue_scripts', 'gamipress_gf_admin_enqueue_scripts', 100 ); |