register_frontend_scripts( $frontend_scripts ); $this->register_frontend_styles( array( array( 'sow-slider-slider', plugin_dir_url( SOW_BUNDLE_BASE_FILE ) . 'css/slider/slider.css', array(), SOW_BUNDLE_VERSION ) ) ); } /** * The control array required for the slider * * @return array */ function control_form_fields(){ return array( 'speed' => array( 'type' => 'number', 'label' => __('Animation speed', 'so-widgets-bundle'), 'description' => __('Animation speed in milliseconds.', 'so-widgets-bundle'), 'default' => 800, ), 'timeout' => array( 'type' => 'number', 'label' => __('Timeout', 'so-widgets-bundle'), 'description' => __('How long each frame is displayed for in milliseconds.', 'so-widgets-bundle'), 'default' => 8000, ), 'nav_color_hex' => array( 'type' => 'color', 'label' => __('Navigation color', 'so-widgets-bundle'), 'default' => '#FFFFFF', ), 'nav_style' => array( 'type' => 'select', 'label' => __('Navigation style', 'so-widgets-bundle'), 'default' => 'thin', 'options' => array( 'ultra-thin' => __('Ultra thin', 'so-widgets-bundle'), 'thin' => __('Thin', 'so-widgets-bundle'), 'medium' => __('Medium', 'so-widgets-bundle'), 'thick' => __('Thick', 'so-widgets-bundle'), 'ultra-thin-rounded' => __('Rounded ultra thin', 'so-widgets-bundle'), 'thin-rounded' => __('Rounded thin', 'so-widgets-bundle'), 'medium-rounded' => __('Rounded medium', 'so-widgets-bundle'), 'thick-rounded' => __('Rounded thick', 'so-widgets-bundle'), ) ), 'nav_size' => array( 'type' => 'number', 'label' => __('Navigation size', 'so-widgets-bundle'), 'default' => '25', ), 'swipe' => array( 'type' => 'checkbox', 'label' => __( 'Swipe Control', 'so-widgets-bundle' ), 'description' => __( 'Allow users to swipe through frames on mobile devices.', 'so-widgets-bundle' ), 'default' => true, ) ); } function video_form_fields(){ return array( 'file' => array( 'type' => 'media', 'library' => 'video', 'label' => __('Video file', 'so-widgets-bundle'), ), 'url' => array( 'type' => 'text', 'sanitize' => 'url', 'label' => __('Video URL', 'so-widgets-bundle'), 'optional' => 'true', 'description' => __('An external URL of the video. Overrides video file.', 'so-widgets-bundle') ), 'format' => array( 'type' => 'select', 'label' => __('Video format', 'so-widgets-bundle'), 'options' => array( 'video/mp4' => 'MP4', 'video/webm' => 'WebM', 'video/ogg' => 'Ogg', ), ), 'height' => array( 'type' => 'number', 'label' => __( 'Maximum height', 'so-widgets-bundle' ) ), ); } function slider_settings( $controls ){ return array( 'pagination' => true, 'speed' => empty( $controls['speed'] ) ? 1 : $controls['speed'], 'timeout' => $controls['timeout'], 'swipe' => $controls['swipe'], ); } function render_template( $controls, $frames ){ $this->render_template_part('before_slider', $controls, $frames); $this->render_template_part('before_slides', $controls, $frames); foreach( $frames as $i => $frame ) { $this->render_frame( $i, $frame ); } $this->render_template_part('after_slides', $controls, $frames); $this->render_template_part('navigation', $controls, $frames); $this->render_template_part('after_slider', $controls, $frames); } function render_template_part( $part, $controls, $frames ) { switch( $part ) { case 'before_slider': ?>get_frame_background( $i, $frame ), array( 'color' => false, 'image' => false, 'image-width' => 0, 'image-height' => 0, 'opacity' => 1, 'url' => false, 'new_window' => false, 'image-sizing' => 'cover', // options for image sizing are cover and contain 'videos' => false, 'videos-sizing' => 'background', // options for video sizing are background or full ) ); $wrapper_attributes = array( 'class' => array( 'sow-slider-image' ), 'style' => array(), ); if( !empty($background['color']) ) { $wrapper_attributes['style'][] = 'background-color: ' . esc_attr($background['color']); } if( $background['opacity'] >= 1 ) { if( !empty($background['image']) ) { $wrapper_attributes['style'][] = 'background-image: url(' . esc_url($background['image']) . ')'; } } if( ! empty( $background['url'] ) ) { $wrapper_attributes['style'][] = 'cursor: pointer;'; } if( !empty($background['image']) && !empty($background['image-sizing']) ) { $wrapper_attributes['class'][] = ' ' . 'sow-slider-image-' . $background['image-sizing']; } if( !empty( $background['url'] ) ) { $wrapper_attributes['data-url'] = json_encode( array( 'url' => sow_esc_url($background['url']), 'new_window' => !empty( $background['new_window'] ) ) ); } $wrapper_attributes = apply_filters( 'siteorigin_widgets_slider_wrapper_attributes', $wrapper_attributes, $frame, $background ); $wrapper_attributes['class'] = implode( ' ', $wrapper_attributes['class'] ); $wrapper_attributes['style'] = implode( ';', $wrapper_attributes['style'] ); ?>
  • $val ) echo $attr . '="' . esc_attr( $val ) . '" '; ?>> render_frame_contents( $i, $frame ); if( !empty( $background['videos'] ) ) { $this->video_code( $background['videos'], array('sow-' . $background['video-sizing'] . '-element') ); } if( $background['opacity'] < 1 && !empty($background['image']) ) { $overlay_attributes = array( 'class' => array( 'sow-slider-image-overlay', 'sow-slider-image-' . $background['image-sizing'] ), 'style' => array( 'background-image: url(' . $background['image'] . ')', 'opacity: ' . floatval( $background['opacity'] ), ) ); $overlay_attributes = apply_filters( 'siteorigin_widgets_slider_overlay_attributes', $overlay_attributes, $frame, $background ); $overlay_attributes['class'] = implode( ' ', $overlay_attributes['class'] ); $overlay_attributes['style'] = implode( ';', $overlay_attributes['style'] ); ?>
    $val ) echo $attr . '="' . esc_attr( $val ) . '" '; ?> >
  • '; foreach( $videos as $video ) { if( empty( $video['file'] ) && empty ( $video['url'] ) ) continue; // If video is an external file, try and display it using oEmbed if( !empty( $video['url'] ) ) { $args = array(); if ( ! empty( $video['height'] ) ) { $args['height'] = $video['height']; } $embedded_video = wp_oembed_get( $video['url'], $args ); // Check if we can oEmbed the video or not if( !$embedded_video ) { $video_file = sow_esc_url( $video['url'] ); }else{ echo $embedded_video; continue; } } // If $video_file isn't set video is a local file if( !isset( $video_file ) ) { $video_file = wp_get_attachment_url( $video['file'] ); } $video_element .= ''; } if ( strpos( $video_element, 'source' ) !== false ) { $video_element .= ''; echo $video_element; } } }