@@ 338-350 (lines=13) @@ | ||
335 | * |
|
336 | * @return \WP_Error|null |
|
337 | */ |
|
338 | public function set_archive_filename( $filename ) { |
|
339 | ||
340 | if ( empty( $filename ) || ! is_string( $filename ) ) { |
|
341 | return new \WP_Error( 'invalid_file_name', __( 'archive filename must be a non-empty string', 'backupwordpress' ) ); |
|
342 | } |
|
343 | ||
344 | if ( pathinfo( $filename, PATHINFO_EXTENSION ) !== 'zip' ) { |
|
345 | return new \WP_Error( 'invalid_file_extension', sprintf( __( 'invalid file extension for archive filename <code>%s</code>', 'backupwordpress' ), $filename ) ); |
|
346 | } |
|
347 | ||
348 | $this->archive_filename = strtolower( sanitize_file_name( remove_accents( $filename ) ) ); |
|
349 | ||
350 | } |
|
351 | ||
352 | /** |
|
353 | * Get the full filepath to the database dump file. |
|
@@ 383-395 (lines=13) @@ | ||
380 | * |
|
381 | * @return \WP_Error|null |
|
382 | */ |
|
383 | public function set_database_dump_filename( $filename ) { |
|
384 | ||
385 | if ( empty( $filename ) || ! is_string( $filename ) ) { |
|
386 | return new \WP_Error( 'invalid_file_name', __( 'database dump filename must be a non-empty string', 'backupwordpress' ) ); |
|
387 | } |
|
388 | ||
389 | if ( pathinfo( $filename, PATHINFO_EXTENSION ) !== 'sql' ) { |
|
390 | return new \WP_Error( 'invalid_file_extension', sprintf( __( 'invalid file extension for database dump filename <code>%s</code>', 'backupwordpress' ), $filename ) ); |
|
391 | } |
|
392 | ||
393 | $this->database_dump_filename = strtolower( sanitize_file_name( remove_accents( $filename ) ) ); |
|
394 | ||
395 | } |
|
396 | ||
397 | /** |
|
398 | * Get the root directory to backup from |