2121 * @return array|mixed The full settings array or a specific setting value.
2222 */
2323function ableplayer_get_settings ( $ setting = '' ) {
24- $ settings = get_option ( 'ableplayer_settings ' , array () );
25- $ settings = array_merge ( $ settings , ableplayer_default_settings () );
24+ $ settings = get_option ( 'ableplayer_settings ' , ableplayer_default_settings () );
25+ $ settings = array_merge ( ableplayer_default_settings (), $ settings );
2626 if ( $ setting && isset ( $ settings [ $ setting ] ) ) {
2727 return $ settings [ $ setting ];
2828 }
@@ -133,7 +133,7 @@ function ableplayer_settings_field( $args = array() ) {
133133 case 'email ' :
134134 if ( $ note ) {
135135 $ note = sprintf ( str_replace ( '% ' , '' , $ note ), "<code> $ value</code> " );
136- $ note = "<span id=' $ id-note' class='mc -input-description'><i class='dashicons dashicons-editor-help' aria-hidden='true'></i> $ note</span> " ;
136+ $ note = "<span id=' $ id-note' class='ableplayer -input-description'><i class='dashicons dashicons-editor-help' aria-hidden='true'></i> $ note</span> " ;
137137 $ aria = " aria-describedby=' $ id-note' " ;
138138 } else {
139139 $ note = '' ;
@@ -149,7 +149,7 @@ function ableplayer_settings_field( $args = array() ) {
149149 case 'textarea ' :
150150 if ( $ note ) {
151151 $ note = sprintf ( $ note , "<code> $ value</code> " );
152- $ note = "<span id=' $ id-note' class='mc -input-description'><i class='dashicons dashicons-editor-help' aria-hidden='true'></i> $ note</span> " ;
152+ $ note = "<span id=' $ id-note' class='ableplayer -input-description'><i class='dashicons dashicons-editor-help' aria-hidden='true'></i> $ note</span> " ;
153153 $ aria = " aria-describedby=' $ id-note' " ;
154154 } else {
155155 $ note = '' ;
@@ -160,7 +160,7 @@ function ableplayer_settings_field( $args = array() ) {
160160 case 'checkbox-single ' :
161161 $ checked = checked ( 'true ' , ableplayer_get_settings ( $ name ), false );
162162 if ( $ note ) {
163- $ note = "<div id=' $ id-note' class='mc -input-description'><i class='dashicons dashicons-editor-help' aria-hidden='true'></i> " . sprintf ( $ note , "<code> $ value</code> " ) . '</div> ' ;
163+ $ note = "<div id=' $ id-note' class='ableplayer -input-description'><i class='dashicons dashicons-editor-help' aria-hidden='true'></i> " . sprintf ( $ note , "<code> $ value</code> " ) . '</div> ' ;
164164 $ aria = " aria-describedby=' $ id-note' " ;
165165 } else {
166166 $ note = '' ;
@@ -172,7 +172,7 @@ function ableplayer_settings_field( $args = array() ) {
172172 case 'radio ' :
173173 if ( $ note ) {
174174 $ note = sprintf ( $ note , "<code> $ value</code> " );
175- $ note = "<span id=' $ id-note' class='mc -input-description'><i class='dashicons dashicons-editor-help' aria-hidden='true'></i> $ note</span> " ;
175+ $ note = "<span id=' $ id-note' class='ableplayer -input-description'><i class='dashicons dashicons-editor-help' aria-hidden='true'></i> $ note</span> " ;
176176 $ aria = " aria-describedby=' $ id-note' " ;
177177 } else {
178178 $ note = '' ;
@@ -197,7 +197,7 @@ function ableplayer_settings_field( $args = array() ) {
197197 case 'select ' :
198198 if ( $ note ) {
199199 $ note = sprintf ( $ note , "<code> $ value</code> " );
200- $ note = "<span id=' $ id-note' class='mc -input-description'><i class='dashicons dashicons-editor-help' aria-hidden='true'></i> $ note</span> " ;
200+ $ note = "<span id=' $ id-note' class='ableplayer -input-description'><i class='dashicons dashicons-editor-help' aria-hidden='true'></i> $ note</span> " ;
201201 $ aria = " aria-describedby=' $ id-note' " ;
202202 } else {
203203 $ note = '' ;
@@ -237,7 +237,7 @@ function ableplayer_update_options( $settings ) {
237237 return false ;
238238 }
239239 $ defaults = ableplayer_default_settings ();
240- $ options = get_option ( 'ableplayer_settings ' , ableplayer_default_settings () );
240+ $ options = get_option ( 'ableplayer_settings ' );
241241 if ( ! is_array ( $ options ) ) {
242242 $ options = $ defaults ;
243243 }
@@ -256,10 +256,20 @@ function ableplayer_update_settings( $post ) {
256256 $ replace_video = ( ! empty ( $ post ['replace_video ' ] ) && 'on ' === $ post ['replace_video ' ] ) ? 'true ' : 'false ' ;
257257 $ replace_audio = ( ! empty ( $ post ['replace_audio ' ] ) && 'on ' === $ post ['replace_audio ' ] ) ? 'true ' : 'false ' ;
258258 $ replace_playlists = ( ! empty ( $ post ['replace_playlists ' ] ) && 'on ' === $ post ['replace_playlists ' ] ) ? 'true ' : 'false ' ;
259+ $ youtube_nocookie = ( ! empty ( $ post ['youtube_nocookie ' ] ) && 'on ' === $ post ['youtube_nocookie ' ] ) ? 'true ' : 'false ' ;
260+ $ hide_controls = ( ! empty ( $ post ['hide_controls ' ] ) && 'on ' === $ post ['hide_controls ' ] ) ? 'true ' : 'false ' ;
261+ $ default_speed = ( isset ( $ post ['default_speed ' ] ) ) ? $ post ['default_speed ' ] : 'animals ' ;
262+ $ default_heading = ( isset ( $ post ['default_heading ' ] ) ) ? $ post ['default_heading ' ] : 'auto ' ;
263+ $ default_poster = ( isset ( $ post ['default_poster_id ' ] ) ) ? absint ( $ post ['default_poster_id ' ] ) : '' ;
259264
260265 $ settings ['replace_video ' ] = $ replace_video ;
261266 $ settings ['replace_audio ' ] = $ replace_audio ;
262267 $ settings ['replace_playlists ' ] = $ replace_playlists ;
268+ $ settings ['youtube_nocookie ' ] = $ youtube_nocookie ;
269+ $ settings ['hide_controls ' ] = $ hide_controls ;
270+ $ settings ['default_speed ' ] = $ default_speed ;
271+ $ settings ['default_heading ' ] = $ default_heading ;
272+ $ settings ['default_poster ' ] = $ default_poster ;
263273
264274 ableplayer_update_options ( $ settings );
265275}
@@ -376,7 +386,7 @@ function ableplayer_settings_form() {
376386 ableplayer_settings_field (
377387 array (
378388 'name ' => 'hide_controls ' ,
379- 'label ' => __ ( 'Hide controls when not interacting with player ' , 'ableplayer ' ),
389+ 'label ' => __ ( 'Visually hide controls during playback ' , 'ableplayer ' ),
380390 'type ' => 'checkbox-single ' ,
381391 )
382392 );
@@ -390,10 +400,11 @@ function ableplayer_settings_form() {
390400 'label ' => __ ( 'Default hidden heading level ' , 'ableplayer ' ),
391401 'type ' => 'select ' ,
392402 'default ' => array (
393- 'auto ' => 'Automatically set ' ,
394- 'h2 ' => 'H2 ' ,
395- 'h3 ' => 'H3 ' ,
396- 'h4 ' => 'H4 ' ,
403+ 'auto ' => __ ( 'Automatically set ' , 'ableplayer ' ),
404+ '0 ' => __ ( 'No heading ' , 'ableplayer ' ),
405+ '2 ' => 'H2 ' ,
406+ '3 ' => 'H3 ' ,
407+ '4 ' => 'H4 ' ,
397408 )
398409 )
399410 );
0 commit comments