PluginProbe
Themify Builder / 7.7.6
Themify Builder v7.7.6
7.8.1 7.8.0 7.7.9 7.7.8 7.7.7 7.7.6 7.7.5 7.7.4 7.7.3 7.7.2 trunk 7.6.0 7.6.1 7.6.2 7.6.3 7.6.4 7.6.5 7.6.6 7.6.7 7.6.8 7.6.9 7.7.0 7.7.1
themify-builder / modules / module-video.php

module-video.php in Themify Builder 7.7.6, at modules/module-video.php

68 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 defined('ABSPATH') || exit;
4
5 /**
6 * Module Name: Video
7 * Description: Display Video content
8 */
9 class TB_Video_Module extends Themify_Builder_Component_Module {
10
11 public static function get_module_name():string {
12 return __('Video', 'themify');
13 }
14
15 public static function get_module_icon():string {
16 return 'video-clapper';
17 }
18
19
20 public static function get_js_css():array {
21 return array(
22 'async' => 1,
23 'css' => 1,
24 'js' => 1
25 );
26 }
27
28 /**
29 * Renders the module for Static Content
30 */
31 public static function get_static_content( array $module ):string {
32 $url = ! empty( $module['mod_settings']['url_video'] ) ? esc_url( $module['mod_settings']['url_video'] ) : '';
33 $output = '';
34 if ( $url !== '' ) {
35 if ( strpos( $url, themify_upload_dir( 'baseurl' ) ) === false ) {
36 /* external URL, use WP Embeds */
37 $output = '[embed]' . $url . '[/embed]';
38 } else {
39 /* local video, use [video] shortcode which produces more viewer-friendly output */
40 $size = '';
41 $media_id = themify_get_attachment_id_from_url( $url );
42 if ( $media_id ) {
43 $metadata = wp_get_attachment_metadata( $media_id );
44 if ( ! empty( $metadata['width'] ) && ! empty( $metadata['height'] ) ) {
45 $size = sprintf( ' width="%s" height="%s"', $metadata['width'], $metadata['height'] );
46 }
47 }
48 $output = sprintf( '[video src="%s"%s][/video]', $url, $size );
49 }
50 }
51
52 return $output;
53 }
54
55 public static function get_translatable_text_fields( $module ) : array {
56 return [ 'mod_title_video', 'title_video' ];
57 }
58
59 public static function get_translatable_textarea_fields( $module ) : array {
60 return [ 'caption_video' ];
61 }
62
63 public static function get_translatable_link_fields( $module ) : array {
64 return [ 'url_video', 'o_i', 'title_link_video' ];
65 }
66 }
67
68