Added a filter to set fopen mode for streams that dont support a+ (#33652)
Added a filter to set fopen mode for streams that dont support a+ Co-authored-by: barryhughes <3594411+barryhughes@users.noreply.github.com>
This commit is contained in:
parent
3fc11126a4
commit
6cb6fd02df
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: tweak
|
||||
|
||||
The file writing mode used during CSV exports is now filterable via new hook `woocommerce_csv_exporter_fopen_mode`.
|
|
@ -130,7 +130,18 @@ abstract class WC_CSV_Batch_Exporter extends WC_CSV_Exporter {
|
|||
return false;
|
||||
}
|
||||
|
||||
$fp = fopen( $this->get_file_path(), 'a+' );
|
||||
/**
|
||||
* Filters the mode parameter which specifies the type of access you require to the stream (used during file
|
||||
* writing for CSV exports). Defaults to 'a+' (which supports both reading and writing, and places the file
|
||||
* pointer at the end of the file).
|
||||
*
|
||||
* @see https://www.php.net/manual/en/function.fopen.php
|
||||
* @since 6.8.0
|
||||
*
|
||||
* @param string $fopen_mode, either (r, r+, w, w+, a, a+, x, x+, c, c+, e)
|
||||
*/
|
||||
$fopen_mode = apply_filters( 'woocommerce_csv_exporter_fopen_mode', 'a+' );
|
||||
$fp = fopen( $this->get_file_path(), $fopen_mode );
|
||||
|
||||
if ( $fp ) {
|
||||
fwrite( $fp, $data );
|
||||
|
|
Loading…
Reference in New Issue