diff --git a/readme.txt b/readme.txt index 4e9c08c..d6fa832 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://www.gravitykit.com/extensions/gravityexport/?utm_source=plu Tags: Gravity Forms, GravityForms, Excel, Export, Entries Requires at least: 4.0 Requires PHP: 7.2 -Tested up to: 6.6.2 +Tested up to: 6.7 Stable tag: 2.3.2 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -256,6 +256,10 @@ You can hide a row by adding a hook. Checkout this example: == Changelog == += develop = + +* Enhancement: Added `gfexcel_field_fileuploads_force_download` hook, to disable the forced download links. + = 2.3.2 on October 14, 2024 = * Fixed: Added compatibility for servers that miss the `iconv` or `mbstring` PHP extension. diff --git a/src/Field/FileUploadField.php b/src/Field/FileUploadField.php index 6b3b35a..42c7df8 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 $ver$ + * + * @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 + ); } }