PluginProbe
E2Pdf – Export Pdf Tool for WordPress / 1.32.49
E2Pdf – Export Pdf Tool for WordPress v1.32.49
1.32.49 1.32.48 1.32.43 1.32.40 1.32.34 1.32.32 1.32.31 1.32.26 1.32.22 1.32.23 1.32.18 1.32.17 1.32.15 trunk 1.00.00 1.00.13 1.01.01 1.02.02 1.03.07 1.04.07 1.05.03 1.06.02 1.07.11 1.08.00 1.08.06 All 72 releases
e2pdf / classes / helper / e2pdf-filter.php

e2pdf-filter.php in E2Pdf – Export Pdf Tool for WordPress 1.32.49, at classes/helper/e2pdf-filter.php

70 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * File: /helper/e2pdf-filter.php
5 *
6 * @package E2Pdf
7 * @license GPLv3
8 * @link https://e2pdf.com
9 */
10 if (!defined('ABSPATH')) {
11 die('Access denied.');
12 }
13
14 class Helper_E2pdf_Filter {
15
16 // is stream
17 public function is_stream($file_path) {
18 if (strpos($file_path, '://') > 0) {
19 $wrappers = array(
20 'phar',
21 );
22 if (function_exists('stream_get_wrappers')) {
23 $wrappers = stream_get_wrappers();
24 }
25
26 foreach ($wrappers as $wrapper) {
27 if (in_array($wrapper, ['http', 'https', 'file'], true)) {
28 continue;
29 }
30 if (stripos($file_path, $wrapper . '://') === 0) {
31 return true;
32 }
33 }
34 }
35 return false;
36 }
37
38 // is downloadable
39 public function is_downloadable($file_path) {
40 if (!$file_path || !$this->is_downloadable_ext($file_path)) {
41 return false;
42 }
43 return true;
44 }
45
46 // is downlodable ext
47 public function is_downloadable_ext($file_path) {
48 $ext = strtolower(pathinfo($file_path, PATHINFO_EXTENSION));
49 $allowed = apply_filters(
50 'e2pdf_helper_filter_is_downloadable_allowed_extensions',
51 ['pdf', 'jpg', 'doc', 'docx']
52 );
53 return in_array($ext, $allowed, true);
54 }
55
56 // filter html tags
57 public function filter_html_tags($value) {
58 if ($value) {
59 $tags = array(
60 'script',
61 'style',
62 );
63 foreach ($tags as $tag) {
64 $value = preg_replace('#<' . $tag . '(.*?)>(.*?)</' . $tag . '>#is', '', $value);
65 }
66 }
67 return $value;
68 }
69 }
70