-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreview.php
executable file
·40 lines (40 loc) · 1.29 KB
/
preview.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
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if( isset($_GET['id'])) {
$id_template = sanitize_text_field( $_GET['id'] );
$type = "preview";
if( isset($_GET["download"]) ){
$type = "download";
}
if( isset($_GET["html"]) ){
$type = "html";
}
$name ="pdf_name";
if( isset($_GET["pdf_name"]) ){
$name = sanitize_text_field($_GET["pdf_name"]);
$name = urldecode($name);
$name = sanitize_file_name($name);
}
$user = wp_get_current_user();
$allowed_roles = array('editor', 'administrator', 'author',"shop_manager");
$check = false;
if ( isset( $_REQUEST['_wpnonce']) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'pdf_creator' ) ) {
$check = true;
}
if( array_intersect($allowed_roles, $user->roles ) ) {
$check = true;
}
if( $check ){
$order_id = "";
if( isset($_GET["woo_order"]) ) {
$order_id = sanitize_text_field( $_GET['woo_order'] );
}
$data_send_settings = array(
"id_template"=> $id_template,
"type"=> $type,
"woo_order_id" =>$order_id,
"name" => $name
);
Yeepdf_Create_PDF::pdf_creator_preview($data_send_settings);
}
}