PluginProbe
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress / 9.2.0
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress v9.2.0
9.2.0 9.1.4 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 All 224 releases
← All changes | src/Admin/Admin.php +101 -5 9.0.0 → 9.2.0 View file →
@@ -56,13 +56,16 @@
56 56 $page_title = $tour_id
57 57 ? __( 'Edit Tour', 'wpvr' )
58 58 : __( 'Add New Tour', 'wpvr' );
59 59
60 + $post_type_obj = get_post_type_object( self::POST_TYPE );
61 + $capability = $post_type_obj ? $post_type_obj->cap->edit_posts : 'edit_wpvr_tours';
62 +
60 63 add_submenu_page(
61 64 '',
62 65 $page_title,
63 66 $page_title,
64 - 'edit_posts',
67 + $capability,
65 68 self::PAGE_SLUG,
66 69 [ $this, 'render_editor_page' ]
67 70 );
68 71 }
@@ -127,8 +130,16 @@
127 130 // Step 4 — Render + enqueue
128 131 // -------------------------------------------------------------------------
129 132
130 133 public function render_editor_page(): void {
134 + $tour_id = isset( $_GET['tour_id'] ) ? (int) $_GET['tour_id'] : 0;
135 + if ( $tour_id ) {
136 + $post = get_post( $tour_id );
137 + if ( ! $post || $post->post_type !== self::POST_TYPE || ! current_user_can( 'edit_post', $tour_id ) ) {
138 + wp_die( esc_html__( 'Sorry, you are not allowed to edit this tour.', 'wpvr' ), 403 );
139 + }
140 + }
141 +
131 142 echo '<div id="wpvr-tour-editor-root"></div>';
132 143
133 144 if ( ! wpvr_is_pro_active() ) {
134 145 require WPVR_PLUGIN_LEGACY_DIR_PATH . 'admin/partials/wpvr-premium-feature-popup.php';
@@ -149,8 +160,16 @@
149 160 if ( ! $this->is_editor_page( $hook ) ) {
150 161 return;
151 162 }
152 163
164 + $tour_id_cfg = isset( $_GET['tour_id'] ) ? (int) $_GET['tour_id'] : 0;
165 + if ( $tour_id_cfg ) {
166 + $post = get_post( $tour_id_cfg );
167 + if ( ! $post || $post->post_type !== self::POST_TYPE || ! current_user_can( 'edit_post', $tour_id_cfg ) ) {
168 + return;
169 + }
170 + }
171 +
153 172 $plugin_url = plugin_dir_url( WPVR_FILE );
154 173 $plugin_path = plugin_dir_path( WPVR_FILE );
155 174 $build_dir = $plugin_path . 'build/tour-editor/';
156 175
@@ -159,8 +178,15 @@
159 178 wp_enqueue_style( 'wpvr-pannellum-css', $pano_base . 'css/pannellum.css', [], WPVR_VERSION );
160 179 wp_enqueue_script( 'wpvr-libpannellum', $pano_base . 'js/libpannellum.js', [], WPVR_VERSION, true );
161 180 wp_enqueue_script( 'wpvr-pannellum', $pano_base . 'js/pannellum.js', [ 'wpvr-libpannellum' ], WPVR_VERSION, true );
162 181
182 + // Load Video.js & VideoJS-VR (for 360 video tours).
183 + $public_base = $plugin_url . 'legacy/public/';
184 + wp_enqueue_style( 'wpvr-videojs-css', $public_base . 'lib/pannellum/src/css/video-js.css', [], WPVR_VERSION );
185 + wp_enqueue_style( 'wpvr-videojs-vr-css', $public_base . 'lib/videojs-vr/videojs-vr.css', [], WPVR_VERSION );
186 + wp_enqueue_script( 'wpvr-videojs', $public_base . 'js/video.js', [], WPVR_VERSION, true );
187 + wp_enqueue_script( 'wpvr-videojs-vr', $public_base . 'lib/videojs-vr/videojs-vr.js', [ 'wpvr-videojs' ], WPVR_VERSION, true );
188 +
163 189 wp_enqueue_style( 'wpvr-fontawesome', $plugin_url . 'legacy/admin/lib/fontawesome/css/all.min.css', [], WPVR_VERSION );
164 190
165 191 // Tour editor React bundle.
166 192 $js_file = $build_dir . 'index.js';
@@ -177,9 +203,9 @@
177 203
178 204 wp_enqueue_script(
179 205 'wpvr-tour-editor',
180 206 $plugin_url . 'build/tour-editor/index.js',
181 - array_merge( $asset['dependencies'], [ 'wpvr-pannellum' ] ),
207 + array_merge( $asset['dependencies'], [ 'wpvr-pannellum', 'wpvr-videojs-vr' ] ),
182 208 $asset['version'],
183 209 true
184 210 );
185 211
@@ -190,11 +216,67 @@
190 216 if ( class_exists( 'Wpvr_fontawesome_icons' ) ) {
191 217 $fa_icons = ( new \Wpvr_fontawesome_icons() )->icon;
192 218 }
193 219
220 + $raw_hotspot_types = apply_filters( 'wpvr_hotspot_types', [
221 + 'info' => __( 'Info', 'wpvr' ),
222 + 'scene' => __( 'Scene', 'wpvr' ),
223 + ] );
224 +
225 + $hotspot_types = [];
226 + if ( isset( $raw_hotspot_types['info'] ) ) {
227 + $hotspot_types[] = [ 'value' => 'info', 'label' => $raw_hotspot_types['info'] ];
228 + unset( $raw_hotspot_types['info'] );
229 + } else {
230 + $hotspot_types[] = [ 'value' => 'info', 'label' => __( 'Info', 'wpvr' ) ];
231 + }
232 +
233 + if ( isset( $raw_hotspot_types['scene'] ) ) {
234 + $hotspot_types[] = [ 'value' => 'scene', 'label' => $raw_hotspot_types['scene'] ];
235 + unset( $raw_hotspot_types['scene'] );
236 + } else {
237 + $hotspot_types[] = [ 'value' => 'scene', 'label' => __( 'Scene', 'wpvr' ) ];
238 + }
239 +
240 + $hotspot_types[] = [ 'value' => 'url', 'label' => __( 'External URL', 'wpvr' ) ];
241 + if ( isset( $raw_hotspot_types['url'] ) ) {
242 + unset( $raw_hotspot_types['url'] );
243 + }
244 +
245 + foreach ( $raw_hotspot_types as $type_key => $type_label ) {
246 + $hotspot_types[] = [ 'value' => $type_key, 'label' => $type_label ];
247 + }
248 +
249 + $fluent_forms = [];
250 + if ( defined( 'FLUENTFORM' ) ) {
251 + global $wpdb;
252 + $fluent_form_table = $wpdb->prefix . 'fluentform_forms';
253 + $forms = $wpdb->get_results( "SELECT id, title FROM {$fluent_form_table} WHERE status = 'published' ORDER BY title ASC" );
254 + if ( ! empty( $forms ) && is_array( $forms ) ) {
255 + foreach ( $forms as $form ) {
256 + $fluent_forms[] = [
257 + 'id' => (string) $form->id,
258 + 'title' => $form->title,
259 + ];
260 + }
261 + }
262 + }
263 +
264 + $is_embed_addon_active = apply_filters( 'is_wpvr_embed_addon_premium', false );
265 + if ( $is_embed_addon_active ) {
266 + if ( wp_script_is( 'custom-qrcode', 'registered' ) ) {
267 + wp_enqueue_script( 'custom-qrcode' );
268 + } elseif ( defined( 'WPVR_PRO_PLUGIN_DIR_URL' ) ) {
269 + wp_enqueue_script( 'custom-qrcode', trailingslashit( WPVR_PRO_PLUGIN_DIR_URL ) . 'admin/lib/qr-code/custom-qrcode.js', [ 'jquery' ], null, true );
270 + }
271 + }
272 +
194 273 wp_localize_script( 'wpvr-tour-editor', 'wpvrTourEditor', [
195 274 'tourId' => $tour_id_cfg ?: null,
196 275 'tourStatus' => $tour_status,
276 + 'tourTitle' => $tour_id_cfg ? get_the_title( $tour_id_cfg ) : '',
277 + 'homeUrl' => home_url( '/' ),
278 + 'isEmbedAddonActive' => $is_embed_addon_active,
197 279 'nonce' => wp_create_nonce( 'wp_rest' ),
198 280 'apiBase' => rest_url( 'wpvr/v1' ),
199 281 'mediaUrl' => rest_url( 'wp/v2/media' ),
200 282 'isPro' => wpvr_is_pro_active(),
@@ -203,8 +285,12 @@
203 285 'postEditUrl' => admin_url( 'post.php' ),
204 286 'faIcons' => $fa_icons,
205 287 'ajaxUrl' => admin_url( 'admin-ajax.php' ),
206 288 'exportNonce' => wp_create_nonce( 'wpvr_export_tour' ),
289 + 'hotspotTypes' => $hotspot_types,
290 + 'fluentForms' => $fluent_forms,
291 + 'isFluentFormActive' => defined( 'FLUENTFORM' ),
292 + 'isWcActive' => class_exists( 'WooCommerce' ),
207 293 'imageResizeWarning' => [
208 294 'ajaxNonce' => wp_create_nonce( 'wpvr' ),
209 295 'canManageSettings' => current_user_can( 'manage_options' ),
210 296 'settingEnabled' => get_option( 'high_res_image' ) === 'true',
@@ -215,13 +301,17 @@
215 301 'close' => __( 'Close', 'wpvr' ),
216 302 ],
217 303 ] );
218 304
305 + $inter_font_path = $plugin_path . 'legacy/public/css/inter.css';
306 + $inter_font_ver = file_exists( $inter_font_path ) ? filemtime( $inter_font_path ) : WPVR_VERSION;
307 + wp_enqueue_style( 'wpvr-inter-font', $public_base . 'css/inter.css', [], $inter_font_ver, 'all' );
308 +
219 309 if ( file_exists( $css_file ) ) {
220 310 wp_enqueue_style(
221 311 'wpvr-tour-editor',
222 312 $plugin_url . 'build/tour-editor/style-index.css',
223 - [ 'wpvr-pannellum-css' ],
313 + [ 'wpvr-pannellum-css', 'wpvr-inter-font' ],
224 314 $asset['version']
225 315 );
226 316 }
227 317 }
@@ -454,13 +544,19 @@
454 544 $style_dependencies[] = 'wpvr-create-tour-modal';
455 545 $script_dependencies[] = 'wpvr-create-tour-modal';
456 546 }
457 547
548 + $tour_listing_css = plugin_dir_path( WPVR_FILE ) . 'app/admin/tour-listing.css';
549 + $tour_listing_css_ver = file_exists( $tour_listing_css ) ? (string) filemtime( $tour_listing_css ) : WPVR_VERSION;
550 +
551 + $tour_listing_js = plugin_dir_path( WPVR_FILE ) . 'app/admin/tour-listing.js';
552 + $tour_listing_js_ver = file_exists( $tour_listing_js ) ? (string) filemtime( $tour_listing_js ) : WPVR_VERSION;
553 +
458 554 wp_enqueue_style(
459 555 'wpvr-tour-listing',
460 556 $plugin_url . 'app/admin/tour-listing.css',
461 557 $style_dependencies,
462 - WPVR_VERSION
558 + $tour_listing_css_ver
463 559 );
464 560
465 561 wp_enqueue_script(
466 562 'wpvr-tour-listing',
@@ -465,9 +561,9 @@
465 561 wp_enqueue_script(
466 562 'wpvr-tour-listing',
467 563 $plugin_url . 'app/admin/tour-listing.js',
468 564 $script_dependencies,
469 - WPVR_VERSION,
565 + $tour_listing_js_ver,
470 566 true
471 567 );
472 568 }
473 569