PluginProbe
E2Pdf – Export Pdf Tool for WordPress / 1.01.01
E2Pdf – Export Pdf Tool for WordPress v1.01.01
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 / extension / e2pdf-divi.php

e2pdf-divi.php in E2Pdf – Export Pdf Tool for WordPress 1.01.01, at classes/extension/e2pdf-divi.php

1,447 lines 61.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * E2pdf Divi Extension
5 *
6 * @copyright Copyright 2017 https://e2pdf.com
7 * @license GPL v2
8 * @version 1
9 * @link https://e2pdf.com
10 * @since 0.00.01
11 */
12 if (!defined('ABSPATH')) {
13 die('Access denied.');
14 }
15
16 class Extension_E2pdf_Divi extends Model_E2pdf_Model {
17
18 private $options;
19
20 function __construct() {
21 parent::__construct();
22 }
23
24 /**
25 * Get info about extension
26 *
27 * @return array() - Extension key and name
28 */
29 public function info() {
30 return array(
31 'divi' => __('Divi', 'e2pdf')
32 );
33 }
34
35 /**
36 * Check if needed plugin active
37 *
38 * @return bool - Activated/Not Activated plugin
39 */
40 public function active() {
41 if (file_exists(get_template_directory() . "/et-pagebuilder/et-pagebuilder.php")) {
42 require_once(get_template_directory() . "/et-pagebuilder/et-pagebuilder.php");
43 if (defined('ET_BUILDER_THEME')) {
44 return true;
45 }
46 }
47 return false;
48 }
49
50 /**
51 * Check if export item function available
52 *
53 * @return bool - Item export available/not available
54 */
55 public function export() {
56 return false;
57 }
58
59 /**
60 * Set option
61 *
62 * @param string $attr - Key of option
63 * @param string $value - Value of option
64 *
65 * @return bool - Status of setting option
66 */
67 public function set($key, $value) {
68 if (!isset($this->options)) {
69 $this->options = new stdClass();
70 }
71
72 $this->options->$key = $value;
73 }
74
75 /**
76 * Get option by key
77 *
78 * @param string $key - Key to get assigned option value
79 *
80 * @return mixed
81 */
82 public function get($key) {
83 if (isset($this->options->$key)) {
84 $value = $this->options->$key;
85 return $value;
86 } else {
87 return false;
88 }
89 }
90
91 /**
92 * Get items to work with
93 *
94 * @return array() - List of available items
95 */
96 public function get_items() {
97 global $wpdb;
98
99 $helper_e2pdf_db = new Helper_E2pdf_Db();
100
101 $condition = array(
102 'post_content' => array(
103 'condition' => 'LIKE',
104 'value' => '%et_pb_contact_form%',
105 'type' => '%s'
106 ),
107 'post_type' => array(
108 'condition' => '<>',
109 'value' => array(
110 'revision',
111 'et_pb_layout'
112 ),
113 'type' => '%s'
114 ),
115 );
116
117 $order_condition = array(
118 'orderby' => 'id',
119 'order' => 'desc',
120 );
121
122 $where = $helper_e2pdf_db->prepare_where($condition);
123 $orderby = $helper_e2pdf_db->prepare_orderby($order_condition);
124
125 $posts = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . 'posts' . $where['sql'] . $orderby . "", $where['filter']));
126
127 $forms = array();
128 foreach ($posts as $key => $post) {
129 if ($forms_labels = $this->get_forms($post->post_content)) {
130
131 foreach ($forms_labels as $form_key => $form_value) {
132 $forms[] = array(
133 'key' => $form_key,
134 'value' => $form_value
135 );
136 }
137 }
138 }
139 return $forms;
140 }
141
142 /**
143 * Parse available forms from pages
144 *
145 * @param string $content - Page content
146 *
147 * @return array() - Forms list
148 */
149 public function get_forms($content) {
150
151 $forms = array();
152 if (false !== strpos($content, 'et_pb_contact_form')) {
153 $shortcode_tags = array(
154 'et_pb_contact_form',
155 );
156
157 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches);
158 $tagnames = array_intersect($shortcode_tags, $matches[1]);
159
160 if (!empty($tagnames)) {
161 $pattern = get_shortcode_regex($tagnames);
162
163 preg_match_all("/$pattern/", $content, $shortcodes);
164 foreach ($shortcodes[0] as $key => $shortcode_value) {
165
166 $shortcode = array();
167 $shortcode[1] = $shortcodes[1][$key];
168 $shortcode[2] = $shortcodes[2][$key];
169 $shortcode[3] = $shortcodes[3][$key];
170 $shortcode[4] = $shortcodes[4][$key];
171 $shortcode[5] = $shortcodes[5][$key];
172 $shortcode[6] = $shortcodes[6][$key];
173
174 preg_match_all('/admin_label="(.*?)"/', $shortcode[3], $labels);
175 if (isset($labels['1'])) {
176 foreach ($labels['1'] as $label) {
177 $forms[$label] = $label;
178 }
179 }
180 }
181 }
182 }
183
184 return $forms;
185 }
186
187 /**
188 * Get entries for export
189 *
190 * @param string $item - Item
191 * @param string $name - Entries names
192 *
193 * @return array() - Entries list
194 */
195 public function get_datasets($item = false, $name = false) {
196
197 global $wpdb;
198
199 $datasets = array();
200
201 if ($item) {
202 $helper_e2pdf_db = new Helper_E2pdf_Db();
203 $condition = array(
204 'extension' => array(
205 'condition' => '=',
206 'value' => 'divi',
207 'type' => '%s'
208 ),
209 'item' => array(
210 'condition' => '=',
211 'value' => $item,
212 'type' => '%s'
213 ),
214 );
215
216 $order_condition = array(
217 'orderby' => 'ID',
218 'order' => 'desc',
219 );
220
221 $where = $helper_e2pdf_db->prepare_where($condition);
222 $orderby = $helper_e2pdf_db->prepare_orderby($order_condition);
223
224 $datasets_tmp = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . 'e2pdf_datasets' . $where['sql'] . $orderby . "", $where['filter']));
225
226 if ($datasets_tmp) {
227 foreach ($datasets_tmp as $key => $dataset) {
228 $this->set('item', $item);
229 $this->set('dataset', $dataset->ID);
230 $dataset_title = $this->render($name);
231 if (!$dataset_title) {
232 $dataset_title = $dataset->ID;
233 }
234 $datasets[] = array(
235 'key' => $dataset->ID,
236 'value' => $dataset_title
237 );
238 }
239 }
240 }
241
242 return $datasets;
243 }
244
245 /**
246 * Get dataset
247 *
248 * @param int $dataset - Dataset ID
249 *
250 * @return object - Dataset
251 */
252 public function get_dataset($dataset = false) {
253
254 $dataset = (int) $dataset;
255
256 if (!$dataset) {
257 return;
258 }
259
260 $data = new stdClass();
261 $data->url = false;
262
263 return $data;
264 }
265
266 /**
267 * Get item
268 *
269 * @param string $item - Item
270 *
271 * @return object - Item
272 */
273 public function get_item($item = false) {
274
275 $form = new stdClass();
276
277 if ($item) {
278 $form->name = $item;
279 $post = $this->get_post($item);
280 $form->url = isset($post->ID) ? $this->helper->get_url(array('post' => $post->ID, 'action' => 'edit'), 'post.php?') : 'javascript:void(0);';
281 } else {
282 $form->name = '';
283 $form->url = 'javascript:void(0);';
284 }
285 return $form;
286 }
287
288 /**
289 * Get post
290 *
291 * @param string $item_id - Form label
292 *
293 * @return object - Post
294 */
295 public function get_post($item_id = false) {
296 global $wpdb;
297
298 $item_post = false;
299 $helper_e2pdf_db = new Helper_E2pdf_Db();
300
301 $condition = array(
302 'post_content' => array(
303 'condition' => 'LIKE',
304 'value' => '%admin_label="' . $item_id . '"%',
305 'type' => '%s'
306 ),
307 'post_type' => array(
308 'condition' => '<>',
309 'value' => array(
310 'revision',
311 'et_pb_layout'
312 ),
313 'type' => '%s'
314 ),
315 );
316
317 $order_condition = array(
318 'orderby' => 'id',
319 'order' => 'desc',
320 );
321
322 $where = $helper_e2pdf_db->prepare_where($condition);
323 $orderby = $helper_e2pdf_db->prepare_orderby($order_condition);
324
325 $posts = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . 'posts' . $where['sql'] . $orderby . "", $where['filter']));
326 foreach ($posts as $key => $post) {
327 if ($forms_labels = $this->get_forms($post->post_content)) {
328 if (in_array($item_id, $forms_labels)) {
329 $item_post = $post;
330 break;
331 }
332 }
333 }
334 return $item_post;
335 }
336
337 /**
338 * Render value according to content
339 *
340 * @param string $value - Content
341 * @param string $type - Type of rendering value
342 * @param array $field - Field details
343 *
344 * @return string - Fully rendered value
345 */
346 public function render($value, $type = false, $field = array()) {
347
348 $value = $this->render_shortcodes($value, $type, $field);
349 $value = $this->strip_shortcodes($value);
350
351 if ($type === 'value' && isset($field['type']) && $field['type'] === 'e2pdf-checkbox' && isset($field['properties']['option'])) {
352 $option = $this->render($field['properties']['option']);
353 $options = explode(', ', $value);
354 $option_options = explode(', ', $option);
355 if (is_array($options) && is_array($option_options) && !array_diff($option_options, $options)) {
356 return $option;
357 } else {
358 return "";
359 }
360 }
361
362 return $value;
363 }
364
365 /**
366 * Render shortcodes which available in this extension
367 *
368 * @param string $value - Content
369 * @param string $type - Type of rendering value
370 * @param array $field - Field details
371 *
372 * @return string - Value with rendered shortcodes
373 */
374 public function render_shortcodes($value, $type = false, $field = array()) {
375 global $wpdb;
376
377 $dataset_id = $this->get('dataset');
378 $item_id = $this->get('item');
379
380 $condition = array(
381 'ID' => array(
382 'condition' => '=',
383 'value' => $dataset_id,
384 'type' => '%d'
385 ),
386 'item' => array(
387 'condition' => '=',
388 'value' => $item_id,
389 'type' => '%s'
390 ),
391 'extension' => array(
392 'condition' => '=',
393 'value' => 'divi',
394 'type' => '%s'
395 ),
396 );
397
398 $helper_e2pdf_db = new Helper_E2pdf_Db();
399 $where = $helper_e2pdf_db->prepare_where($condition);
400
401 $dataset = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . 'e2pdf_datasets' . $where['sql'] . "", $where['filter']));
402
403 $processed_fields_values = array();
404 if ($dataset) {
405 $post = unserialize($dataset->entry);
406 if ($post && is_array($post)) {
407
408 $et_pb_contact_form_num = 0;
409
410 $current_form_fields = isset($post['et_pb_contact_email_fields_' . $et_pb_contact_form_num]) ? $post['et_pb_contact_email_fields_' . $et_pb_contact_form_num] : '';
411 $hidden_form_fields = isset($post['et_pb_contact_email_hidden_fields_' . $et_pb_contact_form_num]) ? $post['et_pb_contact_email_hidden_fields_' . $et_pb_contact_form_num] : false;
412 $processed_fields_values = array();
413
414 if ('' !== $current_form_fields) {
415 $fields_data_json = str_replace('\\', '', $current_form_fields);
416 $fields_data_array = json_decode($fields_data_json, true);
417
418 if (!empty($fields_data_array)) {
419 foreach ($fields_data_array as $index => $field_value) {
420 $processed_fields_values[$field_value['original_id']]['value'] = isset($post[$field_value['field_id']]) ? $post[$field_value['field_id']] : '';
421 $processed_fields_values[$field_value['original_id']]['label'] = $field_value['field_label'];
422 }
423 }
424 }
425 }
426
427 if (false !== strpos($value, '[')) {
428
429 $shortcode_tags = array(
430 'e2pdf-format-number',
431 'e2pdf-format-date',
432 'e2pdf-format-output',
433 );
434 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $value, $matches);
435 $tagnames = array_intersect($shortcode_tags, $matches[1]);
436
437 if (!empty($tagnames)) {
438
439 $pattern = get_shortcode_regex($tagnames);
440 preg_match_all("/$pattern/", $value, $shortcodes);
441 foreach ($shortcodes[0] as $key => $shortcode_value) {
442 $shortcode = array();
443 $shortcode[1] = $shortcodes[1][$key];
444 $shortcode[2] = $shortcodes[2][$key];
445 $shortcode[3] = $shortcodes[3][$key];
446 $shortcode[4] = $shortcodes[4][$key];
447 $shortcode[5] = $shortcodes[5][$key];
448 $shortcode[6] = $shortcodes[6][$key];
449
450 if (isset($shortcode['5'])) {
451 foreach ($processed_fields_values as $field_key => $field_value) {
452 $shortcode['5'] = str_ireplace("%%{$field_key}%%", wp_strip_all_tags($field_value['value']), $shortcode['5']);
453 }
454 $sub_value = $this->strip_shortcodes($shortcode['5']);
455 $value = str_replace($shortcode_value, "[" . $shortcode['2'] . $shortcode['3'] . "]" . $sub_value . "[/" . $shortcode['2'] . "]", $value);
456 }
457 }
458 }
459 }
460
461 $value = do_shortcode($value);
462
463 if ($dataset) {
464 foreach ($processed_fields_values as $field_key => $field_value) {
465 $value = str_ireplace("%%{$field_key}%%", wp_strip_all_tags($field_value['value']), $value);
466 }
467 }
468
469 if (isset($field['type']) && ($field['type'] === 'e2pdf-image' || $field['type'] === 'e2pdf-signature')) {
470 $esig = isset($field['properties']['esig']) && $field['properties']['esig'] ? true : false;
471 if ($esig) {
472 //process e-signature
473 $value = "";
474 } else {
475 $helper_e2pdf_image = new Helper_E2pdf_Image();
476 if (!$helper_e2pdf_image->get_image($value)) {
477 $value = $this->strip_shortcodes($value);
478 if (
479 $value &&
480 trim($value) != "" &&
481 extension_loaded('gd') &&
482 function_exists('imagettftext')
483 ) {
484 if (isset($field['properties']['text_color']) && $field['properties']['text_color']) {
485 $penColour = $this->helper->hexColorAllocate($field['properties']['text_color']);
486 } else {
487 $penColour = array(0x14, 0x53, 0x94);
488 }
489
490 $default_options = array(
491 'imageSize' => array(isset($field['width']) ? $field['width'] : '400', isset($field['height']) ? $field['height'] : '150'),
492 'bgColour' => 'transparent',
493 'penColour' => $penColour
494 );
495
496 $options = array();
497 $options = array_merge($default_options, $options);
498
499 $model_e2pdf_font = new Model_E2pdf_Font();
500
501 $font = false;
502 if (isset($field['properties']['text_font']) && $field['properties']['text_font']) {
503 $font = $model_e2pdf_font->get_font_path($field['properties']['text_font']);
504 }
505 if (!$font) {
506 $font = $model_e2pdf_font->get_font_path('Noto Sans');
507 }
508
509 $size = 150;
510 if (isset($field['properties']['text_font_size']) && $field['properties']['text_font_size']) {
511 $size = $field['properties']['text_font_size'];
512 }
513
514 $model_e2pdf_signature = new Model_E2pdf_Signature();
515 $value = $model_e2pdf_signature->ttf_signature($value, $size, $font, $options);
516 } else {
517 $value = "";
518 }
519 }
520 }
521 }
522 }
523
524 return $value;
525 }
526
527 /**
528 * Strip unused shortcodes
529 *
530 * @param string $value - Content
531 *
532 * @return string - Value with removed unused shortcodes
533 */
534 public function strip_shortcodes($value) {
535 $value = preg_replace('~(?:\[/?)[^/\]]+/?\]~s', "", $value);
536 $value = preg_replace('~(?:%%/?)[^/%%]+/?%%~', "", $value);
537 return $value;
538 }
539
540 public function auto() {
541
542 $response = array();
543 $elements = array();
544
545 if ($this->get('item')) {
546 $post = $this->get_post($this->get('item'));
547 if ($post && isset($post->post_content)) {
548
549 $content = $post->post_content;
550
551 if (false !== strpos($content, '[')) {
552 $shortcode_tags = array(
553 'et_pb_contact_form',
554 );
555
556 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches);
557 $tagnames = array_intersect($shortcode_tags, $matches[1]);
558
559 if (!empty($tagnames)) {
560 $pattern = get_shortcode_regex($tagnames);
561
562 preg_match_all("/$pattern/", $content, $shortcodes);
563
564 foreach ($shortcodes[0] as $key => $shortcode_value) {
565
566 $shortcode = array();
567 $shortcode[1] = $shortcodes[1][$key];
568 $shortcode[2] = $shortcodes[2][$key];
569 $shortcode[3] = $shortcodes[3][$key];
570 $shortcode[4] = $shortcodes[4][$key];
571 $shortcode[5] = $shortcodes[5][$key];
572 $shortcode[6] = $shortcodes[6][$key];
573
574 $atts = shortcode_parse_atts($shortcode[3]);
575 if (isset($atts['admin_label']) && $atts['admin_label'] == $this->get('item')) {
576
577 require_once(ET_BUILDER_DIR . 'class-et-builder-element.php');
578 require_once(ET_BUILDER_DIR . 'functions.php');
579 require_once(ET_BUILDER_DIR . 'ab-testing.php');
580 require_once(ET_BUILDER_DIR . 'class-et-global-settings.php');
581 require_once(ET_BUILDER_DIR . 'module/ContactForm.php');
582 require_once(ET_BUILDER_DIR . 'module/ContactFormItem.php');
583
584 new ET_Builder_Module_Contact_Form();
585 new ET_Builder_Module_Contact_Form_Item();
586
587
588 $source = do_shortcode($shortcode_value);
589
590 libxml_use_internal_errors(true);
591 $dom = new DOMDocument;
592 $html = $dom->loadHTML($source);
593 libxml_clear_errors();
594
595 if ($html) {
596 $xpath = new DomXPath($dom);
597 $blocks = $xpath->query("//*[contains(@class, 'et_pb_contact_field')]");
598 foreach ($blocks as $element) {
599
600 $data_type = $element->attributes->getNamedItem("data-type")->nodeValue;
601
602 if ($data_type == 'radio') {
603
604 $label = $xpath->query(".//label", $element)->item(0);
605 $check_handler = $xpath->query(".//input[contains(@class, 'et_pb_checkbox_handle')]", $element)->item(0);
606
607 $name = "";
608 if ($check_handler) {
609 $name = "%%" . $check_handler->attributes->getNamedItem("data-original_id")->nodeValue . "%%";
610 }
611
612 $elements[] = $this->auto_field($element, 'e2pdf-html', array(
613 'top' => '20',
614 'left' => '20',
615 'right' => '20',
616 'block' => true,
617 'properties' => array(
618 'value' => $label->nodeValue,
619 )
620 ));
621
622 $top = 0;
623 $fields = $xpath->query("//*[contains(@class, 'et_pb_contact_field_radio')]", $element);
624
625 foreach ($fields as $field) {
626 $radio_label = $xpath->query(".//label", $field)->item(0);
627 $radio = $xpath->query(".//input[@type='radio']", $field)->item(0);
628
629 $elements[] = $this->auto_field($field, 'e2pdf-radio', array(
630 'top' => $top,
631 'properties' => array(
632 'width' => '15',
633 'height' => '15',
634 'value' => "%%" . $radio->attributes->getNamedItem("data-original_id")->nodeValue . "%%",
635 'option' => $radio->attributes->getNamedItem("value")->nodeValue,
636 'group' => $radio->attributes->getNamedItem("data-original_id")->nodeValue,
637 )
638 ));
639 $elements[] = $this->auto_field($radio, 'e2pdf-html', array(
640 'top' => $top,
641 'left' => '20',
642 'properties' => array(
643 'value' => $radio_label->nodeValue
644 )
645 ));
646
647 $top = $top + 20;
648 }
649 } elseif ($data_type == 'checkbox') {
650
651 $label = $xpath->query(".//label", $element)->item(0);
652 $check_handler = $xpath->query(".//input[contains(@class, 'et_pb_checkbox_handle')]", $element)->item(0);
653
654 $name = "";
655 if ($check_handler) {
656 $name = "%%" . $check_handler->attributes->getNamedItem("data-original_id")->nodeValue . "%%";
657 }
658
659
660 $elements[] = $this->auto_field($element, 'e2pdf-html', array(
661 'top' => '20',
662 'left' => '20',
663 'right' => '20',
664 'block' => true,
665 'properties' => array(
666 'value' => $label->nodeValue,
667 )
668 ));
669
670
671 $top = 0;
672 $fields = $xpath->query("//*[contains(@class, 'et_pb_contact_field_checkbox')]", $element);
673
674 foreach ($fields as $field) {
675 $checkbox_label = $xpath->query(".//label", $field)->item(0);
676 $checkbox = $xpath->query(".//input[@type='checkbox']", $field)->item(0);
677
678
679 $elements[] = $this->auto_field($field, 'e2pdf-checkbox', array(
680 'top' => $top,
681 'properties' => array(
682 'width' => '15',
683 'height' => '15',
684 'value' => $name,
685 'option' => $checkbox->attributes->getNamedItem("value")->nodeValue
686 )
687 ));
688 $elements[] = $this->auto_field($checkbox, 'e2pdf-html', array(
689 'top' => $top,
690 'left' => '20',
691 'properties' => array(
692 'value' => $checkbox_label->nodeValue
693 )
694 ));
695
696 $top = $top + 20;
697 }
698 } else {
699
700 $label = $xpath->query(".//label", $element)->item(0);
701 $input_text = $xpath->query(".//input[@type='text']", $element)->item(0);
702 $select = $xpath->query(".//select", $element)->item(0);
703 $textarea = $xpath->query(".//textarea", $element)->item(0);
704
705 if ($label && ($input_text || $select || $textarea)) {
706 $elements[] = $this->auto_field($element, 'e2pdf-html', array(
707 'top' => '20',
708 'left' => '20',
709 'right' => '20',
710 'block' => true,
711 'properties' => array(
712 'value' => $label->nodeValue,
713 )
714 ));
715 }
716
717
718 if ($input_text) {
719 $elements[] = $this->auto_field($input_text, 'e2pdf-input', array(
720 'properties' => array(
721 'value' => "%%{$input_text->attributes->getNamedItem("data-original_id")->nodeValue}%%",
722 )
723 ));
724 } elseif ($select) {
725 $options_tmp = array();
726 $options = $xpath->query(".//option", $select);
727 foreach ($options as $option) {
728 $options_tmp[] = $option->attributes->getNamedItem("value")->nodeValue;
729 }
730
731 $elements[] = $this->auto_field($select, 'e2pdf-select', array(
732 'properties' => array(
733 'options' => implode("\n", $options_tmp),
734 'value' => "%%{$select->attributes->getNamedItem("data-original_id")->nodeValue}%%",
735 )
736 ));
737 } elseif ($textarea) {
738 $elements[] = $this->auto_field($textarea, 'e2pdf-textarea', array(
739 'properties' => array(
740 'value' => "%%{$textarea->attributes->getNamedItem("data-original_id")->nodeValue}%%",
741 )
742 ));
743 }
744 }
745 }
746 }
747 }
748 }
749 }
750 }
751 }
752 }
753
754 $response['page'] = array(
755 'bottom' => '20',
756 'top' => '20',
757 );
758 $response['elements'] = $elements;
759
760 return $response;
761 }
762
763 /**
764 * Convert Field name to Value
765 * @since 0.01.34
766 *
767 * @param string $name - Field name
768 *
769 * @return bool|string - Converted value or false
770 */
771 public function auto_map($name = false) {
772 $item = $this->get('item');
773 if ($item) {
774 $post = $this->get_post($item);
775 if ($post && isset($post->post_content)) {
776 $content = $post->post_content;
777
778 if (false !== strpos($content, '[')) {
779 $shortcode_tags = array(
780 'et_pb_contact_form',
781 );
782
783 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches);
784 $tagnames = array_intersect($shortcode_tags, $matches[1]);
785
786 if (!empty($tagnames)) {
787 $pattern = get_shortcode_regex($tagnames);
788
789 preg_match_all("/$pattern/", $content, $shortcodes);
790
791 foreach ($shortcodes[0] as $key => $shortcode_value) {
792
793 $shortcode = array();
794 $shortcode[1] = $shortcodes[1][$key];
795 $shortcode[2] = $shortcodes[2][$key];
796 $shortcode[3] = $shortcodes[3][$key];
797 $shortcode[4] = $shortcodes[4][$key];
798 $shortcode[5] = $shortcodes[5][$key];
799 $shortcode[6] = $shortcodes[6][$key];
800
801
802 $atts = shortcode_parse_atts($shortcode[3]);
803 if (isset($atts['admin_label']) && $atts['admin_label'] == $this->get('item')) {
804
805 $field_content = $shortcode_value;
806 $field_shortcode_tags = array(
807 'et_pb_contact_field',
808 );
809
810 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $field_content, $field_matches);
811 $field_tagnames = array_intersect($field_shortcode_tags, $field_matches[1]);
812
813 if (!empty($field_tagnames)) {
814 $field_pattern = get_shortcode_regex($field_tagnames);
815
816 preg_match_all("/$field_pattern/", $field_content, $field_shortcodes);
817
818 foreach ($field_shortcodes[0] as $field_key => $field_shortcode_value) {
819 $field_shortcode = array();
820 $field_shortcode[3] = $field_shortcodes[3][$field_key];
821 $field_atts = shortcode_parse_atts($field_shortcode[3]);
822 if (isset($field_atts['field_title']) && isset($field_atts['field_id'])) {
823 if ($field_atts['field_title'] == $name || $field_atts['field_id'] == $name) {
824 return "%%" . strtolower($field_atts['field_id']) . "%%";
825 }
826 }
827 }
828 }
829 }
830 }
831 }
832 }
833 }
834 }
835
836 return false;
837 }
838
839 /**
840 * Generate field for Auto PDF
841 *
842 * @param object $field - Formidable field object
843 * @param string $type - Field type
844 * @param array $options - Field additional options
845 *
846 * @return array - Prepared auto field
847 */
848 public function auto_field($field = false, $type = false, $options = array()) {
849
850 if (!$field || !$type) {
851 return false;
852 }
853
854 $element = array(
855 'type' => $type,
856 'properties' => isset($options['properties']) ? $options['properties'] : array(),
857 );
858
859 $element['top'] = isset($options['top']) ? $options['top'] : '0';
860 $element['left'] = isset($options['left']) ? $options['left'] : '0';
861 $element['right'] = isset($options['right']) ? $options['right'] : '0';
862 $element['block'] = isset($options['block']) ? $options['block'] : false;
863
864 $classes = array();
865 if (isset($field->attributes->getNamedItem("class")->nodeValue)) {
866 $classes = explode(" ", $field->attributes->getNamedItem("class")->nodeValue);
867 }
868
869 $float_classes = array(
870 'et_pb_contact_field_half',
871 );
872 $array_intersect = array_intersect($classes, $float_classes);
873
874 if (!empty($array_intersect)) {
875 $element['float'] = true;
876 };
877
878 $primary_class = false;
879 if (!empty($array_intersect)) {
880 $primary_class = end($array_intersect);
881 }
882
883 if ($element['block']) {
884 switch ($primary_class) {
885 case 'et_pb_contact_field_half':
886 $element['width'] = '50%';
887 break;
888 default:
889 break;
890 }
891 }
892
893 return $element;
894 }
895
896 /**
897 * Verify if form and dataset exists
898 *
899 * @return bool - Exists/Not exists
900 */
901 public function verify() {
902 global $wpdb;
903 $item_id = $this->get('item');
904 $dataset_id = $this->get('dataset');
905
906 if ($item_id && $dataset_id) {
907 $condition = array(
908 'ID' => array(
909 'condition' => '=',
910 'value' => $dataset_id,
911 'type' => '%d'
912 ),
913 'extension' => array(
914 'condition' => '=',
915 'value' => 'divi',
916 'type' => '%s'
917 ),
918 'item' => array(
919 'condition' => '=',
920 'value' => $item_id,
921 'type' => '%s'
922 ),
923 );
924
925 $helper_e2pdf_db = new Helper_E2pdf_Db();
926 $where = $helper_e2pdf_db->prepare_where($condition);
927 $dataset = $wpdb->get_row($wpdb->prepare("SELECT * FROM " . $wpdb->prefix . 'e2pdf_datasets' . $where['sql'] . "", $where['filter']));
928
929 if ($dataset) {
930 return true;
931 }
932 }
933 return false;
934 }
935
936 /**
937 * Visual Mapper for Mapping field
938 *
939 * @return bool|string - Prepared form or false
940 */
941 public function visual_mapper() {
942 if ($this->get('item')) {
943 $post = $this->get_post($this->get('item'));
944 if ($post && isset($post->post_content)) {
945
946 $content = $post->post_content;
947
948 if (false !== strpos($content, '[')) {
949 $shortcode_tags = array(
950 'et_pb_contact_form',
951 );
952
953 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $content, $matches);
954 $tagnames = array_intersect($shortcode_tags, $matches[1]);
955
956
957
958 if (!empty($tagnames)) {
959 $pattern = get_shortcode_regex($tagnames);
960
961 preg_match_all("/$pattern/", $content, $shortcodes);
962
963 foreach ($shortcodes[0] as $key => $shortcode_value) {
964
965 $shortcode = array();
966 $shortcode[1] = $shortcodes[1][$key];
967 $shortcode[2] = $shortcodes[2][$key];
968 $shortcode[3] = $shortcodes[3][$key];
969 $shortcode[4] = $shortcodes[4][$key];
970 $shortcode[5] = $shortcodes[5][$key];
971 $shortcode[6] = $shortcodes[6][$key];
972
973
974 $atts = shortcode_parse_atts($shortcode[3]);
975 if (isset($atts['admin_label']) && $atts['admin_label'] == $this->get('item')) {
976
977 require_once(ET_BUILDER_DIR . 'class-et-builder-element.php');
978 require_once(ET_BUILDER_DIR . 'functions.php');
979 require_once(ET_BUILDER_DIR . 'ab-testing.php');
980 require_once(ET_BUILDER_DIR . 'class-et-global-settings.php');
981 require_once(ET_BUILDER_DIR . 'module/ContactForm.php');
982 require_once(ET_BUILDER_DIR . 'module/ContactFormItem.php');
983
984 new ET_Builder_Module_Contact_Form();
985 new ET_Builder_Module_Contact_Form_Item();
986
987 $source = do_shortcode($shortcode_value);
988
989 libxml_use_internal_errors(true);
990 $dom = new DOMDocument;
991 $html = $dom->loadHTML($source);
992 libxml_clear_errors();
993
994 if (!$html) {
995 return __('Form could not be parsed due incorrect HTML', 'e2pdf');
996 } else {
997
998 $xpath = new DomXPath($dom);
999 // Replace names
1000 $fields = $xpath->query("//*[contains(@name, 'et_pb_contact_')]");
1001 foreach ($fields as $element) {
1002 $element->attributes->getNamedItem("name")->nodeValue = "%%" . $element->attributes->getNamedItem("data-original_id")->nodeValue . "%%";
1003 }
1004
1005 $checkboxes = $xpath->query("//*[contains(@class, 'et_pb_contact_field') and @data-type='checkbox']");
1006 foreach ($checkboxes as $element) {
1007
1008 $check_handler = $xpath->query(".//input[contains(@class, 'et_pb_checkbox_handle')]", $element)->item(0);
1009
1010 $name = "";
1011 if ($check_handler) {
1012 $name = "%%" . $check_handler->attributes->getNamedItem("data-original_id")->nodeValue . "%%";
1013 }
1014
1015 $checks = $xpath->query(".//input[@type='checkbox']", $element);
1016 foreach ($checks as $check) {
1017 $attr = $dom->createAttribute('name');
1018 $attr->value = $name;
1019 $check->appendChild($attr);
1020 }
1021 }
1022
1023 $remove_by_class = array(
1024 'et_pb_contact_submit',
1025 'et_pb_contactform_validate_field'
1026 );
1027 foreach ($remove_by_class as $key => $class) {
1028 $elements = $xpath->query("//*[contains(@class, '{$class}')]");
1029 foreach ($elements as $element) {
1030 $element->parentNode->removeChild($element);
1031 }
1032 }
1033
1034
1035 $remove_parent_by_class = array(
1036 'et_pb_contact_captcha_question'
1037 );
1038 foreach ($remove_parent_by_class as $key => $class) {
1039 $elements = $xpath->query("//*[contains(@class, '{$class}')]/parent::*");
1040 foreach ($elements as $element) {
1041 $element->parentNode->removeChild($element);
1042 }
1043 }
1044
1045
1046 if ($xpath->query("//form")->item(0)) {
1047 $autocomplete = $dom->createAttribute('autocomplete');
1048 $autocomplete->value = 'off';
1049 $xpath->query("//form")->item(0)->appendChild($autocomplete);
1050 }
1051 }
1052
1053 return $dom->saveHTML();
1054 }
1055 }
1056 }
1057 }
1058 }
1059 }
1060
1061 return false;
1062 }
1063
1064 /**
1065 * Overwrite shortcodes
1066 */
1067 public function action_overwrite_shortcodes() {
1068 remove_shortcode('et_pb_contact_form');
1069 add_shortcode('et_pb_contact_form', array($this, 'shortcode_et_pb_contact_form'));
1070 }
1071
1072 public function filter_wp_mail($args) {
1073
1074 if (isset($args['message'])) {
1075 if (false !== strpos($args['message'], '[')) {
1076 $shortcode_tags = array(
1077 'e2pdf-download',
1078 'e2pdf-attachment',
1079 'e2pdf-save'
1080 );
1081
1082 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $args['message'], $matches);
1083 $tagnames = array_intersect($shortcode_tags, $matches[1]);
1084
1085 if (!empty($tagnames)) {
1086 $pattern = get_shortcode_regex($tagnames);
1087
1088 preg_match_all("/$pattern/", $args['message'], $shortcodes);
1089
1090 foreach ($shortcodes[0] as $key => $shortcode_value) {
1091 $extension = false;
1092 $item = false;
1093
1094 $shortcode = array();
1095 $shortcode[1] = $shortcodes[1][$key];
1096 $shortcode[2] = $shortcodes[2][$key];
1097 $shortcode[3] = $shortcodes[3][$key];
1098 $shortcode[4] = $shortcodes[4][$key];
1099 $shortcode[5] = $shortcodes[5][$key];
1100 $shortcode[6] = $shortcodes[6][$key];
1101
1102 $atts = shortcode_parse_atts($shortcode[3]);
1103
1104 if (array_key_exists('id', $atts)) {
1105 $template = new Model_E2pdf_Template();
1106 $template->load($atts['id']);
1107 if ($template->get('extension') === 'divi') {
1108 $extension = $template->get('extension');
1109 $item = $template->get('item');
1110 if (array_key_exists('dataset', $atts)) {
1111 $shortcode[3] .= " apply='true'";
1112 if ($shortcode[2] === 'e2pdf-download') {
1113 $args['headers'][] = 'Content-Type: text/html; charset=UTF-8';
1114 $args['message'] = str_replace($shortcode_value, do_shortcode_tag($shortcode), $args['message']);
1115 $args['message'] = str_replace("\r\n", "<br/>", $args['message']);
1116 } elseif ($shortcode[2] === 'e2pdf-attachment') {
1117 $file = do_shortcode_tag($shortcode);
1118 if ($file) {
1119 $this->helper->add('divi_attachments', $file);
1120 $args['attachments'][] = $file;
1121 }
1122 $args['message'] = str_replace($shortcode_value, '', $args['message']);
1123 } elseif ($shortcode[2] === 'e2pdf-save') {
1124 do_shortcode_tag($shortcode);
1125 $args['message'] = str_replace($shortcode_value, '', $args['message']);
1126 }
1127 } else {
1128 $args['message'] = str_replace($shortcode_value, '', $args['message']);
1129 }
1130 }
1131 }
1132 }
1133 }
1134 }
1135 }
1136
1137 $wp_mail = array(
1138 'to' => $args['to'],
1139 'subject' => $args['subject'],
1140 'message' => $args['message'],
1141 'headers' => $args['headers'],
1142 'attachments' => $args['attachments'],
1143 );
1144
1145 return $wp_mail;
1146 }
1147
1148 /**
1149 * Load actions for this extension
1150 */
1151 public function load_actions() {
1152 add_action('wp', array($this, 'action_overwrite_shortcodes'), 99);
1153 }
1154
1155 public function shortcode_et_pb_contact_form($shortcode_atts, $content = null, $function_name, $parent_address = '', $global_parent = '', $global_parent_type = '') {
1156 global $wpdb;
1157
1158 if (class_exists('ET_Builder_Module_Contact_Form')) {
1159
1160 $et_pb_contact = new ET_Builder_Module_Contact_Form();
1161
1162 if (isset($_POST['_wpnonce-et-pb-contact-form-submitted'])) {
1163
1164 $et_pb_contact_form_num = 0;
1165
1166 $nonce_result = isset($_POST['_wpnonce-et-pb-contact-form-submitted']) && wp_verify_nonce($_POST['_wpnonce-et-pb-contact-form-submitted'], 'et-pb-contact-form-submit') ? true : false;
1167
1168 if ($nonce_result && isset($_POST['et_pb_contactform_submit_' . $et_pb_contact_form_num]) && empty($_POST['et_pb_contactform_validate_' . $et_pb_contact_form_num])) {
1169 if ('' !== $current_form_fields) {
1170 $fields_data_json = str_replace('\\', '', $current_form_fields);
1171 $fields_data_array = json_decode($fields_data_json, true);
1172
1173 // check whether captcha field is not empty
1174 if ('on' === $captcha && (!isset($_POST['et_pb_contact_captcha_' . $et_pb_contact_form_num]) || empty($_POST['et_pb_contact_captcha_' . $et_pb_contact_form_num]) )) {
1175 $et_error_message .= sprintf('<p class="et_pb_contact_error_text">%1$s</p>', esc_html__('Make sure you entered the captcha.', 'et_builder'));
1176 $et_contact_error = true;
1177 }
1178
1179 // check all fields on current form and generate error message if needed
1180 if (!empty($fields_data_array)) {
1181 foreach ($fields_data_array as $index => $value) {
1182 // check all the required fields, generate error message if required field is empty
1183 if ('required' === $value['required_mark'] && empty($_POST[$value['field_id']])) {
1184 $et_error_message .= sprintf('<p class="et_pb_contact_error_text">%1$s</p>', esc_html__('Make sure you fill in all required fields.', 'et_builder'));
1185 $et_contact_error = true;
1186 continue;
1187 }
1188
1189 // additional check for email field
1190 if ('email' === $value['field_type'] && 'required' === $value['required_mark'] && !empty($_POST[$value['field_id']])) {
1191 $contact_email = sanitize_email($_POST[$value['field_id']]);
1192 if (!is_email($contact_email)) {
1193 $et_error_message .= sprintf('<p class="et_pb_contact_error_text">%1$s</p>', esc_html__('Invalid Email.', 'et_builder'));
1194 $et_contact_error = true;
1195 }
1196 }
1197
1198 // prepare the array of processed field values in convenient format
1199 if (false === $et_contact_error) {
1200 $processed_fields_values[$value['original_id']]['value'] = isset($_POST[$value['field_id']]) ? $_POST[$value['field_id']] : '';
1201 $processed_fields_values[$value['original_id']]['label'] = $value['field_label'];
1202 }
1203 }
1204 }
1205 } else {
1206 $et_error_message .= sprintf('<p class="et_pb_contact_error_text">%1$s</p>', esc_html__('Make sure you fill in all required fields.', 'et_builder'));
1207 $et_contact_error = true;
1208 }
1209 } else {
1210 if (false === $nonce_result && isset($_POST['et_pb_contactform_submit_' . $et_pb_contact_form_num]) && empty($_POST['et_pb_contactform_validate_' . $et_pb_contact_form_num])) {
1211 $et_error_message .= sprintf('<p class="et_pb_contact_error_text">%1$s</p>', esc_html__('Please refresh the page and try again.', 'et_builder'));
1212 }
1213 $et_contact_error = true;
1214 }
1215
1216 if (!$et_contact_error && $nonce_result) {
1217 if (isset($shortcode_atts['success_message'])) {
1218 $shortcode_atts['success_message'] = str_replace(array('%91', '%93', '%22'), array('[', ']', '"'), $shortcode_atts['success_message']);
1219 if (false !== strpos($shortcode_atts['success_message'], '[')) {
1220
1221 $shortcode_tags = array(
1222 'e2pdf-download',
1223 'e2pdf-save',
1224 'e2pdf-view'
1225 );
1226
1227 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $shortcode_atts['success_message'], $matches);
1228 $tagnames = array_intersect($shortcode_tags, $matches[1]);
1229
1230 if (!empty($tagnames)) {
1231 $pattern = get_shortcode_regex($tagnames);
1232
1233 preg_match_all("/$pattern/", $shortcode_atts['success_message'], $shortcodes);
1234
1235 foreach ($shortcodes[0] as $key => $shortcode_value) {
1236
1237 $extension = false;
1238 $item = false;
1239
1240 $shortcode = array();
1241 $shortcode[1] = $shortcodes[1][$key];
1242 $shortcode[2] = $shortcodes[2][$key];
1243 $shortcode[3] = $shortcodes[3][$key];
1244 $shortcode[4] = $shortcodes[4][$key];
1245 $shortcode[5] = $shortcodes[5][$key];
1246 $shortcode[6] = $shortcodes[6][$key];
1247
1248 $atts = shortcode_parse_atts($shortcode[3]);
1249
1250 if (array_key_exists('id', $atts)) {
1251 $template = new Model_E2pdf_Template();
1252 $template->load($atts['id']);
1253 if ($template->get('extension') === 'divi') {
1254 $extension = $template->get('extension');
1255 $item = $template->get('item');
1256 }
1257 }
1258
1259 if ($item && isset($shortcode_atts['admin_label']) && $shortcode_atts['admin_label'] == $item && $extension) {
1260 if (!array_key_exists('dataset', $atts)) {
1261 $serialized = serialize($_POST);
1262 $dataset = array(
1263 'extension' => 'divi',
1264 'item' => $item,
1265 'entry' => $serialized
1266 );
1267 $wpdb->insert($wpdb->prefix . 'e2pdf_datasets', $dataset);
1268
1269 $dataset_id = $wpdb->insert_id;
1270
1271 $atts['dataset'] = $dataset_id;
1272 $shortcode[3] .= " dataset='{$dataset_id}' apply='true'";
1273 $shortcode_atts['success_message'] = str_replace($shortcode_value, do_shortcode_tag($shortcode), $shortcode_atts['success_message']);
1274 }
1275 } elseif ($shortcode[2] === 'e2pdf-view') {
1276 $shortcode_atts['success_message'] = str_replace($shortcode_value, do_shortcode_tag($shortcode), $shortcode_atts['success_message']);
1277 }
1278 }
1279 }
1280 }
1281 }
1282
1283
1284 if (isset($shortcode_atts['custom_message'])) {
1285
1286 $shortcode_atts['custom_message'] = str_replace(array('%91', '%93', '%22'), array('[', ']', '"'), $shortcode_atts['custom_message']);
1287
1288 if (false !== strpos($shortcode_atts['custom_message'], '[')) {
1289 $shortcode_tags = array(
1290 'e2pdf-download',
1291 'e2pdf-attachment',
1292 'e2pdf-save'
1293 );
1294
1295 preg_match_all('@\[([^<>&/\[\]\x00-\x20=]++)@', $shortcode_atts['custom_message'], $matches);
1296 $tagnames = array_intersect($shortcode_tags, $matches[1]);
1297
1298
1299 if (!empty($tagnames)) {
1300 $pattern = get_shortcode_regex($tagnames);
1301
1302 preg_match_all("/$pattern/", $shortcode_atts['custom_message'], $shortcodes);
1303
1304 add_filter('wp_mail', array($this, 'filter_wp_mail'), 10, 2);
1305
1306 foreach ($shortcodes[0] as $key => $shortcode_value) {
1307
1308 $extension = false;
1309 $item = false;
1310
1311 $shortcode = array();
1312 $shortcode[1] = $shortcodes[1][$key];
1313 $shortcode[2] = $shortcodes[2][$key];
1314 $shortcode[3] = $shortcodes[3][$key];
1315 $shortcode[4] = $shortcodes[4][$key];
1316 $shortcode[5] = $shortcodes[5][$key];
1317 $shortcode[6] = $shortcodes[6][$key];
1318
1319 $atts = shortcode_parse_atts($shortcode[3]);
1320
1321 if (array_key_exists('id', $atts)) {
1322 $template = new Model_E2pdf_Template();
1323 $template->load($atts['id']);
1324 if ($template->get('extension') === 'divi') {
1325 $extension = $template->get('extension');
1326 $item = $template->get('item');
1327 }
1328 }
1329
1330 if ($item && isset($shortcode_atts['admin_label']) && $shortcode_atts['admin_label'] == $item && $extension) {
1331 if (!array_key_exists('dataset', $atts)) {
1332 if (!$dataset_id) {
1333 $serialized = serialize($_POST);
1334 $dataset = array(
1335 'extension' => 'divi',
1336 'item' => $item,
1337 'entry' => $serialized
1338 );
1339 $wpdb->insert($wpdb->prefix . 'e2pdf_datasets', $dataset);
1340 $dataset_id = $wpdb->insert_id;
1341 }
1342
1343 $atts['dataset'] = $dataset_id;
1344 $shortcode[3] .= " dataset='{$dataset_id}'";
1345
1346 $new_shortcode = "[" . $shortcode[2] . $shortcode[3] . "]";
1347 $shortcode_atts['custom_message'] = str_replace($shortcode_value, $new_shortcode, $shortcode_atts['custom_message']);
1348 }
1349 }
1350 }
1351 }
1352 }
1353 }
1354 }
1355 }
1356
1357 $output = $et_pb_contact->_shortcode_callback($shortcode_atts, $content, $function_name, $parent_address, $global_parent, $global_parent_type);
1358
1359 remove_filter('wp_mail', array($this, 'filter_wp_mail'), 10, 2);
1360
1361 $files = $this->helper->get('divi_attachments');
1362 if (is_array($files) && !empty($files)) {
1363 foreach ($files as $key => $file) {
1364 $this->helper->delete_dir(dirname($file) . '/');
1365 }
1366 $this->helper->deset('divi_attachments');
1367 }
1368
1369 return html_entity_decode($output, ENT_QUOTES);
1370 }
1371 }
1372
1373 /**
1374 * Delete dataset for template
1375 *
1376 * @param int $template_id - Template ID
1377 * @param int $dataset_id - Dataset ID
1378 *
1379 * @return bool - Result of removing items
1380 */
1381 public function delete_item($template_id = false, $dataset_id = false) {
1382 global $wpdb;
1383
1384 $template = new Model_E2pdf_Template();
1385 if ($template_id && $dataset_id && $template->load($template_id)) {
1386 $extension = new Model_E2pdf_Extension();
1387 if ($template->get('extension') === 'divi' && $extension->load($template->get('extension'))) {
1388
1389 $item_id = $template->get('item');
1390
1391 $where = array(
1392 'ID' => $dataset_id,
1393 'item' => $item_id,
1394 'extension' => 'divi'
1395 );
1396 $wpdb->delete($wpdb->prefix . 'e2pdf_datasets', $where);
1397 return true;
1398 }
1399 }
1400
1401 return false;
1402 }
1403
1404 /**
1405 * Delete all datasets for Template
1406 *
1407 * @param int $template_id - Template ID
1408 *
1409 * @return bool - Result of removing items
1410 */
1411 public function delete_items($template_id = false) {
1412 global $wpdb;
1413
1414 $template = new Model_E2pdf_Template();
1415
1416 if ($template_id && $template->load($template_id)) {
1417 $extension = new Model_E2pdf_Extension();
1418 if ($template->get('extension') === 'divi' && $extension->load($template->get('extension'))) {
1419
1420 $item_id = $template->get('item');
1421
1422 $where = array(
1423 'item' => $item_id,
1424 'extension' => 'divi'
1425 );
1426 $wpdb->delete($wpdb->prefix . 'e2pdf_datasets', $where);
1427 return true;
1428 }
1429 }
1430
1431 return false;
1432 }
1433
1434 /**
1435 * Get styles for generating Map Field function
1436 *
1437 * @return array - List of css files to load
1438 */
1439 public function get_styles() {
1440 $styles = array(
1441 plugins_url('css/extension/divi.css?v=' . time(), $this->helper->get('plugin_file_path'))
1442 );
1443 return $styles;
1444 }
1445
1446 }
1447