From 9e71d4cc43e57cfcd0e2ee82a6a4213cbaf94d2b Mon Sep 17 00:00:00 2001 From: Doeke Norg Date: Thu, 17 Oct 2024 10:46:41 +0200 Subject: [PATCH] Remove undefined settings tab --- future/includes/class-gv-permalinks.php | 20 ++++++++++++-------- readme.txt | 4 ++++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/future/includes/class-gv-permalinks.php b/future/includes/class-gv-permalinks.php index b17bb6cf07..f4c699f3f7 100644 --- a/future/includes/class-gv-permalinks.php +++ b/future/includes/class-gv-permalinks.php @@ -445,6 +445,10 @@ private function permalink_settings(): array { * @return array The full settings array. */ public function add_permalink_settings( array $settings ): array { + if ( ! isset( $settings[ Plugin_Settings::SETTINGS_PLUGIN_ID ] ) ) { + return $settings; + } + $settings[ Plugin_Settings::SETTINGS_PLUGIN_ID ]['sections'][] = [ 'title' => esc_html__( 'Permalinks', 'gk-gravityview' ), 'description' => esc_html__( @@ -513,33 +517,33 @@ public function add_view_settings_scripts(): void { if ( value.length === 0 ) { return ''; } - + if (value.length < 3) { return '[ERROR_AT_LEAST_3]'; } - + if ( ! value.match( /{entry_id}/s ) ) { return '[ERROR_MISSING_ENTRY_ID]'; } - + if ( ! value.match( /(^[a-zA-Z0-9_{}\-]*$)/s ) ) { return '[ERROR_NO_SPACES]'; } - + return ''; } - + $( '#gravityview_se_single_entry_slug' ).on( 'input', function () { const value = $( this ).val(); const parent = $( this ).closest( 'label' ); const error = getErrorMessage( value ); const is_valid = '' === error; - + parent.toggleClass( 'form-invalid form-required', ! is_valid ); $( '#publish ') .attr( 'disabled', ! is_valid ) .toggleClass( 'disabled' , ! is_valid ); - + parent.find( 'span.error-message' ).remove(); if ( !is_valid ) { parent.append( $( '' + error + '' ) ); @@ -723,7 +727,7 @@ public function add_global_settings_scripts( array $scripts ): array { document.querySelectorAll( `[data-slug-preview="\${e.target.name}"]` ).forEach( ( element ) => { const default_value = element.dataset.slugDefault ?? 'unknown'; element.innerHTML = ( e.target.value || default_value ); - + if ( 'entry_slug' === e.target.name ) { element.innerHTML = element.innerHTML.replaceAll( '{entry_id}', '123' ); } diff --git a/readme.txt b/readme.txt index b4a0e94229..61d7e60284 100644 --- a/readme.txt +++ b/readme.txt @@ -21,6 +21,10 @@ Beautifully display your Gravity Forms entries. Learn more on [gravitykit.com](h == Changelog == += develop = + +Fixed: Settings paged showed an undefined settings tab when the GravityView Settings tab was disabled. + = 2.30.1 on October 15, 2024 = This hotfix release resolves an issue with the Multiple Forms extension.