PluginProbe
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress / 9.1.3
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress v9.1.3
9.1.3 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 All 222 releases
wpvr / legacy / admin / classes / class-wpvr-video.php

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

198 lines 6.2 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' => $panoid,
94 'panoviddata' => $html,
95 'vidid' => $vidid,
96 'vidurl' => $videourl,
97 'vidtype' => $vidtype,
98 'autoplay' => $videodata['autoplay'],
99 'loop' => $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 ( function_exists( 'wpvr_enqueue_frontend_scripts' ) ) {
169 wpvr_enqueue_frontend_scripts( 'video' );
170 }
171 if (empty($width)) {
172 $width = '600px';
173 }
174 if (empty($height)) {
175 $height = '400px';
176 }
177
178 $autoplay = 'off';
179 if (isset($postdata['autoplay'])) {
180 $autoplay = $postdata['autoplay'];
181 }
182
183 $loop = 'off';
184 if (isset($postdata['loop'])) {
185 $loop = $postdata['loop'];
186 }
187
188 if (strpos($postdata['vidurl'], 'youtube') > 0 || strpos($postdata['vidurl'], 'youtu') > 0) {
189 $html = $this->format->prepare_youtube_video_shortcode_data($postdata, $width, $height, $autoplay, $loop, $radius);
190 } elseif (strpos($postdata['vidurl'], 'vimeo') > 0) {
191 $html = $this->format->prepare_vimeo_video_shortcode_data($postdata, $width, $height, $autoplay, $loop, $radius);
192 } else {
193 $html = $this->format->prepare_regular_video_shortcode_data($id, $postdata, $width, $height, $radius);
194 }
195 return $html;
196 }
197
198 }