| @@ -601,20 +601,8 @@ | ||
| 601 | 601 | if ($checkbox_separated) { |
| 602 | 602 | remove_filter('frm_display_value_custom', array($this, 'filter_frm_display_value_custom'), 0); |
| 603 | 603 | } |
| 604 | 604 | |
| 605 | - /* Bug fix for Formidable Forms Signature (2.0.1) */ | |
| 606 | - if (class_exists('FrmFieldFactory')) { | |
| 607 | - $signature_field = FrmFieldFactory::get_field_type('signature'); | |
| 608 | - if ($signature_field->get_display_value('signature') == '') { | |
| 609 | - $signature = true; | |
| 610 | - } | |
| 611 | - } | |
| 612 | - if ($signature) { | |
| 613 | - remove_filter('frm_get_signature_display_value', 'FrmSigAppController::display_signature'); | |
| 614 | - remove_filter('frmpro_fields_replace_shortcodes', 'FrmSigAppController::custom_display_signature'); | |
| 615 | - add_filter('frm_keep_signature_value_array', array($this, 'filter_frm_keep_signature_value_array'), 10, 2); | |
| 616 | - } | |
| 617 | 605 | add_filter('frmpro_fields_replace_shortcodes', array($this, 'filter_frmpro_fields_replace_shortcodes'), 20, 4); |
| 618 | 606 | |
| 619 | 607 | $text_signature = !empty($field['type']) && ($field['type'] == 'e2pdf-image' || $field['type'] == 'e2pdf-signature') ? true : false; |
| 620 | 608 | if ($text_signature) { |
| @@ -673,13 +661,8 @@ | ||
| 673 | 661 | $field['properties']['text'] = '1'; |
| 674 | 662 | } |
| 675 | 663 | } |
| 676 | 664 | remove_filter('frmpro_fields_replace_shortcodes', array($this, 'filter_frmpro_fields_replace_shortcodes'), 20); |
| 677 | - if ($signature) { | |
| 678 | - remove_filter('frm_keep_signature_value_array', array($this, 'filter_frm_keep_signature_value_array')); | |
| 679 | - add_filter('frm_get_signature_display_value', 'FrmSigAppController::display_signature', 10, 3); | |
| 680 | - add_filter('frmpro_fields_replace_shortcodes', 'FrmSigAppController::custom_display_signature', 10, 4); | |
| 681 | - } | |
| 682 | 665 | $value = $this->replace_meta_shortcodes($value); |
| 683 | 666 | $value = $this->helper->load('field')->render( |
| 684 | 667 | apply_filters('e2pdf_extension_render_shortcodes_pre_value', $value, $element_id, $this->get('template_id'), $this->get('item'), $this->get('dataset'), $this->get('item2'), $this->get('dataset2')), |
| 685 | 668 | $this, |
| @@ -744,12 +727,8 @@ | ||
| 744 | 727 | } |
| 745 | 728 | return $is_filter_needed; |
| 746 | 729 | } |
| 747 | 730 | |
| 748 | - public function filter_frm_keep_signature_value_array($keep_array, $atts) { | |
| 749 | - return true; | |
| 750 | - } | |
| 751 | - | |
| 752 | 731 | /** |
| 753 | 732 | * Search and update shortcodes for this extension inside content |
| 754 | 733 | * Auto set of dataset id |
| 755 | 734 | * @param string $content - Content |
| @@ -899,35 +878,49 @@ | ||
| 899 | 878 | $replace_with = FrmProEntryMetaHelper::get_post_or_meta_value($this->get('cached_entry2'), $field, $atts); |
| 900 | 879 | } |
| 901 | 880 | } |
| 902 | 881 | |
| 903 | - if ($field->type === 'checkbox' && is_array($replace_with)) { | |
| 904 | - if (isset($atts['key']) && $atts['key']) { | |
| 905 | - if (isset($replace_with[$atts['key']])) { | |
| 906 | - $replace_with = $replace_with[$atts['key']]; | |
| 907 | - } else { | |
| 908 | - $replace_with = ''; | |
| 882 | + switch ($field->type) { | |
| 883 | + case 'checkbox': | |
| 884 | + if (is_array($replace_with) && isset($atts['key']) && $atts['key']) { | |
| 885 | + if (isset($replace_with[$atts['key']])) { | |
| 886 | + $replace_with = $replace_with[$atts['key']]; | |
| 887 | + } else { | |
| 888 | + $replace_with = ''; | |
| 889 | + } | |
| 909 | 890 | } |
| 910 | - } | |
| 911 | - } | |
| 912 | - | |
| 913 | - if ($field->type === 'radio') { | |
| 914 | - if (isset($atts['key']) && $atts['key'] === 'other') { | |
| 915 | - if (isset($field->options) && is_array($field->options)) { | |
| 916 | - $field_key = array_search($replace_with, array_column($field->options, 'value')); | |
| 917 | - if ($field_key !== false) { | |
| 918 | - $replace_with = ''; | |
| 891 | + break; | |
| 892 | + case 'radio': | |
| 893 | + if (isset($atts['key']) && $atts['key'] === 'other') { | |
| 894 | + if (isset($field->options) && is_array($field->options)) { | |
| 895 | + $field_key = array_search($replace_with, array_column($field->options, 'value')); | |
| 896 | + if ($field_key !== false) { | |
| 897 | + $replace_with = ''; | |
| 898 | + } | |
| 919 | 899 | } |
| 920 | 900 | } |
| 921 | - } | |
| 901 | + break; | |
| 902 | + case 'signature': | |
| 903 | + if (is_array($replace_with)) { | |
| 904 | + if (!empty($replace_with['format']) && $replace_with['format'] == 'drawn' && !empty($replace_with['output'])) { | |
| 905 | + if (strpos($replace_with['output'], 'data:image') === 0) { | |
| 906 | + $replace_with = $replace_with['output']; | |
| 907 | + } elseif (strpos($replace_with['output'], '[{"lx":') === 0 && isset($replace_with['content'])) { | |
| 908 | + if (class_exists('FrmSigAppController') && is_callable(['FrmSigAppController', 'get_signature_file_directory'])) { | |
| 909 | + $file_path = FrmSigAppController::get_signature_file_directory() . '/' . $replace_with['content']; | |
| 910 | + if (file_exists($file_path) && is_readable($file_path)) { | |
| 911 | + $replace_with = $file_path; | |
| 912 | + } else { | |
| 913 | + $replace_with = ''; | |
| 914 | + } | |
| 915 | + } | |
| 916 | + } | |
| 917 | + } | |
| 918 | + } | |
| 919 | + break; | |
| 920 | + default: | |
| 921 | + break; | |
| 922 | 922 | } |
| 923 | - | |
| 924 | - if ($field->type === 'signature' && is_array($replace_with)) { | |
| 925 | - if (!empty($replace_with['format']) && $replace_with['format'] == 'drawn' && !empty($replace_with['output'])) { | |
| 926 | - return $replace_with['output']; | |
| 927 | - } | |
| 928 | - } | |
| 929 | - | |
| 930 | 923 | return $replace_with; |
| 931 | 924 | } |
| 932 | 925 | |
| 933 | 926 | /** |