From c79ab5b41c39bf98ee31ce6fb6af32a824a4a5bb Mon Sep 17 00:00:00 2001 From: Subodh Rajpopat Date: Thu, 22 Oct 2026 23:00:20 +0530 Subject: [PATCH 1/2] Render the GoDAM player from attributes instead of a built shortcode string The video embed page, the video-shortcode REST route, the GoDAM Gallery Elementor widget, the preview page and the entry screens of the Fluent Forms, WPForms, Everest Forms, SureForms and Gravity Forms recorder fields now hand their values to the player as an attributes array. A new helper, rtgodam_render_shortcode_from_atts(), calls the registered shortcode callback directly, so a value is only ever an attribute value and is never parsed as shortcode syntax. - The embed page and the route reduce godam_context and block_source to slug characters with sanitize_key(); the route argument uses sanitize_key too. - Stored recording and transcoded URLs are passed through esc_url_raw(). - The route gets a rtgodam_shortcode_atts filter for the attributes array. The rtgodam_shortcode_output filter, which receives the shortcode string, is deprecated but still applied when a site uses it; every value in that string is now an ID, a slug, 'show'/'hide' or JSON. The rendered player HTML for normal values is unchanged. Adds unit tests for the helper, the embed and preview pages, the route, the Elementor gallery widget and each form plugin's entry view. The tests register a harmless shortcode and check that extra shortcode text in a value does not run it, and that a normal value still reaches the player. --- .../elementor-widgets/class-godam-gallery.php | 15 +- .../class-everest-forms-field-godam-video.php | 17 +- .../fields/class-recorder-field.php | 11 +- .../class-gf-field-godam-video.php | 11 +- .../rest-api/class-dynamic-shortcode.php | 56 ++- inc/classes/sureforms/class-form-submit.php | 12 +- .../wpforms-field-godam-record-entry-edit.php | 12 +- .../wpforms-field-godam-record-entry-view.php | 11 +- inc/helpers/custom-functions.php | 53 ++- tests/bootstrap.php | 4 + .../ElementorGalleryWidgetAttributesTest.php | 167 +++++++++ tests/php/EmbedPagePlayerAttributesTest.php | 172 +++++++++ ...FormsRecorderEntryPlayerAttributesTest.php | 124 +++++++ ...FormsRecorderEntryPlayerAttributesTest.php | 127 +++++++ ...FormsRecorderEntryPlayerAttributesTest.php | 115 ++++++ tests/php/RenderShortcodeFromAttsTest.php | 104 ++++++ ...FormsRecorderEntryPlayerAttributesTest.php | 113 ++++++ ...ideoShortcodeRoutePlayerAttributesTest.php | 254 ++++++++++++++ ...FormsRecorderEntryPlayerAttributesTest.php | 170 +++++++++ tests/stubs/gravity-forms-fields.php | 34 +- tests/stubs/player-entry-stubs.php | 330 ++++++++++++++++++ tests/stubs/shortcode-runtime.php | 173 +++++++++ 22 files changed, 2039 insertions(+), 46 deletions(-) create mode 100644 tests/php/ElementorGalleryWidgetAttributesTest.php create mode 100644 tests/php/EmbedPagePlayerAttributesTest.php create mode 100644 tests/php/EverestFormsRecorderEntryPlayerAttributesTest.php create mode 100644 tests/php/FluentFormsRecorderEntryPlayerAttributesTest.php create mode 100644 tests/php/GravityFormsRecorderEntryPlayerAttributesTest.php create mode 100644 tests/php/RenderShortcodeFromAttsTest.php create mode 100644 tests/php/SureFormsRecorderEntryPlayerAttributesTest.php create mode 100644 tests/php/VideoShortcodeRoutePlayerAttributesTest.php create mode 100644 tests/php/WPFormsRecorderEntryPlayerAttributesTest.php create mode 100644 tests/stubs/player-entry-stubs.php create mode 100644 tests/stubs/shortcode-runtime.php diff --git a/inc/classes/elementor-widgets/class-godam-gallery.php b/inc/classes/elementor-widgets/class-godam-gallery.php index 6ff34da3f..23c580db8 100644 --- a/inc/classes/elementor-widgets/class-godam-gallery.php +++ b/inc/classes/elementor-widgets/class-godam-gallery.php @@ -502,12 +502,17 @@ protected function render() { ); } - $shortcode_atts_string = ''; - foreach ( $shortcode_atts as $key => $value ) { - $shortcode_atts_string .= sprintf( ' %s="%s"', $key, esc_attr( $value ) ); - } + // Pass the settings as an attributes array rather than building a + // "[godam_video_gallery …]" string, so a setting value is never parsed as + // shortcode syntax. Values stay strings, as the shortcode parser delivers them. + $shortcode_atts = array_map( + function ( $value ) { + return is_scalar( $value ) ? (string) $value : ''; + }, + $shortcode_atts + ); - echo do_shortcode( '[godam_video_gallery' . $shortcode_atts_string . ']' ); + echo rtgodam_render_shortcode_from_atts( 'godam_video_gallery', $shortcode_atts ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- The gallery template escapes its output. } /** diff --git a/inc/classes/everest-forms/class-everest-forms-field-godam-video.php b/inc/classes/everest-forms/class-everest-forms-field-godam-video.php index cbee8e181..724994739 100644 --- a/inc/classes/everest-forms/class-everest-forms-field-godam-video.php +++ b/inc/classes/everest-forms/class-everest-forms-field-godam-video.php @@ -128,12 +128,14 @@ public function update_entry_meta_display_godam_recorder( $meta_value, $value, $ $transcoded_url_meta_key = 'rtgodam_transcoded_url_everestforms_' . $form_id . '_' . $entry_id; $transcoded_url_output = ''; + $transcoded_url_source = ''; + $transcoded_url = ''; if ( ! empty( $entry_data ) ) { - $transcoded_url = esc_url( $entry_data->meta[ $transcoded_url_meta_key ] ?? '' ); + $transcoded_url_source = $entry_data->meta[ $transcoded_url_meta_key ] ?? ''; + $transcoded_url = esc_url( $transcoded_url_source ); if ( ! empty( $transcoded_url ) ) { - $transcoded_url = "transcoded_url={$transcoded_url}"; $transcoded_url_output = sprintf( "
%s
", $is_audio @@ -151,8 +153,7 @@ public function update_entry_meta_display_godam_recorder( $meta_value, $value, $ if ( $is_audio ) { $audio_output = '