PluginProbe
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress / 8.5.74
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress v8.5.74
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.74, at admin/classes/class-wpvr-video.php

195 lines 6.1 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 esc_html__( '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 $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : '';
66 if ( ! wp_verify_nonce( $nonce, 'wpvr' ) ) {
67 wp_die( 'Permission denied.' );
68 }
69 $vidid = 'vid' . $postid;
70 $videourl = isset( $_POST['videourl'] ) ? esc_url_raw( wp_unslash( $_POST['videourl'] ) ) : '';
71
72 $videodata = $this->format->prepare_video_settings_data();
73 $vidtype = '';
74
75 $this->validator->empty_video_validation($videourl);
76
77 if (strpos($videourl, 'youtube') > 0) {
78 $vidtype = 'youtube';
79 $html = $this->format->prepare_youtube_video_meta_data($videourl, $videodata);
80 } elseif (strpos($videourl, 'youtu.be') > 0) {
81 $vidtype = 'youtube';
82 $html = $this->format->prepare_youtu_be_video_meta_data($videourl, $videodata);
83 } elseif (strpos($videourl, 'vimeo') > 0) {
84 $vidtype = 'vimeo';
85 $html = $this->format->prepare_vimeo_video_meta_data($videourl, $videodata);
86 } else {
87 $vidtype = 'selfhost';
88 $html = $this->format->prepare_selfhost_video_meta_data($videourl, $vidid, $videodata);
89 }
90
91 $videoarray = array();
92 $videoarray = array(
93 __("panoid", 'wpvr') => $panoid,
94 __("panoviddata", 'wpvr') => $html,
95 __("vidid", 'wpvr') => $vidid,
96 __("vidurl", 'wpvr') => $videourl,
97 __("vidtype", 'wpvr') => $vidtype,
98 __("autoplay", 'wpvr') => $videodata['autoplay'],
99 __("loop", 'wpvr') => $videodata['loop']
100 );
101 update_post_meta($postid, 'panodata', $videoarray);
102 $response = array(
103 'success' => true,
104 'data' => array(
105 'post_ID' => $postid,
106 'post_status' => get_post_status($postid)
107 )
108 );
109 do_action( 'wpvr_tour_settings_saved', $postid );
110 wp_send_json($response);
111 die();
112 }
113
114
115 /**
116 * Video Tour Preview
117 *
118 * @param mixed $panoid
119 *
120 * @return wp_send_json_response
121 * @since 8.0.0
122 */
123 public function wpvr_video_preview($panoid)
124 {
125 $randid = wp_rand(1000, 1000000);
126 $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : '';
127 if ( ! wp_verify_nonce( $nonce, 'wpvr' ) ) {
128 wp_die( 'Permission denied.' );
129 }
130 $vidid = 'vid' . $randid;
131 $videourl = isset( $_POST['videourl'] ) ? esc_url_raw( wp_unslash( $_POST['videourl'] ) ) : '';
132 $videodata = $this->format->prepare_video_settings_data();
133 $vidtype = '';
134
135 $this->validator->empty_video_validation($videourl);
136
137 if (strpos($videourl, 'youtube') > 0) {
138 $vidtype = 'youtube';
139 $html = $this->format->prepare_youtube_video_preview($videourl, $videodata);
140 } elseif (strpos($videourl, 'youtu.be') > 0) {
141 $vidtype = 'youtube';
142 $html = $this->format->prepare_youtube_video_preview($videourl, $videodata);
143 } elseif (strpos($videourl, 'vimeo') > 0) {
144 $vidtype = 'vimeo';
145 $html = $this->format->prepare_vimeo_video_meta_data($videourl, $videodata);
146 } else {
147 $vidtype = 'selfhost';
148 $html = $this->format->prepare_selfhost_video_meta_data($videourl, $vidid, $videodata);
149 }
150
151 $response = array();
152 $response = array(__("panoid", 'wpvr') => $panoid, __("panodata", 'wpvr') => $html, __("vidid", 'wpvr') => $vidid, __("vidtype", 'wpvr') => $vidtype);
153 wp_send_json_success($response);
154 }
155
156
157 /**
158 * Render shortcode while postdata has video data
159 *
160 * @param array $postdata
161 * @param integer $id
162 *
163 * @return string
164 * @since 8.0.0
165 */
166 public function render_video_shortcode($postdata, $id, $width, $height, $radius)
167 {
168 if (empty($width)) {
169 $width = '600px';
170 }
171 if (empty($height)) {
172 $height = '400px';
173 }
174
175 $autoplay = 'off';
176 if (isset($postdata['autoplay'])) {
177 $autoplay = $postdata['autoplay'];
178 }
179
180 $loop = 'off';
181 if (isset($postdata['loop'])) {
182 $loop = $postdata['loop'];
183 }
184
185 if (strpos($postdata['vidurl'], 'youtube') > 0 || strpos($postdata['vidurl'], 'youtu') > 0) {
186 $html = $this->format->prepare_youtube_video_shortcode_data($postdata, $width, $height, $autoplay, $loop, $radius);
187 } elseif (strpos($postdata['vidurl'], 'vimeo') > 0) {
188 $html = $this->format->prepare_vimeo_video_shortcode_data($postdata, $width, $height, $autoplay, $loop, $radius);
189 } else {
190 $html = $this->format->prepare_regular_video_shortcode_data($id, $postdata, $width, $height, $radius);
191 }
192 return $html;
193 }
194
195 }