| @@ -142,9 +142,23 @@ | ||
| 142 | 142 | <script> |
| 143 | 143 | (function() { |
| 144 | 144 | var notice = document.getElementById('wpvr-ui-mode-notice'); |
| 145 | 145 | var dismissButton = notice ? notice.querySelector('.wpvr-ui-mode-notice__dismiss') : null; |
| 146 | + var switchButton = notice ? notice.querySelector('.wpvr-ui-mode-notice__switch') : null; | |
| 146 | 147 | |
| 148 | + if (switchButton) { | |
| 149 | + switchButton.addEventListener('click', function() { | |
| 150 | + // Publishing updates the page URL without rebuilding this notice. | |
| 151 | + var tourId = parseInt(new URLSearchParams(window.location.search).get('post'), 10); | |
| 152 | + if (tourId > 0) { | |
| 153 | + var switchUrl = new URL(switchButton.href); | |
| 154 | + switchUrl.searchParams.set('context', 'edit'); | |
| 155 | + switchUrl.searchParams.set('tour_id', tourId); | |
| 156 | + switchButton.href = switchUrl.toString(); | |
| 157 | + } | |
| 158 | + }); | |
| 159 | + } | |
| 160 | + | |
| 147 | 161 | if (dismissButton) { |
| 148 | 162 | dismissButton.addEventListener('click', function() { |
| 149 | 163 | notice.remove(); |
| 150 | 164 | }); |
| @@ -189,9 +203,9 @@ | ||
| 189 | 203 | return $screen->id === self::POST_TYPE; |
| 190 | 204 | } |
| 191 | 205 | |
| 192 | 206 | private function get_current_mode(): string { |
| 193 | - return get_option( 'wpvr_ui_mode', 'legacy' ) === 'latest' ? 'latest' : 'legacy'; | |
| 207 | + return get_option( 'wpvr_ui_mode', 'latest' ) === 'latest' ? 'latest' : 'legacy'; | |
| 194 | 208 | } |
| 195 | 209 | |
| 196 | 210 | private function get_current_context(): string { |
| 197 | 211 | if ( isset( $_GET['page'] ) && sanitize_key( $_GET['page'] ) === self::PAGE_SLUG ) { |