PluginProbe
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress / 8.5.36
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress v8.5.36
9.1.2 9.1.1 9.1.0 9.0.3 9.0.2 9.0.1 9.0.0 8.5.79 8.5.78 8.5.77 8.5.76 8.5.75 8.5.74 8.5.73 8.5.72 8.5.71 8.5.70 8.5.69 8.5.68 8.5.35 8.5.36 8.5.37 8.5.38 8.5.39 8.5.4 All 221 releases
wpvr / admin / classes / class-wpvr-video.php

class-wpvr-video.php in WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress 8.5.36, at admin/classes/class-wpvr-video.php

186 lines 5.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) exit; // Exit if accessed directly
3 /**
4 * Responsible for managing Video tab content on Setup metabox
5 *
6 * @link http://rextheme.com/
7 * @since 1.0.0
8 *
9 * @package Wpvr
10 * @subpackage Wpvr/admin/classes
11 */
12
13 class WPVR_Video {
14
15 /**
16 * Instance of WPVR_Format class
17 */
18 protected $format;
19
20 /**
21 * Instance of WPVR_Validation class
22 */
23 protected $validator;
24
25
26 function __construct()
27 {
28 $this->format = new WPVR_Format();
29
30 $this->validator = new WPVR_Validator();
31 }
32
33
34 /**
35 * Render Video Tab Content
36 * @param mixed $postdata
37 *
38 * @return void
39 * @since 8.0.0
40 */
41 public function render_video($postdata)
42 {
43 ob_start();
44 ?>
45
46 <h6 class="title"><?php echo __('Video Settings : ', 'wpvr'); ?></h6>
47
48 <?php
49 WPVR_Meta_Field::render_video_setting_meta_fields($postdata);
50 ob_end_flush();
51 }
52
53
54 /**
55 * Update post meta data
56 *
57 * @param integer $postid
58 * @param integer $panoid
59 *
60 * @return void
61 * @since 8.0.0
62 */
63 public function wpvr_update_meta_box($postid, $panoid)
64 {
65 $vidid = 'vid' . $postid;
66 $videourl = esc_url_raw($_POST['videourl']);
67
68 $videodata = $this->format->prepare_video_settings_data();
69 $vidtype = '';
70
71 $this->validator->empty_video_validation($videourl);
72
73 if (strpos($videourl, 'youtube') > 0) {
74 $vidtype = 'youtube';
75 $html = $this->format->prepare_youtube_video_meta_data($videourl, $videodata);
76 } elseif (strpos($videourl, 'youtu.be') > 0) {
77 $vidtype = 'youtube';
78 $html = $this->format->prepare_youtu_be_video_meta_data($videourl, $videodata);
79 } elseif (strpos($videourl, 'vimeo') > 0) {
80 $vidtype = 'vimeo';
81 $html = $this->format->prepare_vimeo_video_meta_data($videourl, $videodata);
82 } else {
83 $vidtype = 'selfhost';
84 $html = $this->format->prepare_selfhost_video_meta_data($videourl, $vidid, $videodata);
85 }
86
87 $videoarray = array();
88 $videoarray = array(
89 __("panoid") => $panoid,
90 __("panoviddata") => $html,
91 __("vidid") => $vidid,
92 __("vidurl") => $videourl,
93 __("vidtype") => $vidtype,
94 __("autoplay") => $videodata['autoplay'],
95 __("loop") => $videodata['loop']
96 );
97 update_post_meta($postid, 'panodata', $videoarray);
98 $response = array(
99 'success' => true,
100 'data' => array(
101 'post_ID' => $postid,
102 'post_status' => get_post_status($postid)
103 )
104 );
105 wp_send_json($response);
106 die();
107 }
108
109
110 /**
111 * Video Tour Preview
112 *
113 * @param mixed $panoid
114 *
115 * @return wp_send_json_response
116 * @since 8.0.0
117 */
118 public function wpvr_video_preview($panoid)
119 {
120 $randid = rand(1000, 1000000);
121 $vidid = 'vid' . $randid;
122 $videourl = esc_url_raw($_POST['videourl']);
123 $videodata = $this->format->prepare_video_settings_data();
124 $vidtype = '';
125
126 $this->validator->empty_video_validation($videourl);
127
128 if (strpos($videourl, 'youtube') > 0) {
129 $vidtype = 'youtube';
130 $html = $this->format->prepare_youtube_video_preview($videourl, $videodata);
131 } elseif (strpos($videourl, 'youtu.be') > 0) {
132 $vidtype = 'youtube';
133 $html = $this->format->prepare_youtu_be_video_meta_data($videourl, $videodata);
134 } elseif (strpos($videourl, 'vimeo') > 0) {
135 $vidtype = 'vimeo';
136 $html = $this->format->prepare_vimeo_video_meta_data($videourl, $videodata);
137 } else {
138 $vidtype = 'selfhost';
139 $html = $this->format->prepare_selfhost_video_meta_data($videourl, $vidid, $videodata);
140 }
141
142 $response = array();
143 $response = array(__("panoid") => $panoid, __("panodata") => $html, __("vidid") => $vidid, __("vidtype") => $vidtype);
144 wp_send_json_success($response);
145 }
146
147
148 /**
149 * Render shortcode while postdata has video data
150 *
151 * @param array $postdata
152 * @param integer $id
153 *
154 * @return string
155 * @since 8.0.0
156 */
157 public function render_video_shortcode($postdata, $id, $width, $height, $radius)
158 {
159 if (empty($width)) {
160 $width = '600px';
161 }
162 if (empty($height)) {
163 $height = '400px';
164 }
165
166 $autoplay = 'off';
167 if (isset($postdata['autoplay'])) {
168 $autoplay = $postdata['autoplay'];
169 }
170
171 $loop = 'off';
172 if (isset($postdata['loop'])) {
173 $loop = $postdata['loop'];
174 }
175
176 if (strpos($postdata['vidurl'], 'youtube') > 0 || strpos($postdata['vidurl'], 'youtu') > 0) {
177 $html = $this->format->preapre_youtube_video_shortcode_data($postdata, $width, $height, $autoplay, $loop, $radius);
178 } elseif (strpos($postdata['vidurl'], 'vimeo') > 0) {
179 $html = $this->format->prepare_vimeo_video_shortcode_data($postdata, $width, $height, $autoplay, $loop, $radius);
180 } else {
181 $html = $this->format->prepare_regular_video_shortcode_data($id, $postdata, $width, $height, $radius);
182 }
183 return $html;
184 }
185
186 }