-
Notifications
You must be signed in to change notification settings - Fork 2
/
exporter.php
63 lines (46 loc) · 2.16 KB
/
exporter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
function simple_pdf_export_process(){
/*ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ERROR | E_PARSE);*/
//?export=pdf&num=3&post_type=post&force
//?export=pdf&post_id=3&post_type=post&force
global $pdf_export_post_type,
$pdf_export_force,
$pdf_posts_per_page,
$pdf_export_post_id,
$pdf_export_final_pdf;
$pdf_export_post_type = isset($_REQUEST['post_type']) && $_REQUEST['post_type'] != '' ? $_REQUEST['post_type'] : 'post';
$pdf_export_post_id = isset($_REQUEST['post_id']) ? $_REQUEST['post_id'] : '';
$pdf_posts_per_page = isset($_REQUEST['num']) ? $_REQUEST['num'] : -1;
$pdf_export_check = isset($_REQUEST['export']) ? $_REQUEST['export'] : '';
$pdf_export_force = isset($_REQUEST['force']);
// Added by Lomix
/*$pdf_export_force2 = get_the_title( $pdf_export_post_id );
$product = wc_get_product( $pdf_export_post_id );
$productsku = $product->get_sku();*/
$pdf_export_final_pdf = SIMPLE_PDF_EXPORTER_EXPORT.$pdf_export_post_type.SIMPLE_PDF_EXPORTER_EXTRA_FILE_NAME.date('dMY').'.pdf';
if ($pdf_export_check == 'pdf') {
//if ($pdf_export_force || !file_exists($pdf_export_final_pdf) || date("dMY", filemtime($pdf_export_final_pdf)) != date('dMY')) {
require_once(SIMPLE_PDF_EXPORTER_PROCESS."create_pagenumber_merge.php");
create_pagenumber_merge();
//}
$filename = $pdf_export_post_type.SIMPLE_PDF_EXPORTER_EXTRA_FILE_NAME.date('dMY').'.pdf';
// Handler
$pdf_handler = get_option('spe_pdfhandler');
// Debug
/*if(current_user_can('administrator')) {
echo '<pre>';
var_dump( get_option('spe_pdfhandler'));
echo '</pre>';
} exit;*/
header('Content-type: application/pdf');
header('Content-Disposition: '.$pdf_handler.'; filename="' . $filename . '"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($pdf_export_final_pdf));
header('Accept-Ranges: bytes');
readfile($pdf_export_final_pdf);
exit();
}
}
?>