Skip to content

Commit d57bf26

Browse files
committed
Add filter on script dependencies.
Will use this to set whether the global video script is required. See #14
1 parent 3ee71b4 commit d57bf26

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/ableplayer.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function ableplayer_enqueue_scripts() {
6262
* @param {string} $url URL to Able Player root directory.
6363
* @param {bool} $is_production True if environment is designated as production.
6464
*
65-
* @return string
65+
* @return {string}
6666
*/
6767
$js_dir = apply_filters( 'able_player_js', plugins_url( 'build', __FILE__ ) . '/' . $js_file, $is_production );
6868
/**
@@ -73,12 +73,25 @@ function ableplayer_enqueue_scripts() {
7373
* @param {string} $url URL to Able Player root directory.
7474
* @param {bool} $is_production True if environment is designated as production.
7575
*
76-
* @return string
76+
* @return {string}
7777
*/
7878
$css_dir = apply_filters( 'able_player_css', plugins_url( 'build', __FILE__ ) . '/' . $css_file, $is_production );
7979

8080
// Enqueue Able Player script and CSS.
81-
wp_enqueue_script( 'ableplayer', $js_dir, array( 'jquery', 'ableplayer-video' ), ABLEPLAYER_VERSION, true );
81+
$dependencies = array( 'jquery', 'ableplayer-video' );
82+
$js_dir = apply_filters( 'able_player_js', plugins_url( 'build', __FILE__ ) . '/' . $js_file, $is_production );
83+
/**
84+
* Filter the Able Player script dependencies.
85+
*
86+
* @hook ableplayer_dependencies
87+
*
88+
* @param {array} $dependencies Array of scripts required by the main AblePlayer script.
89+
* @param {bool} $is_production True if environment is designated as production.
90+
*
91+
* @return {array}
92+
*/
93+
$dependencies = apply_filters( 'ableplayer_dependencies', $dependencies, $is_production );
94+
wp_enqueue_script( 'ableplayer', $js_dir, $dependencies, ABLEPLAYER_VERSION, true );
8295
wp_enqueue_style( 'ableplayer', $css_dir, array(), ABLEPLAYER_VERSION );
8396
}
8497
add_action( 'wp_enqueue_scripts', 'ableplayer_enqueue_scripts' );

0 commit comments

Comments
 (0)