From 1a5e19523e624f87308478024b543da054f16acf Mon Sep 17 00:00:00 2001 From: Doeke Norg Date: Tue, 29 Oct 2024 09:49:24 +0100 Subject: [PATCH] Release 2.3.3 (#202) * Fix plugin icon color * Add force download hook --------- Co-authored-by: Zack Katz Co-authored-by: Vlad --- gfexcel.php | 4 ++-- readme.txt | 8 ++++++-- src/Addon/GravityExportAddon.php | 2 +- src/Field/FileUploadField.php | 26 +++++++++++++++++++++++--- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/gfexcel.php b/gfexcel.php index 88f489fb..ccd270e1 100644 --- a/gfexcel.php +++ b/gfexcel.php @@ -1,7 +1,7 @@ '; + return ''; } /** diff --git a/src/Field/FileUploadField.php b/src/Field/FileUploadField.php index 6b3b35aa..f2951326 100644 --- a/src/Field/FileUploadField.php +++ b/src/Field/FileUploadField.php @@ -7,6 +7,7 @@ /** * Class FileUploadField + * * @since 1.1.0 */ class FileUploadField extends BaseField implements RowsInterface { @@ -51,7 +52,6 @@ public function getColumns() { * @return bool Whether the uploads should be shown as a column. */ private function showFileUploadsAsColumn() { - // The default value of `true` will not be returned by get_plugin_setting(); it will return null by default. // So we apply the ?? operator and return true as the default value. $fileuploads_enabled = GravityExportAddon::get_instance()->get_plugin_setting( 'fileuploads_enabled' ) ?? true; @@ -80,7 +80,9 @@ public function getRows( ?array $entry = null ): iterable { } foreach ( $files as $file ) { - yield $this->wrap( [ $this->field->get_download_url( $file, true ) ] ); + yield $this->wrap( [ + $this->field->get_download_url( $file, $this->should_force_download() ), + ] ); } } } else { @@ -98,6 +100,24 @@ protected function getFieldValue( $entry, $input_id = '' ) { return $value; } - return $this->field->get_download_url( $value, true ); + return $this->field->get_download_url( $value, $this->should_force_download() ); + } + + /** + * Returns whether to force a download URL. + * + * @since 2.3.3 + * + * @return bool Whether to force a download URL. + */ + private function should_force_download(): bool { + return (bool) gf_apply_filters( + [ + 'gfexcel_field_fileuploads_force_download', + $this->field->formId, + ], + true, + $this->field + ); } }