false ] ); } return $data; } /** * Wrapper for wp_enqueue_script() to handle various script dependencies * * @param string $handle The script handle. * @param string $src The relative script source path. The base URL will be added dynamically. * @param array $deps An array of script handles this script depends on. * @param bool $in_footer Whether to enqueue the script in the footer. * * @return void */ public static function enqueue_script( string $handle, string $src, array $deps = [], bool $in_footer = true ) { wp_enqueue_script( $handle, self::get_script_url( $src ), $deps, ISCVERSION, $in_footer ); } /** * Wrapper for wp_register_script() to handle various script dependencies * * @param string $handle The script handle. * @param string $src The relative script source path. The base URL will be added dynamically. * @param array $deps An array of script handles this script depends on. * @param bool $in_footer Whether to enqueue the script in the footer. * * @return void */ public static function register_script( string $handle, string $src, array $deps = [], bool $in_footer = true ) { wp_register_script( $handle, self::get_script_url( $src ), $deps, ISCVERSION, $in_footer ); } /** * Get script URL * * @param string $src The relative script source path. * * @return string The full URL to the script, with the base URL prepended and minified if SCRIPT_DEBUG is off. */ public static function get_script_url( string $src ): string { // load the minified script version if SCRIPT_DEBUG is off if ( ! SCRIPT_DEBUG && strpos( $src, '.min.js' ) === false ) { $src = str_replace( '.js', '.min.js', $src ); } // fix slashes return trailingslashit( ISCBASEURL ) . ltrim( $src, '/' ); } }