| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Suppress "error - 0 - No summary was found for this file" on phpdoc generation |
| 5 |
* |
| 6 |
* @package WPDataAccess\Utilities |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace WPDataAccess\Utilities { |
| 10 |
|
| 11 |
use WPDataAccess\WPDA; |
| 12 |
|
| 13 |
/** |
| 14 |
* Class WPDA_Export |
| 15 |
* |
| 16 |
* @author Peter Schulz |
| 17 |
* @since 2.0.13 |
| 18 |
*/ |
| 19 |
class WPDA_Export { |
| 20 |
|
| 21 |
/** |
| 22 |
* Main method to start specific export type |
| 23 |
* |
| 24 |
* @since 2.0.13 |
| 25 |
*/ |
| 26 |
public static function export() { |
| 27 |
$export_class = 'WPDataAccess\\Utilities\\WPDA_Export_Sql'; // Default export class exports to SQL. |
| 28 |
if ( isset( $_REQUEST['format_type'] ) ) { // phpcs:ignore |
| 29 |
$format_type = sanitize_text_field( wp_unslash( $_REQUEST['format_type'] ) ); // phpcs:ignore |
| 30 |
switch ( $format_type ) { |
| 31 |
case 'excel': |
| 32 |
$export_class = 'WPDataAccess\\Utilities\\WPDA_Export_Excel'; |
| 33 |
break; |
| 34 |
case 'json': |
| 35 |
$export_class = 'WPDataAccess\\Utilities\\WPDA_Export_Json'; |
| 36 |
break; |
| 37 |
case 'xml': |
| 38 |
$export_class = 'WPDataAccess\\Utilities\\WPDA_Export_Xml'; |
| 39 |
break; |
| 40 |
case 'csv': |
| 41 |
$export_class = 'WPDataAccess\\Utilities\\WPDA_Export_Csv'; |
| 42 |
break; |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
$export = new $export_class(); |
| 47 |
$export->export(); |
| 48 |
} |
| 49 |
|
| 50 |
public static function export_ajax() { |
| 51 |
static::export(); |
| 52 |
die(); |
| 53 |
} |
| 54 |
|
| 55 |
} |
| 56 |
|
| 57 |
} |
| 58 |
|