is_target_screen() ) { return; } // New tour editor has its own "Classic View" button — no notice needed there. if ( isset( $_GET['page'] ) && sanitize_key( $_GET['page'] ) === self::PAGE_SLUG ) { return; } $current_mode = $this->get_current_mode(); $target_mode = $current_mode === 'latest' ? 'legacy' : 'latest'; $context = $this->get_current_context(); $tour_id = $this->get_current_tour_id(); $button_label = $current_mode === 'latest' ? __( 'Switch to Classic UI', 'wpvr' ) : __( 'Switch to New UI', 'wpvr' ); $message = $current_mode === 'latest' ? __( 'You are using the latest WP VR editor.', 'wpvr' ) : __( 'You are using the classic WP VR editor.', 'wpvr' ); ?>

get_redirect_url( $mode, $context, $tour_id ) ); exit; } private function is_target_screen(): bool { if ( isset( $_GET['page'] ) && sanitize_key( $_GET['page'] ) === self::PAGE_SLUG ) { return true; } if ( ! function_exists( 'get_current_screen' ) ) { return false; } $screen = get_current_screen(); if ( ! $screen ) { return false; } return $screen->id === self::POST_TYPE; } private function get_current_mode(): string { return get_option( 'wpvr_ui_mode', 'legacy' ) === 'latest' ? 'latest' : 'legacy'; } private function get_current_context(): string { if ( isset( $_GET['page'] ) && sanitize_key( $_GET['page'] ) === self::PAGE_SLUG ) { return isset( $_GET['tour_id'] ) ? 'edit' : 'new'; } if ( isset( $_GET['post'] ) ) { return 'edit'; } if ( isset( $_GET['post_type'] ) && sanitize_key( $_GET['post_type'] ) === self::POST_TYPE && strpos( (string) $_SERVER['PHP_SELF'], 'post-new.php' ) !== false ) { return 'new'; } return 'listing'; } private function get_current_tour_id(): int { if ( isset( $_GET['tour_id'] ) ) { return absint( $_GET['tour_id'] ); } if ( isset( $_GET['post'] ) ) { return absint( $_GET['post'] ); } return 0; } private function get_switch_url( string $mode, string $context, int $tour_id = 0 ): string { $args = [ 'action' => 'wpvr_switch_ui_mode', 'mode' => $mode, 'context' => $context, ]; if ( $tour_id > 0 ) { $args['tour_id'] = $tour_id; } return wp_nonce_url( add_query_arg( $args, admin_url( 'admin-post.php' ) ), 'wpvr_switch_ui_mode' ); } private function get_redirect_url( string $mode, string $context, int $tour_id = 0 ): string { if ( $mode === 'latest' ) { if ( $context === 'edit' && $tour_id > 0 ) { return add_query_arg( [ 'page' => self::PAGE_SLUG, 'tour_id' => $tour_id, ], admin_url( 'admin.php' ) ); } if ( $context === 'new' ) { return add_query_arg( [ 'page' => self::PAGE_SLUG ], admin_url( 'admin.php' ) ); } return admin_url( 'edit.php?post_type=' . self::POST_TYPE ); } if ( $context === 'edit' && $tour_id > 0 ) { return add_query_arg( [ 'post' => $tour_id, 'action' => 'edit', ], admin_url( 'post.php' ) ); } if ( $context === 'new' ) { return admin_url( 'post-new.php?post_type=' . self::POST_TYPE ); } return admin_url( 'edit.php?post_type=' . self::POST_TYPE ); } }