@@ -304,6 +304,13 @@ public function maybe_enqueue_lightbox_runtime() {
304304 * enqueues via render() as usual, is untouched. Mirrors the GoDAM Image element's
305305 * preload_wpbakery_editor_assets().
306306 *
307+ * The analytics script (godam-player-analytics-script) is deliberately NOT
308+ * preloaded here. Its only skip guard, shouldSkipAnalytics(), gates on is_admin()
309+ * (false on the WPBakery frontend inline-editor page) and the video-preview query
310+ * var (unset here), so it would not skip — every preview play/scrub while designing
311+ * would send real view/engagement events and corrupt the video's stats. The player
312+ * runs fine without it; the front end still loads analytics via render() as before.
313+ *
307314 * @since 2.2.2
308315 *
309316 * @return void
@@ -313,18 +320,30 @@ public function preload_wpbakery_editor_assets() {
313320 return ;
314321 }
315322
316- // register_scripts() (priority 10) has already registered these handles .
323+ // register_scripts() (priority 10) has already registered this handle .
317324 if ( wp_script_is ( 'godam-player-frontend-script ' , 'registered ' ) ) {
318325 wp_enqueue_script ( 'godam-player-frontend-script ' );
319326 }
320- if ( wp_script_is ( 'godam-player-analytics-script ' , 'registered ' ) ) {
321- wp_enqueue_script ( 'godam-player-analytics-script ' );
322- }
323327
324328 wp_enqueue_style ( 'godam-player-style ' );
325329
326- // Match the active player skin, exactly as render() does, so the editor
327- // preview looks like the front end rather than defaulting to the base skin.
330+ // Match the active player skin so the editor preview looks like the front end.
331+ $ this ->enqueue_active_skin_style ();
332+ }
333+
334+ /**
335+ * Enqueue the stylesheet for the site's currently selected player skin, if any.
336+ *
337+ * Shared by render() (front end) and preload_wpbakery_editor_assets() (inline
338+ * editor) so the skin map lives in one place and the editor preview can never
339+ * silently diverge from the front end when a skin is added, renamed or removed.
340+ * No-op when no skin (or the default base skin) is selected.
341+ *
342+ * @since 2.2.2
343+ *
344+ * @return void
345+ */
346+ private function enqueue_active_skin_style () {
328347 $ godam_settings = get_option ( 'rtgodam-settings ' , array () );
329348 $ selected_skin = isset ( $ godam_settings ['video_player ' ]['player_skin ' ] ) ? $ godam_settings ['video_player ' ]['player_skin ' ] : '' ;
330349 $ skins = array (
@@ -502,18 +521,7 @@ public function render( $atts ) {
502521 wp_enqueue_script ( 'godam-player-analytics-script ' );
503522 wp_enqueue_style ( 'godam-player-style ' );
504523
505- $ godam_settings = get_option ( 'rtgodam-settings ' , array () );
506- $ selected_skin = isset ( $ godam_settings ['video_player ' ]['player_skin ' ] ) ? $ godam_settings ['video_player ' ]['player_skin ' ] : '' ;
507- $ skins = array (
508- 'Minimal ' => 'godam-player-minimal-skin ' ,
509- 'Pills ' => 'godam-player-pills-skin ' ,
510- 'Bubble ' => 'godam-player-bubble-skin ' ,
511- 'Classic ' => 'godam-player-classic-skin ' ,
512- );
513-
514- if ( isset ( $ skins [ $ selected_skin ] ) ) {
515- wp_enqueue_style ( $ skins [ $ selected_skin ] );
516- }
524+ $ this ->enqueue_active_skin_style ();
517525
518526 ob_start ();
519527 require RTGODAM_PATH . 'inc/templates/godam-player.php ' ;
0 commit comments