|
74 | 74 | wp_enqueue_script( 'js-cookie', plugins_url( 'thirdparty', __FILE__ ) . '/js.cookie.js', array( 'jquery' ), ABLEPLAYER_VERSION, true ); |
75 | 75 | wp_enqueue_script( 'vimeo', 'https://player.vimeo.com/api/player.js', array(), ABLEPLAYER_VERSION, true ); |
76 | 76 | wp_register_script( 'ableplayer-video', plugins_url( 'assets', __FILE__ ) . '/js/video.js', array(), ABLEPLAYER_VERSION, true ); |
77 | | - |
| 77 | + wp_localize_script( |
| 78 | + 'ableplayer-video', |
| 79 | + 'ableplayer', |
| 80 | + array( |
| 81 | + 'settings' => ableplayer_get_settings(), |
| 82 | + ) |
| 83 | + ); |
78 | 84 | // if the environment is production, use minified files. Otherwise, inherit the value of SCRIPT_DEBUG. |
79 | 85 | $is_production = ( function_exists( 'wp_get_environment_type' ) && wp_get_environment_type() === 'production' ) ? true : SCRIPT_DEBUG; |
80 | 86 |
|
|
88 | 94 | * @param {string} $url URL to Able Player root directory. |
89 | 95 | * @param {bool} $is_production True if environment is designated as production. |
90 | 96 | * |
91 | | - * @return string |
| 97 | + * @return {string} |
92 | 98 | */ |
93 | 99 | $js_dir = apply_filters( 'able_player_js', plugins_url( 'build', __FILE__ ) . '/' . $js_file, $is_production ); |
94 | 100 | /** |
|
99 | 105 | * @param {string} $url URL to Able Player root directory. |
100 | 106 | * @param {bool} $is_production True if environment is designated as production. |
101 | 107 | * |
102 | | - * @return string |
| 108 | + * @return {string} |
103 | 109 | */ |
104 | 110 | $css_dir = apply_filters( 'able_player_css', plugins_url( 'build', __FILE__ ) . '/' . $css_file, $is_production ); |
105 | 111 |
|
106 | | - // Enqueue Able Player script and CSS. |
107 | | - wp_enqueue_script( 'ableplayer', $js_dir, array( 'jquery', 'ableplayer-video' ), ABLEPLAYER_VERSION, true ); |
| 112 | + $dependencies = array( 'jquery', 'ableplayer-video' ); |
| 113 | + /** |
| 114 | + * Filter the Able Player script dependencies. |
| 115 | + * |
| 116 | + * @hook ableplayer_dependencies |
| 117 | + * |
| 118 | + * @param {array} $dependencies Array of scripts required by the main AblePlayer script. |
| 119 | + * @param {bool} $is_production True if environment is designated as production. |
| 120 | + * |
| 121 | + * @return {array} |
| 122 | + */ |
| 123 | + $dependencies = apply_filters( 'ableplayer_dependencies', $dependencies, $is_production ); |
| 124 | + wp_enqueue_script( 'ableplayer', $js_dir, $dependencies, ABLEPLAYER_VERSION, true ); |
108 | 125 | wp_enqueue_style( 'ableplayer', $css_dir, array(), ABLEPLAYER_VERSION ); |
109 | 126 | } |
110 | 127 | add_action( 'wp_enqueue_scripts', 'ableplayer_enqueue_scripts' ); |
111 | 128 |
|
| 129 | +/** |
| 130 | + * Get Able Player settings. |
| 131 | + * |
| 132 | + * @param string $setting A specific setting key. Default empty string. |
| 133 | + * |
| 134 | + * @return array|mixed The full settings array or a specific setting value. |
| 135 | + */ |
| 136 | +function ableplayer_get_settings( $setting = '' ) { |
| 137 | + $settings = get_option( 'ableplayer_settings', ableplayer_default_settings() ); |
| 138 | + if ( $setting && isset( $settings[ $setting ] ) ) { |
| 139 | + return $settings[ $setting ]; |
| 140 | + } |
| 141 | + |
| 142 | + return $settings; |
| 143 | +} |
| 144 | + |
| 145 | +/** |
| 146 | + * Get Able Player default settings. |
| 147 | + * |
| 148 | + * @return array |
| 149 | + */ |
| 150 | +function ableplayer_default_settings() { |
| 151 | + return array(); |
| 152 | +} |
| 153 | + |
112 | 154 | /** |
113 | 155 | * Self-documenting array of AblePlayer attributes. |
114 | 156 | * |
|
517 | 559 | </div> |
518 | 560 |
|
519 | 561 | <nav> |
520 | | - <h2><a href="index.html">Home</a></h2><h3>Filters</h3><ul><li><a href="able_player_css.html">able_player_css</a></li><li><a href="able_player_js.html">able_player_js</a></li><li><a href="ableplayer_parameters.html">ableplayer_parameters</a></li></ul> |
| 562 | + <h2><a href="index.html">Home</a></h2><h3>Filters</h3><ul><li><a href="able_player_css.html">able_player_css</a></li><li><a href="able_player_js.html">able_player_js</a></li><li><a href="ableplayer_dependencies.html">ableplayer_dependencies</a></li><li><a href="ableplayer_parameters.html">ableplayer_parameters</a></li></ul> |
521 | 563 | </nav> |
522 | 564 |
|
523 | 565 | <br class="clear"> |
|
0 commit comments