-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
56 lines (48 loc) · 1.54 KB
/
functions.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
<?php
function download(){
?>
<script type="text/javascript">
function SaveToDisk(fileURL, fileName) {
// for non-IE
/* if (!window.ActiveXObject) {
var save = document.createElement('a');
save.href = fileURL;
save.target = '_blank';
save.download = fileName || 'unknown';
var evt = new MouseEvent('click', {
'view': window,
'bubbles': true,
'cancelable': false
});
save.dispatchEvent(evt);
(window.URL || window.webkitURL).revokeObjectURL(save.href);
}
// for IE < 11
else if ( !! window.ActiveXObject && document.execCommand) {
var _window = window.open(fileURL, '_blank');
_window.document.close();
_window.document.execCommand('SaveAs', true, fileName || fileURL)
_window.close();
}
*/
var a = document.createElement("a");
a.href = fileURL;
fileName = fileURL.split("/").pop();
a.download = fileName;
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
a.remove();
}
var downloadURL = 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf';
document.addEventListener( 'wpcf7mailsent', function( event ) {
if ( '25' == event.detail.contactFormId ) {
var m = /[^/]*$/.exec(downloadURL)[0];
SaveToDisk(downloadURL, m);
}
}, false );
//document.addEventListener( 'wpcf7submit', function( event ) { alert( "Fire!" ); location = 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf'; }, true );
</script>
<?php
}
add_action('wp_footer', "download");