"; $element = ''; $close = ''; if ( ! empty( $wrap ) ) { $el = isset( $wrap['element'] ) ? $wrap['element'] : 'p'; $class = ''; $id = ''; if ( isset( $wrap['class'] ) && '' !== $wrap['class'] ) { $class = ' class="' . $wrap['class'] . '"'; } if ( isset( $wrap['id'] ) && '' !== $wrap['id'] ) { $id = ' id="' . $wrap['id'] . '"'; } $element = "<$el$class$id>"; $close = ""; } $options = ''; $attributes = ''; $return = ''; if ( 'text' === $type || 'url' === $type || 'email' === $type ) { $base_atts = array( 'size' => '30', ); } else { $base_atts = $atts; } $value = ableplayer_get_settings( $name ); $value = ( 'generator' === $context && ! is_string( $value ) ) ? '' : $value; $atts = array_merge( $base_atts, $atts ); if ( is_array( $atts ) && ! empty( $atts ) ) { foreach ( $atts as $key => $val ) { $attributes .= " $key='" . esc_attr( $val ) . "'"; } } if ( 'checkbox' !== $type ) { if ( is_array( $default ) ) { $hold = ''; } else { $hold = $default; } $value = ( '' !== $value ) ? esc_attr( wp_unslash( $value ) ) : $hold; } else { $value = ( ! empty( $value ) ) ? (array) $value : $default; } switch ( $type ) { case 'text': case 'url': case 'email': case 'number': if ( $note ) { $note = sprintf( str_replace( '%', '', $note ), "$value" ); $note = "$help_icon$note"; $aria = " aria-describedby='$id-note'"; } else { $note = ''; $aria = ''; } $note_top = ( 'top' === $position ) ? $note : ''; $note_bottom = ( 'bottom' === $position ) ? $note : ''; $return = "$element $note_top $close $note_bottom"; break; case 'hidden': $return = ""; break; case 'textarea': if ( $note ) { $note = sprintf( $note, "$value" ); $note = "$help_icon$note"; $aria = " aria-describedby='$id-note'"; } else { $note = ''; $aria = ''; } $return = "$element
$close$note"; break; case 'checkbox-single': $checked = checked( 'true', ableplayer_get_settings( $name ), false ); if ( $note ) { $note = "$help_icon" . sprintf( $note, "$value" ) . ''; $aria = " aria-describedby='$id-note'"; } else { $note = ''; $aria = ''; } $return = "$element $close$note"; break; case 'checkbox': case 'radio': if ( $note ) { $note = sprintf( $note, "$value" ); $note = "$help_icon$note"; $aria = " aria-describedby='$id-note'"; } else { $note = ''; $aria = ''; } $att_name = $name; if ( 'checkbox' === $type ) { $att_name = $name . '[]'; } if ( is_array( $label ) ) { foreach ( $label as $k => $v ) { if ( 'radio' === $type ) { $checked = ( $k === $value ) ? ' checked="checked"' : ''; } else { $checked = ( in_array( $k, $value, true ) ) ? ' checked="checked"' : ''; } $options .= "
  • $element $close
  • "; } } $return = "$options $note"; break; case 'select': if ( $note ) { $note = sprintf( $note, "$value" ); $note = "$help_icon$note"; $aria = " aria-describedby='$id-note'"; } else { $note = ''; $aria = ''; } if ( is_array( $default ) ) { foreach ( $default as $k => $v ) { $checked = ( (string) $k === (string) $value ) ? ' selected="selected"' : ''; $options .= ""; } } $return = " $element$close $note"; break; } if ( true === $echo ) { echo wp_kses( $return, ableplayer_kses_elements() ); } else { return $return; } } /** * Save a group of Able Player settings. * * @param array $settings An array of settings. * * @return bool */ function ableplayer_update_options( $settings ) { if ( empty( $settings ) ) { return false; } $defaults = ableplayer_default_settings(); $options = get_option( 'ableplayer_settings' ); if ( ! is_array( $options ) ) { $options = $defaults; } $settings = array_merge( $options, $settings ); return update_option( 'ableplayer_settings', $settings ); } /** * Update Able Player settings. * * @param array $post POST data. */ function ableplayer_update_settings( $post ) { $settings = array(); $replace_video = ( ! empty( $post['replace_video'] ) && 'on' === $post['replace_video'] ) ? 'true' : 'false'; $replace_youtube = ( ! empty( $post['replace_youtube'] ) && 'on' === $post['replace_youtube'] ) ? 'true' : 'false'; $replace_audio = ( ! empty( $post['replace_audio'] ) && 'on' === $post['replace_audio'] ) ? 'true' : 'false'; $exclude_class = ( ! empty( $post['exclude_class'] ) ) ? sanitize_text_field( $post['exclude_class'] ) : ''; $replace_playlists = ( ! empty( $post['replace_playlists'] ) && 'on' === $post['replace_playlists'] ) ? 'true' : 'false'; $disable_elements = ( ! empty( $post['disable_elements'] ) && 'on' === $post['disable_elements'] ) ? 'true' : 'false'; $youtube_nocookie = ( ! empty( $post['youtube_nocookie'] ) && 'on' === $post['youtube_nocookie'] ) ? 'true' : 'false'; $play_inline = ( ! empty( $post['play_inline'] ) && 'on' === $post['play_inline'] ) ? 'true' : 'false'; $render_transcript = ( ! empty( $post['render_transcript'] ) && 'on' === $post['render_transcript'] ) ? 'true' : 'false'; $hide_controls = ( ! empty( $post['hide_controls'] ) && 'on' === $post['hide_controls'] ) ? 'true' : 'false'; $default_speed = ( isset( $post['default_speed'] ) ) ? $post['default_speed'] : 'animals'; $seek_interval = ( isset( $post['seek_interval'] ) && $post['seek_interval'] > 5 ) ? absint( $post['seek_interval'] ) : ''; $default_heading = ( isset( $post['default_heading'] ) && 'auto' !== $post['default_heading'] ) ? absint( $post['default_heading'] ) : 'auto'; $vimeo = ( ! empty( $post['vimeo'] ) && 'on' === $post['vimeo'] ) ? 'true' : 'false'; $cookies = ( ! empty( $post['cookies'] ) && 'on' === $post['cookies'] ) ? 'true' : 'false'; $settings['replace_video'] = $replace_video; $settings['replace_youtube'] = $replace_youtube; $settings['replace_audio'] = $replace_audio; $settings['exclude_class'] = $exclude_class; $settings['replace_playlists'] = $replace_playlists; $settings['disable_elements'] = $disable_elements; $settings['youtube_nocookie'] = $youtube_nocookie; $settings['seek_interval'] = $seek_interval; $settings['play_inline'] = $play_inline; $settings['render_transcript'] = $render_transcript; $settings['hide_controls'] = $hide_controls; $settings['default_speed'] = $default_speed; $settings['default_heading'] = $default_heading; $settings['vimeo'] = $vimeo; $settings['cookies'] = $cookies; ableplayer_update_options( $settings ); } /** * Build Able Player settings form. */ function ableplayer_settings_form() { if ( ! empty( $_POST ) ) { $nonce = $_REQUEST['_wpnonce']; if ( ! wp_verify_nonce( $nonce, 'ableplayer-nonce' ) ) { wp_die( 'Able Player: Security check failed' ); } $post = map_deep( $_POST, 'sanitize_textarea_field' ); if ( isset( $post['ableplayer_settings'] ) ) { ableplayer_update_settings( $post ); wp_admin_notice( __( 'Able Player Default Settings saved', 'ableplayer' ), array( 'type' => 'success', ) ); } } ?>

    'vimeo', 'label' => __( 'Load the Vimeo player scripts globally.', 'ableplayer' ), 'type' => 'checkbox-single', 'note' => __( 'Required to play media from Vimeo outside of the AblePlayer shortcode.', 'ableplayer' ), ) ); ?>

    'cookies', 'label' => __( 'Store user settings in cookies.', 'ableplayer' ), 'type' => 'checkbox-single', 'note' => __( 'Required if you need to access user settings from server-side code.', 'ableplayer' ), ) ); ?>

    'replace_video', 'label' => __( 'Use Able Player for all video elements.', 'ableplayer' ), 'type' => 'checkbox-single', 'note' => __( 'Does not replace Vimeo or YouTube Embed blocks', 'ableplayer' ), ) ); ?>

    'replace_youtube', 'label' => __( 'Use Able Player for all YouTube Embed blocks.', 'ableplayer' ), 'type' => 'checkbox-single', ) ); ?>

    'replace_audio', 'label' => __( 'Use Able Player for all audio elements.', 'ableplayer' ), 'type' => 'checkbox-single', ) ); ?>

    'exclude_class', 'label' => __( 'Exclude class from Able Player parsing', 'ableplayer' ), 'note' => __( 'Disable Able Player on video or audio elements with this class or with a parent element with the class.', 'ableplayer' ), 'type' => 'text', ) ); ?>

    'replace_playlists', 'label' => __( 'Use Able Player for WordPress media playlists.', 'ableplayer' ), 'type' => 'checkbox-single', ) ); ?>

    'disable_elements', 'label' => __( 'Disable MediaElement JS.', 'ableplayer' ), 'type' => 'checkbox-single', 'note' => __( 'Recommended if using any element replacement options.', 'ableplayer' ), ) ); ?>

    'youtube_nocookie', 'label' => __( 'Set YouTube videos to use the nocookie parameter for increased privacy.', 'ableplayer' ), 'type' => 'checkbox-single', ) ); ?>

    'play_inline', 'label' => __( 'Force mobile devices to play inline, instead of using their own media player.', 'ableplayer' ), 'type' => 'checkbox-single', ) ); ?>

    'render_transcript', 'label' => __( 'Insert interactive transcript container.', 'ableplayer' ), 'type' => 'checkbox-single', ) ); ?>

    'default_speed', 'label' => __( 'Preferred speed control icon', 'ableplayer' ), 'type' => 'select', 'default' => array( 'animals' => __( 'Animals: Tortoise and Hare', 'ableplayer' ), 'arrows' => __( 'Arrows', 'ableplayer' ), ), ) ); ?>

    'seek_interval', 'label' => __( 'Default seek interval in seconds.', 'ableplayer' ), 'type' => 'number', 'atts' => array( 'min' => 5, 'step' => 5, ), ) ); ?>

    'hide_controls', 'label' => __( 'Visually hide controls during playback', 'ableplayer' ), 'type' => 'checkbox-single', ) ); ?>

    'default_heading', 'label' => __( 'Default hidden heading level', 'ableplayer' ), 'type' => 'select', 'default' => array( 'auto' => __( 'Automatically set', 'ableplayer' ), '0' => __( 'No heading', 'ableplayer' ), '2' => 'H2', '3' => 'H3', '4' => 'H4', ), ) ); ?>

    Able Player accessible media player.', 'ableplayer' ), 'https://ableplayer.github.io/ableplayer/' ) ); ?>

    Sponsor Joe Dolson, Able Player lead developer.', 'ableplayer' ), 'https://www.joedolson.com/donate/' ) ); ?>

    'false', 'replace_youtube' => 'false', 'replace_audio' => 'false', 'exclude_class' => '', 'replace_playlists' => 'false', 'disable_elements' => 'false', 'youtube_nocookie' => 'false', 'play_inline' => 'true', 'render_transcript' => 'true', 'default_speed' => 'animals', 'seek_interval' => '30', 'hide_controls' => 'false', 'default_heading' => 'auto', 'last_shortcode' => '', 'vimeo' => 'false', 'cookies' => 'false', ); return $settings; }