| @@ -601,8 +601,20 @@ | ||
| 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 | + } | |
| 605 | 617 | add_filter('frmpro_fields_replace_shortcodes', array($this, 'filter_frmpro_fields_replace_shortcodes'), 20, 4); |
| 606 | 618 | |
| 607 | 619 | $text_signature = !empty($field['type']) && ($field['type'] == 'e2pdf-image' || $field['type'] == 'e2pdf-signature') ? true : false; |
| 608 | 620 | if ($text_signature) { |
| @@ -661,8 +673,13 @@ | ||
| 661 | 673 | $field['properties']['text'] = '1'; |
| 662 | 674 | } |
| 663 | 675 | } |
| 664 | 676 | 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 | + } | |
| 665 | 682 | $value = $this->replace_meta_shortcodes($value); |
| 666 | 683 | $value = $this->helper->load('field')->render( |
| 667 | 684 | 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')), |
| 668 | 685 | $this, |
| @@ -727,8 +744,12 @@ | ||
| 727 | 744 | } |
| 728 | 745 | return $is_filter_needed; |
| 729 | 746 | } |
| 730 | 747 | |
| 748 | + public function filter_frm_keep_signature_value_array($keep_array, $atts) { | |
| 749 | + return true; | |
| 750 | + } | |
| 751 | + | |
| 731 | 752 | /** |
| 732 | 753 | * Search and update shortcodes for this extension inside content |
| 733 | 754 | * Auto set of dataset id |
| 734 | 755 | * @param string $content - Content |
| @@ -878,49 +899,35 @@ | ||
| 878 | 899 | $replace_with = FrmProEntryMetaHelper::get_post_or_meta_value($this->get('cached_entry2'), $field, $atts); |
| 879 | 900 | } |
| 880 | 901 | } |
| 881 | 902 | |
| 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 { | |
| 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 = ''; | |
| 909 | + } | |
| 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) { | |
| 888 | 918 | $replace_with = ''; |
| 889 | 919 | } |
| 890 | 920 | } |
| 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 | - } | |
| 899 | - } | |
| 900 | - } | |
| 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; | |
| 921 | + } | |
| 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 | + | |
| 923 | 930 | return $replace_with; |
| 924 | 931 | } |
| 925 | 932 | |
| 926 | 933 | /** |