about-widget.php
5 months ago
accordion-widget.php
1 month ago
accordion.php
5 months ago
attachment-url.php
5 months ago
audio.php
5 months ago
before-after.php
5 months ago
button.php
5 months ago
code.php
5 months ago
contact-box.php
5 months ago
contact-form.php
5 months ago
custom-list.php
5 months ago
divider.php
5 months ago
dropcap.php
5 months ago
facebook.php
5 months ago
flickr.php
5 months ago
gallery.php
5 months ago
gmap.php
5 months ago
highlight.php
5 months ago
image.php
5 months ago
instagram-feed.php
5 months ago
latest-posts-slider.php
5 months ago
popular-posts-widget.php
5 months ago
products-grid.php
5 months ago
quote.php
5 months ago
recent-posts-grid-carousel.php
5 months ago
recent-posts-land-style.php
5 months ago
recent-posts-masonry.php
5 months ago
recent-posts-tiles-carousel.php
5 months ago
recent-posts-tiles.php
5 months ago
recent-posts-timeline.php
5 months ago
recent-posts-widget.php
5 months ago
recent-products.php
5 months ago
related-posts.php
8 years ago
sample-element.php
5 months ago
search.php
5 months ago
socials-list.php
5 months ago
staff.php
5 months ago
tab-widget.php
5 months ago
tabs.php
5 months ago
testimonial.php
5 months ago
text.php
5 months ago
touch-slider.php
5 months ago
video.php
5 months ago
video.php
286 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Video player element |
| 4 | * |
| 5 | * |
| 6 | * @package Auxin |
| 7 | * @license LICENSE.txt |
| 8 | * @author averta |
| 9 | * @link http://phlox.pro/ |
| 10 | * @copyright (c) 2010-2026 averta |
| 11 | */ |
| 12 | function auxin_get_video_master_array( $master_array ) { |
| 13 | |
| 14 | $master_array['aux_video'] = array( |
| 15 | 'name' => __('Video', 'auxin-elements'), |
| 16 | 'auxin_output_callback' => 'auxin_widget_video_callback', |
| 17 | 'base' => 'aux_video', |
| 18 | 'description' => __('It adds a video player element.', 'auxin-elements'), |
| 19 | 'class' => 'aux-widget-video', |
| 20 | 'show_settings_on_create' => true, |
| 21 | 'weight' => 1, |
| 22 | 'category' => THEME_NAME, |
| 23 | 'group' => '', |
| 24 | 'admin_enqueue_js' => '', |
| 25 | 'admin_enqueue_css' => '', |
| 26 | 'front_enqueue_js' => '', |
| 27 | 'front_enqueue_css' => '', |
| 28 | 'icon' => 'aux-element aux-pb-icons-video', |
| 29 | 'custom_markup' => '', |
| 30 | 'js_view' => '', |
| 31 | 'html_template' => '', |
| 32 | 'deprecated' => '', |
| 33 | 'content_element' => '', |
| 34 | 'as_parent' => '', |
| 35 | 'as_child' => '', |
| 36 | 'params' => array( |
| 37 | array( |
| 38 | 'heading' => __('Title','auxin-elements'), |
| 39 | 'description' => __('Video title, leave it empty if you don`t need title.', 'auxin-elements'), |
| 40 | 'param_name' => 'title', |
| 41 | 'type' => 'textfield', |
| 42 | 'value' => '', |
| 43 | 'holder' => 'textfield', |
| 44 | 'class' => 'title', |
| 45 | 'admin_label' => false, |
| 46 | 'dependency' => '', |
| 47 | 'weight' => '', |
| 48 | 'group' => '', |
| 49 | 'edit_field_class' => '' |
| 50 | ), |
| 51 | array( |
| 52 | 'heading' => __('Autoplay','auxin-elements'), |
| 53 | 'description' => __('Whether to start the video automatically or not.','auxin-elements'), |
| 54 | 'param_name' => 'autoplay', |
| 55 | 'type' => 'aux_switch', |
| 56 | 'value' => '0', |
| 57 | 'class' => 'autoplay', |
| 58 | 'admin_label' => false, |
| 59 | 'dependency' => '', |
| 60 | 'weight' => '', |
| 61 | 'group' => '', |
| 62 | 'edit_field_class' => '' |
| 63 | ), |
| 64 | array( |
| 65 | 'heading' => __('Repeat video','auxin-elements'), |
| 66 | 'description' => __('Play video again when it ends.','auxin-elements'), |
| 67 | 'param_name' => 'loop', |
| 68 | 'type' => 'aux_switch', |
| 69 | 'value' => '0', |
| 70 | 'class' => 'loop', |
| 71 | 'admin_label' => true, |
| 72 | 'dependency' => '', |
| 73 | 'weight' => '', |
| 74 | 'group' => '', |
| 75 | 'edit_field_class' => '' |
| 76 | ), |
| 77 | array( |
| 78 | 'heading' => __('Width','auxin-elements'), |
| 79 | 'description' => __('Width size of video in pixel.','auxin-elements'), |
| 80 | 'param_name' => 'width', |
| 81 | 'type' => 'textfield', |
| 82 | 'value' => '1200', |
| 83 | 'holder' => '', |
| 84 | 'class' => '', |
| 85 | 'admin_label' => false, |
| 86 | 'dependency' => '', |
| 87 | 'weight' => '', |
| 88 | 'group' => __( 'Style', 'auxin-elements' ), |
| 89 | 'edit_field_class' => '' |
| 90 | ), |
| 91 | array( |
| 92 | 'heading' => __('Height','auxin-elements'), |
| 93 | 'description' => __('Height size of video in pixel.','auxin-elements'), |
| 94 | 'param_name' => 'height', |
| 95 | 'type' => 'textfield', |
| 96 | 'value' => '675', |
| 97 | 'holder' => '', |
| 98 | 'class' => '', |
| 99 | 'admin_label' => false, |
| 100 | 'dependency' => '', |
| 101 | 'weight' => '', |
| 102 | 'group' => __( 'Style', 'auxin-elements' ), |
| 103 | 'edit_field_class' => '' |
| 104 | ), |
| 105 | array( |
| 106 | 'heading' => __('Video file','auxin-elements'), |
| 107 | 'description' => __('Please upload the video file.','auxin-elements'), |
| 108 | 'param_name' => 'src', |
| 109 | 'type' => 'aux_select_video', |
| 110 | 'value' => '', |
| 111 | 'holder' => '', |
| 112 | 'class' => '', |
| 113 | 'admin_label' => false, |
| 114 | 'dependency' => '', |
| 115 | 'weight' => '', |
| 116 | 'group' => '', |
| 117 | 'edit_field_class' => '' |
| 118 | ), |
| 119 | array( |
| 120 | 'heading' => __('Video link','auxin-elements'), |
| 121 | 'description' => __('Youtube, Vimeo or any video embed link.','auxin-elements'), |
| 122 | 'param_name' => 'url', |
| 123 | 'type' => 'textfield', |
| 124 | 'value' => '', |
| 125 | 'holder' => '', |
| 126 | 'class' => '', |
| 127 | 'admin_label' => false, |
| 128 | 'dependency' => '', |
| 129 | 'weight' => '', |
| 130 | 'group' => '', |
| 131 | 'edit_field_class' => '' |
| 132 | ), |
| 133 | array( |
| 134 | 'heading' => __('Video poster','auxin-elements'), |
| 135 | 'description' => __('An image that represents the video content.','auxin-elements'), |
| 136 | 'param_name' => 'poster', |
| 137 | 'type' => 'textfield', |
| 138 | 'value' => '', |
| 139 | 'holder' => '', |
| 140 | 'class' => '', |
| 141 | 'admin_label' => false, |
| 142 | 'dependency' => '', |
| 143 | 'weight' => '', |
| 144 | 'group' => '', |
| 145 | 'edit_field_class' => '' |
| 146 | ), |
| 147 | array( |
| 148 | 'heading' => __('Player skin','auxin-elements'), |
| 149 | 'description' => __('Specifies skin for the player.','auxin-elements'), |
| 150 | 'param_name' => 'skin', |
| 151 | 'type' => 'aux_visual_select', |
| 152 | 'def_value' => 'dark', |
| 153 | 'choices' => array( |
| 154 | 'dark' => array( |
| 155 | 'label' => __('Dark', 'auxin-elements'), |
| 156 | 'image' => AUXIN_URL . 'images/visual-select/audio-player-dark.svg' |
| 157 | ), |
| 158 | 'light' => array( |
| 159 | 'label' => __('Light', 'auxin-elements'), |
| 160 | 'image' => AUXIN_URL . 'images/visual-select/audio-player-light.svg' |
| 161 | ) |
| 162 | ), |
| 163 | 'holder' => '', |
| 164 | 'class' => 'skin', |
| 165 | 'admin_label' => true, |
| 166 | 'dependency' => '', |
| 167 | 'weight' => '', |
| 168 | 'group' => __( 'Style', 'auxin-elements' ), |
| 169 | 'edit_field_class' => '' |
| 170 | ), |
| 171 | array( |
| 172 | 'heading' => __('Extra class name','auxin-elements'), |
| 173 | 'description' => __('If you wish to style particular content element differently, then use this field to add a class name and then refer to it in your css file.', 'auxin-elements'), |
| 174 | 'param_name' => 'extra_classes', |
| 175 | 'type' => 'textfield', |
| 176 | 'value' => '', |
| 177 | 'holder' => '', |
| 178 | 'class' => 'extra_classes', |
| 179 | 'admin_label' => false, |
| 180 | 'dependency' => '', |
| 181 | 'weight' => '', |
| 182 | 'group' => '', |
| 183 | 'edit_field_class' => '' |
| 184 | ) |
| 185 | |
| 186 | ) |
| 187 | ); |
| 188 | |
| 189 | return $master_array; |
| 190 | } |
| 191 | |
| 192 | add_filter( 'auxin_master_array_shortcodes', 'auxin_get_video_master_array', 10, 1 ); |
| 193 | |
| 194 | |
| 195 | |
| 196 | |
| 197 | function auxin_widget_video_callback( $atts, $shortcode_content = null ){ |
| 198 | global $content_width; |
| 199 | |
| 200 | // Defining default attributes |
| 201 | $default_atts = array( |
| 202 | 'title' => '', // header title |
| 203 | |
| 204 | 'autoplay' => '', // play video automatically |
| 205 | 'loop' => '', // loop video |
| 206 | 'preload' => 'metadata', |
| 207 | 'width' => '1200', // default video size |
| 208 | 'height' => '675', // default video height |
| 209 | 'url' => '', // embed video link |
| 210 | 'src' => '', // quick set for mp4 file |
| 211 | 'poster' => '', |
| 212 | 'skin' => 'dark', // dark or light |
| 213 | |
| 214 | 'extra_classes' => '', // custom css class names for this element |
| 215 | 'custom_el_id' => '', // custom id attribute for this element |
| 216 | 'base_class' => 'aux-widget-video' // base class name for container |
| 217 | ); |
| 218 | |
| 219 | $result = auxin_get_widget_scafold( $atts, $default_atts, $shortcode_content ); |
| 220 | extract( $result['parsed_atts'] ); |
| 221 | |
| 222 | ob_start(); |
| 223 | |
| 224 | // widget header ------------------------------ |
| 225 | echo wp_kses_post( $result['widget_header'] ); |
| 226 | echo wp_kses_post( $result['widget_title'] ); |
| 227 | |
| 228 | if( empty( $skin ) ){ |
| 229 | $skin = 'light'; |
| 230 | } |
| 231 | |
| 232 | if( empty( $width ) ) { |
| 233 | $width = $content_width; |
| 234 | } |
| 235 | |
| 236 | if( empty( $height ) ) { |
| 237 | $height = round( ( 360 * $content_width ) / 640 ); |
| 238 | } |
| 239 | |
| 240 | $class = 'wp-video-shortcode aux-player-' . esc_attr( $skin ); |
| 241 | |
| 242 | // convert attachment id to url |
| 243 | if( is_numeric( $src ) ){ |
| 244 | $src = wp_get_attachment_url( $src ); |
| 245 | } |
| 246 | |
| 247 | // convert attachment id to url |
| 248 | if( is_numeric( $poster ) ){ |
| 249 | $poster = wp_get_attachment_url( $poster ); |
| 250 | } |
| 251 | |
| 252 | if( $provider = auxin_extract_embed_provider_name( $src ) ){ |
| 253 | $class .= ' aux-provider-'. $provider; |
| 254 | } |
| 255 | |
| 256 | if( ! empty( $src ) ){ |
| 257 | |
| 258 | $poster = auxin_aq_resize( $poster, $width, $height, true, 100, true, false ); |
| 259 | |
| 260 | echo wp_video_shortcode( |
| 261 | array( |
| 262 | 'src' => $src, |
| 263 | 'class' => $class, |
| 264 | 'width' => $width, |
| 265 | 'height' => $height, |
| 266 | 'poster' => $poster, |
| 267 | 'loop' => auxin_is_true( $loop ), |
| 268 | 'autoplay' => auxin_is_true( $autoplay ), |
| 269 | 'preload' => $preload, |
| 270 | ) |
| 271 | ); |
| 272 | |
| 273 | } elseif( ! empty( $url ) ){ |
| 274 | |
| 275 | echo wp_oembed_get( $url, array( |
| 276 | 'width' => $width, |
| 277 | 'height' => $height |
| 278 | )); |
| 279 | } |
| 280 | |
| 281 | // widget footer ------------------------------ |
| 282 | echo wp_kses_post( $result['widget_footer'] ); |
| 283 | |
| 284 | return ob_get_clean(); |
| 285 | } |
| 286 |