PluginProbe
E2Pdf – Export Pdf Tool for WordPress / 1.32.51
E2Pdf – Export Pdf Tool for WordPress v1.32.51
1.32.51 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 All 73 releases
← All changes | classes/extension/e2pdf-divi.php +214 -32 1.32.311.32.51 View file →
@@ -60,12 +60,32 @@
60 60
61 61 $meta_data = [];
62 62 if ($cached_entry && is_array($cached_entry)) {
63 63 // Divi5
64 - if (!empty($cached_entry['ET_CORE_VERSION'])) {
65 - foreach ($cached_entry as $field_key => $field_value) {
66 - $meta_data['%%' . $field_key . '%%'] = $field_value;
64 + if (!empty($cached_entry['E2PDF_VERSION'])) {
65 + foreach ($cached_entry['fields'] as $field_key => $field) {
66 + if (isset($field['type'])) {
67 + switch ($field['type']) {
68 + case 'signature-pad':
69 + $meta_data['%%' . $field_key . '%%'] = $this->pwh_dcfh_resolve_file_url($field['value'], $cached_entry['options']);
70 + break;
71 + case 'file':
72 + $attachments = is_array($field['value']) ? $field['value'] : explode(',', $field['value']);
73 + foreach ($attachments as $attachment_key => $attachment) {
74 + $attachments[$attachment_key] = $this->pwh_dcfh_resolve_file_url($attachment, $cached_entry['options']);
75 + }
76 + $meta_data['%%' . $field_key . '%%'] = implode(',', $attachments);
77 + break;
78 + default:
79 + $meta_data['%%' . $field_key . '%%'] = is_array($field['value']) ? implode(', ', $field['value']) : $field['value'];
80 + break;
81 + }
82 + }
67 83 }
84 + } elseif (!empty($cached_entry['ET_CORE_VERSION'])) {
85 + foreach ($cached_entry as $field_key => $value) {
86 + $meta_data['%%' . $field_key . '%%'] = is_array($value) ? implode(', ', $value) : $value;
87 + }
68 88 if (!isset($meta_data['%%e2pdf_entry_id%%'])) {
69 89 $meta_data['%%e2pdf_entry_id%%'] = (int) $this->get('dataset');
70 90 }
71 91 } else {
@@ -241,9 +261,8 @@
241 261 $forms[$label] = $label;
242 262 }
243 263 }
244 264 }
245 -
246 265 return $forms;
247 266 }
248 267
249 268 // datasets
@@ -392,9 +411,9 @@
392 411 'or' => [
393 412 [
394 413 'post_content' => [
395 414 'condition' => 'LIKE',
396 - 'value' => '%"meta":{"adminLabel":{"desktop":{"value":"' . $item_id . '"}}}%',
415 + 'value' => '%"meta":{"adminLabel":{"desktop":{"value":"' . $item_id . '"%',
397 416 'type' => '%s',
398 417 ],
399 418 ],
400 419 ],
@@ -574,9 +593,9 @@
574 593 ]
575 594 );
576 595 }
577 596
578 - $fields = $xpath->query("//*[contains(@class, 'et_pb_contact_field_radio')]", $element);
597 + $fields = $xpath->query(".//*[contains(@class, 'et_pb_contact_field_radio')]", $element);
579 598 foreach ($fields as $field) {
580 599 $radio_label = $xpath->query('.//label', $field)->item(0);
581 600 $radio = $xpath->query(".//input[@type='radio']", $field)->item(0);
582 601
@@ -593,9 +612,9 @@
593 612 'top' => '5',
594 613 'width' => 'auto',
595 614 'height' => 'auto',
596 615 'value' => '%%' . $xml->get_node_value($radio, 'data-original_id') . '%%',
597 - 'option' => $xml->get_node_value($radio, 'value'),
616 + 'option' => sanitize_text_field($xml->get_node_value($radio, 'value')),
598 617 'group' => '%%' . $xml->get_node_value($radio, 'data-original_id') . '%%',
599 618 ],
600 619 ]
601 620 );
@@ -645,9 +664,9 @@
645 664 ]
646 665 );
647 666 }
648 667
649 - $fields = $xpath->query("//*[contains(@class, 'et_pb_contact_field_checkbox')]", $element);
668 + $fields = $xpath->query(".//*[contains(@class, 'et_pb_contact_field_checkbox')]", $element);
650 669 foreach ($fields as $field) {
651 670 $checkbox_label = $xpath->query('.//label', $field)->item(0);
652 671 $checkbox = $xpath->query(".//input[@type='checkbox']", $field)->item(0);
653 672
@@ -660,9 +679,9 @@
660 679 'top' => '5',
661 680 'width' => 'auto',
662 681 'height' => 'auto',
663 682 'value' => $name,
664 - 'option' => $xml->get_node_value($checkbox, 'value'),
683 + 'option' => sanitize_text_field($xml->get_node_value($checkbox, 'value')),
665 684 ],
666 685 ]
667 686 );
668 687
@@ -708,26 +727,58 @@
708 727 );
709 728 }
710 729
711 730 if ($input_text) {
712 - $elements[] = $this->auto_field(
713 - $input_text,
714 - [
715 - 'type' => 'e2pdf-input',
716 - 'class' => $xml->get_node_value($input_text, 'class'),
717 - 'properties' => [
718 - 'top' => '5',
719 - 'width' => '100%',
720 - 'height' => 'auto',
721 - 'value' => '%%' . $xml->get_node_value($input_text, 'data-original_id') . '%%',
722 - ],
723 - ]
724 - );
731 + $data_type = $input_text->parentNode->getAttribute('data-type');
732 + if ($data_type === 'signature-pad') {
733 + $elements[] = $this->auto_field(
734 + $input_text,
735 + [
736 + 'type' => 'e2pdf-signature',
737 + 'properties' => [
738 + 'top' => '5',
739 + 'width' => '100%',
740 + 'height' => '150',
741 + 'dimension' => '1',
742 + 'block_dimension' => '1',
743 + 'value' => '%%' . $xml->get_node_value($input_text, 'data-original_id') . '%%',
744 + ],
745 + ]
746 + );
747 + } elseif ($data_type === 'file') {
748 + $elements[] = $this->auto_field(
749 + $input_text,
750 + [
751 + 'type' => 'e2pdf-textarea',
752 + 'class' => $xml->get_node_value($input_text, 'class'),
753 + 'properties' => [
754 + 'top' => '5',
755 + 'width' => '100%',
756 + 'height' => '150',
757 + 'value' => '%%' . $xml->get_node_value($input_text, 'data-original_id') . '%%',
758 + ],
759 + ]
760 + );
761 + } else {
762 + $elements[] = $this->auto_field(
763 + $input_text,
764 + [
765 + 'type' => 'e2pdf-input',
766 + 'class' => $xml->get_node_value($input_text, 'class'),
767 + 'properties' => [
768 + 'top' => '5',
769 + 'width' => '100%',
770 + 'height' => 'auto',
771 + 'value' => '%%' . $xml->get_node_value($input_text, 'data-original_id') . '%%',
772 + ],
773 + ]
774 + );
775 + }
725 776 } elseif ($select) {
726 777 $options_tmp = [];
727 778 $options = $xpath->query('.//option', $select);
728 779 foreach ($options as $option) {
729 - $options_tmp[] = $xml->get_node_value($option, 'value');
780 + $options_tmp[] = sanitize_text_field($xml->get_node_value($option, 'value'));
730 781 }
731 782
732 783 $elements[] = $this->auto_field(
733 784 $select,
@@ -966,8 +1017,9 @@
966 1017 foreach ($fields as $xml_element) {
967 1018 $xml->set_node_value($xml_element, 'name', '%%' . $xml->get_node_value($xml_element, 'data-original_id') . '%%');
968 1019 }
969 1020
1021 + // checkboxes
970 1022 $checkboxes = $xpath->query("//*[contains(@class, 'et_pb_contact_field') and @data-type='checkbox']");
971 1023 foreach ($checkboxes as $xml_element) {
972 1024 $check_handler = $xpath->query(".//input[contains(@class, 'et_pb_checkbox_handle')]", $xml_element)->item(0);
973 1025 $name = '';
@@ -976,16 +1028,35 @@
976 1028 }
977 1029 $checks = $xpath->query(".//input[@type='checkbox']", $xml_element);
978 1030 foreach ($checks as $check) {
979 1031 $xml->set_node_value($check, 'name', $name);
1032 + $xml->set_node_value($check, 'value', sanitize_text_field($xml->get_node_value($check, 'value')));
980 1033 }
981 1034 }
982 1035
1036 + // uploads
1037 + $uploads = $xpath->query("//*[contains(@class, 'et_pb_contact_hidden_files')]");
1038 + foreach ($uploads as $xml_element) {
1039 + $xml->set_node_value($xml_element, 'type', 'file');
1040 + }
1041 +
1042 + $radios = $xpath->query("//input[@type='radio']");
1043 + foreach ($radios as $xml_element) {
1044 + $xml->set_node_value($xml_element, 'value', sanitize_text_field($xml->get_node_value($xml_element, 'value')));
1045 + }
1046 +
1047 + $selects = $xpath->query('//select/option');
1048 + foreach ($selects as $xml_element) {
1049 + $xml->set_node_value($xml_element, 'value', sanitize_text_field($xml->get_node_value($xml_element, 'value')));
1050 + }
1051 +
983 1052 // remove by class
984 1053 $remove_by_class = [
985 1054 'et_pb_contact_submit',
986 1055 'et_pb_contactform_validate_field',
987 1056 'et_pb_checkbox_handle',
1057 + 'et_pb_form_bottom_stepper_container',
1058 + 'stepper__progress',
988 1059 ];
989 1060 foreach ($remove_by_class as $key => $class) {
990 1061 $xml_elements = $xpath->query("//*[contains(@class, '{$class}')]");
991 1062 foreach ($xml_elements as $xml_element) {
@@ -992,8 +1063,13 @@
992 1063 $xml_element->parentNode->removeChild($xml_element);
993 1064 }
994 1065 }
995 1066
1067 + $xml_elements = $xpath->query('//*[@data-step]');
1068 + foreach ($xml_elements as $xml_element) {
1069 + $xml_element->removeAttribute('style');
1070 + }
1071 +
996 1072 // remove parent by class
997 1073 $remove_parent_by_class = [
998 1074 'et_pb_contact_captcha_question',
999 1075 ];
@@ -1142,8 +1218,15 @@
1142 1218
1143 1219 $module_id = !empty($filter_args['id']) ? $filter_args['id'] : '';
1144 1220 $store_instance = !empty($filter_args['storeInstance']) ? $filter_args['storeInstance'] : 0;
1145 1221
1222 + if (
1223 + !class_exists('\ET\Builder\FrontEnd\BlockParser\BlockParserStore') ||
1224 + !method_exists('\ET\Builder\FrontEnd\BlockParser\BlockParserStore', 'get')
1225 + ) {
1226 + return $module_attrs;
1227 + }
1228 +
1146 1229 $module = \ET\Builder\FrontEnd\BlockParser\BlockParserStore::get($module_id, $store_instance);
1147 1230
1148 1231 if (!$module) {
1149 1232 return $module_attrs;
@@ -1244,19 +1327,45 @@
1244 1327 if (!$this->get('process')) {
1245 1328 return $module_attrs;
1246 1329 }
1247 1330
1331 + if (
1332 + !class_exists('\ET\Builder\Packages\ModuleLibrary\ModuleRegistration') ||
1333 + !method_exists('\ET\Builder\Packages\ModuleLibrary\ModuleRegistration', 'get_default_attrs')) {
1334 + return $module_attrs;
1335 + }
1336 +
1248 1337 $fields_raw = [];
1249 -
1338 + $filtered_field_attrs = [];
1250 1339 $fields = \ET\Builder\FrontEnd\BlockParser\BlockParserStore::get_children($module_id, $store_instance);
1340 + $default_child_attrs = \ET\Builder\Packages\ModuleLibrary\ModuleRegistration::get_default_attrs(
1341 + 'divi/contact-field'
1342 + );
1251 1343 foreach ($fields as $field) {
1252 1344 // Skip nested modules (Text, Button, Divider, etc.), only process Contact Field modules.
1253 1345 if ('divi/contact-field' !== $field->blockName) { // phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase -- This is a property of the WP Core class.
1254 1346 continue;
1255 1347 }
1348 + $merged_child_attrs = array_replace_recursive(
1349 + $default_child_attrs,
1350 + $field->attrs ?? []
1351 + );
1352 + $child_filter_args = [
1353 + 'id' => $field->id,
1354 + 'name' => $field->blockName,
1355 + 'parentId' => $module_id,
1356 + 'parentName' => 'divi/contact-form',
1357 + 'parentAttrs' => $module_attrs,
1358 + 'storeInstance' => $store_instance,
1359 + ];
1360 + $filtered_field_attrs[$field->id] = apply_filters(
1361 + 'divi_module_library_register_module_attrs',
1362 + $merged_child_attrs,
1363 + $child_filter_args
1364 + );
1256 1365
1257 1366 // Use pre-filtered field attributes if provided, otherwise use field attributes from storage.
1258 - $field_attrs = $field->attrs;
1367 + $field_attrs = !empty($filtered_field_attrs[$field->id]) ? $filtered_field_attrs[$field->id] : $field->attrs;
1259 1368 $field_unique_id = \ET\Builder\Packages\ModuleLibrary\ContactField\ContactFieldModule::get_field_unique_id($field->id, $store_instance);
1260 1369 $field_type = $field_attrs['fieldItem']['advanced']['type']['desktop']['value'] ?? 'input';
1261 1370 $field_id = $field_attrs['fieldItem']['advanced']['id']['desktop']['value'] ?? '';
1262 1371 $field_key = strtolower($field_id);
@@ -1349,9 +1458,8 @@
1349 1458 return $module_attrs;
1350 1459 }
1351 1460
1352 1461 $obj->validate_fields();
1353 -
1354 1462 $errorObj = $refError->getValue($obj);
1355 1463
1356 1464 if ($errorObj->has_errors()) {
1357 1465 return $module_attrs;
@@ -1364,19 +1472,32 @@
1364 1472 return $module_attrs;
1365 1473 }
1366 1474
1367 1475 $data = [
1368 - 'ET_CORE_VERSION' => '5',
1476 + 'E2PDF_VERSION' => '1.32.40',
1477 + 'fields' => [],
1478 + 'options' => [
1479 + 'timestamp' => current_time('mysql'),
1480 + 'saveFilesToMedia' => !empty($module_attrs['entryPreferences']['advanced']['saveFilesToMedia']['desktop']['value']) ? $module_attrs['entryPreferences']['advanced']['saveFilesToMedia']['desktop']['value'] : '',
1481 + 'uniqueId' => !empty($module_attrs['module']['advanced']['uniqueId']['desktop']['value']) ? $module_attrs['module']['advanced']['uniqueId']['desktop']['value'] : '',
1482 + ],
1369 1483 ];
1484 +
1370 1485 if (!empty($fields_raw) && is_array($fields_raw)) {
1371 1486 foreach ($fields_raw as $field_key => $field_raw) {
1372 - if (!empty($field_raw['value'])) {
1373 - $data[$field_key] = $field_raw['value'];
1487 + if (isset($field_raw['value'])) {
1488 + $data['fields'][$field_key] = [
1489 + 'type' => isset($field_raw['type']) ? $field_raw['type'] : '',
1490 + 'value' => $field_raw['value'],
1491 + ];
1374 1492 }
1375 1493 }
1376 1494 }
1377 - if (empty($data['_wp_http_referer']) && !empty($_POST['_wp_http_referer'])) {
1378 - $data['_wp_http_referer'] = esc_url_raw($_POST['_wp_http_referer']);
1495 + if (empty($data['fields']['_wp_http_referer']) && !empty($_POST['_wp_http_referer'])) {
1496 + $data['fields']['_wp_http_referer'] = [
1497 + 'type' => '',
1498 + 'value' => esc_url_raw($_POST['_wp_http_referer']),
1499 + ];
1379 1500 }
1380 1501
1381 1502 $entry = new Model_E2pdf_Dataset();
1382 1503 $entry->set('extension', 'divi');
@@ -1628,9 +1749,16 @@
1628 1749 $et_contact_error = true;
1629 1750 }
1630 1751
1631 1752 if (!$et_contact_error && $nonce_result) {
1632 -
1753 + // divi contact form helper 2.1.3 bug fix wp_mail filter removed at maybe_filter_wp_mail
1754 + if (defined('KS_PAC_DCFH_PLUGIN_VERSION') && version_compare(KS_PAC_DCFH_PLUGIN_VERSION, '2.1.3', '>=')) {
1755 + add_filter(
1756 + 'wp_mail', function ($args) {
1757 + return $args;
1758 + }, 999
1759 + );
1760 + }
1633 1761 add_filter('wp_mail', [$this, 'filter_wp_mail'], 1000);
1634 1762
1635 1763 $dataset = false;
1636 1764 if (false !== strpos($success_message, '[')) {
@@ -1973,6 +2101,60 @@
1973 2101
1974 2102 // is divi 5 form
1975 2103 public function divi5_form($content = '') {
1976 2104 return (false !== strpos($content, 'wp:divi/contact-form'));
2105 + }
2106 +
2107 + // pwh dcfh resolve file url
2108 + public function pwh_dcfh_resolve_file_url($file, $options) {
2109 +
2110 + if (!$file) {
2111 + return $file;
2112 + }
2113 +
2114 + if (!function_exists('ks_pac_dcfh_app') || !function_exists('path_join')) {
2115 + return $file;
2116 + }
2117 +
2118 + $contact_form_id = $options['uniqueId'];
2119 + $timestamp = strtotime($options['timestamp']);
2120 + $saveFilesToMedia = $options['saveFilesToMedia'] === 'on' ? true : false;
2121 +
2122 + $upload_dir = path_join(
2123 + 'pwh-dcfh-uploads',
2124 + 'forms/' . $contact_form_id . '/'
2125 + );
2126 + $upload_path = ks_pac_dcfh_app()->file_utils()::get_wp_upload_dir(
2127 + $upload_dir,
2128 + 'basedir'
2129 + );
2130 + $upload_url = ks_pac_dcfh_app()->file_utils()::get_wp_upload_dir(
2131 + $upload_dir,
2132 + 'baseurl'
2133 + );
2134 + if ($saveFilesToMedia) {
2135 + $wp_upload_dir = wp_upload_dir();
2136 + $upload_path = $wp_upload_dir['basedir'];
2137 + $upload_url = $wp_upload_dir['baseurl'];
2138 + }
2139 + $dates = [
2140 + date('Y/m', $timestamp),
2141 + date('Y/m', strtotime('-1 month', $timestamp)),
2142 + date('Y/m', strtotime('+1 month', $timestamp)),
2143 + ];
2144 +
2145 + foreach ($dates as $date) {
2146 + $date_path = path_join(
2147 + $upload_path,
2148 + $date
2149 + );
2150 + if (@file_exists(path_join($date_path, $file))) {
2151 + $file = path_join(
2152 + trailingslashit($upload_url) . $date,
2153 + $file
2154 + );
2155 + break;
2156 + }
2157 + }
2158 + return $file;
1977 2159 }
1978 2160 }