@@ -48,7 +48,13 @@ function ableplayer_enqueue_scripts() {
4848 wp_enqueue_script ( 'js-cookie ' , plugins_url ( 'thirdparty ' , __FILE__ ) . '/js.cookie.js ' , array ( 'jquery ' ), ABLEPLAYER_VERSION , true );
4949 wp_enqueue_script ( 'vimeo ' , 'https://player.vimeo.com/api/player.js ' , array (), ABLEPLAYER_VERSION , true );
5050 wp_register_script ( 'ableplayer-video ' , plugins_url ( 'assets ' , __FILE__ ) . '/js/video.js ' , array (), ABLEPLAYER_VERSION , true );
51-
51+ wp_localize_script (
52+ 'ableplayer-video ' ,
53+ 'ableplayer ' ,
54+ array (
55+ 'settings ' => ableplayer_get_settings (),
56+ )
57+ );
5258 // if the environment is production, use minified files. Otherwise, inherit the value of SCRIPT_DEBUG.
5359 $ is_production = ( function_exists ( 'wp_get_environment_type ' ) && wp_get_environment_type () === 'production ' ) ? true : SCRIPT_DEBUG ;
5460
@@ -77,9 +83,7 @@ function ableplayer_enqueue_scripts() {
7783 */
7884 $ css_dir = apply_filters ( 'able_player_css ' , plugins_url ( 'build ' , __FILE__ ) . '/ ' . $ css_file , $ is_production );
7985
80- // Enqueue Able Player script and CSS.
8186 $ dependencies = array ( 'jquery ' , 'ableplayer-video ' );
82- $ js_dir = apply_filters ( 'able_player_js ' , plugins_url ( 'build ' , __FILE__ ) . '/ ' . $ js_file , $ is_production );
8387 /**
8488 * Filter the Able Player script dependencies.
8589 *
@@ -96,6 +100,31 @@ function ableplayer_enqueue_scripts() {
96100}
97101add_action ( 'wp_enqueue_scripts ' , 'ableplayer_enqueue_scripts ' );
98102
103+ /**
104+ * Get Able Player settings.
105+ *
106+ * @param string $setting A specific setting key. Default empty string.
107+ *
108+ * @return array|mixed The full settings array or a specific setting value.
109+ */
110+ function ableplayer_get_settings ( $ setting = '' ) {
111+ $ settings = get_option ( 'ableplayer_settings ' , ableplayer_default_settings () );
112+ if ( $ setting && isset ( $ settings [ $ setting ] ) ) {
113+ return $ settings [ $ setting ];
114+ }
115+
116+ return $ settings ;
117+ }
118+
119+ /**
120+ * Get Able Player default settings.
121+ *
122+ * @return array
123+ */
124+ function ableplayer_default_settings () {
125+ return array ();
126+ }
127+
99128/**
100129 * Self-documenting array of AblePlayer attributes.
101130 *
0 commit comments