پرش به محتویات

کنترل Audio

کنترل Audio به شما امکان می‌دهد یک فایل صوتی را از کتابخانه رسانه انتخاب کنید. همچنین گزینه‌های مختلفی برای نمایش/مخفی کردن هنرمند و عنوان، انتخاب بین تم روشن/تاریک، پخش خودکار فایل صوتی و غیره در اختیار شما قرار می‌دهد. هیچ پارامتر کنترلی سفارشی ندارد.

class Prefix_Element_Audio extends \Bricks\Element {
  // Set builder controls
  public function set_controls() {
    $this->controls['file'] = [
      'tab' => 'content',
      'label' => esc_html__( 'Audio file', 'bricks' ),
      'type' => 'audio',
    ];
  }

  // Render element HTML
  public function render() {
    $settings = $this->settings;

    if ( isset( $settings['file']['url'] ) ) {
      echo wp_audio_shortcode( [
        'src'      => $settings['file']['url'],
        'loop'     => isset( $settings['loop'] ) ? $settings['loop'] : false,
        'autoplay' => isset( $settings['autoplay'] ) ? $settings['autoplay'] : false,
        'preload'  => isset( $settings['preload'] ) ? $settings['preload'] : 'none',
      ] );
    }
  }
}

منابع

https://codex.wordpress.org/Function_Reference/wp_audio_shortcode