| @@ -339,8 +339,18 @@ | ||
| 339 | 339 | add_filter('frm_row_actions', array($this, 'hook_formidable_row_actions'), 10, 2); |
| 340 | 340 | |
| 341 | 341 | // frm-graph |
| 342 | 342 | add_filter('frm_graph_shortcode_custom_html', array($this, 'filter_frm_graph_shortcode_custom_html'), 99, 2); |
| 343 | + | |
| 344 | + // extension hooks | |
| 345 | + add_filter('e2pdf_extension_hooks', function ($hooks) { | |
| 346 | + $hooks[$this->info['key']] = [ | |
| 347 | + 'hook_formidable_entry_view' => __('WP Admin Entry View', 'e2pdf'), | |
| 348 | + 'hook_formidable_entry_edit' => __('WP Admin Entry Edit', 'e2pdf'), | |
| 349 | + 'hook_formidable_row_actions' => __('WP Admin Entry Row Actions', 'e2pdf') | |
| 350 | + ]; | |
| 351 | + return $hooks; | |
| 352 | + }); | |
| 343 | 353 | } |
| 344 | 354 | |
| 345 | 355 | public function action_frm_success_action() { |
| 346 | 356 | $this->set('iframe_download', true); |
| @@ -591,20 +601,8 @@ | ||
| 591 | 601 | if ($checkbox_separated) { |
| 592 | 602 | remove_filter('frm_display_value_custom', array($this, 'filter_frm_display_value_custom'), 0); |
| 593 | 603 | } |
| 594 | 604 | |
| 595 | - /* Bug fix for Formidable Forms Signature (2.0.1) */ | |
| 596 | - if (class_exists('FrmFieldFactory')) { | |
| 597 | - $signature_field = FrmFieldFactory::get_field_type('signature'); | |
| 598 | - if ($signature_field->get_display_value('signature') == '') { | |
| 599 | - $signature = true; | |
| 600 | - } | |
| 601 | - } | |
| 602 | - if ($signature) { | |
| 603 | - remove_filter('frm_get_signature_display_value', 'FrmSigAppController::display_signature'); | |
| 604 | - remove_filter('frmpro_fields_replace_shortcodes', 'FrmSigAppController::custom_display_signature'); | |
| 605 | - add_filter('frm_keep_signature_value_array', array($this, 'filter_frm_keep_signature_value_array'), 10, 2); | |
| 606 | - } | |
| 607 | 605 | add_filter('frmpro_fields_replace_shortcodes', array($this, 'filter_frmpro_fields_replace_shortcodes'), 20, 4); |
| 608 | 606 | |
| 609 | 607 | $text_signature = !empty($field['type']) && ($field['type'] == 'e2pdf-image' || $field['type'] == 'e2pdf-signature') ? true : false; |
| 610 | 608 | if ($text_signature) { |
| @@ -663,13 +661,8 @@ | ||
| 663 | 661 | $field['properties']['text'] = '1'; |
| 664 | 662 | } |
| 665 | 663 | } |
| 666 | 664 | remove_filter('frmpro_fields_replace_shortcodes', array($this, 'filter_frmpro_fields_replace_shortcodes'), 20); |
| 667 | - if ($signature) { | |
| 668 | - remove_filter('frm_keep_signature_value_array', array($this, 'filter_frm_keep_signature_value_array')); | |
| 669 | - add_filter('frm_get_signature_display_value', 'FrmSigAppController::display_signature', 10, 3); | |
| 670 | - add_filter('frmpro_fields_replace_shortcodes', 'FrmSigAppController::custom_display_signature', 10, 4); | |
| 671 | - } | |
| 672 | 665 | $value = $this->replace_meta_shortcodes($value); |
| 673 | 666 | $value = $this->helper->load('field')->render( |
| 674 | 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')), |
| 675 | 668 | $this, |
| @@ -734,12 +727,8 @@ | ||
| 734 | 727 | } |
| 735 | 728 | return $is_filter_needed; |
| 736 | 729 | } |
| 737 | 730 | |
| 738 | - public function filter_frm_keep_signature_value_array($keep_array, $atts) { | |
| 739 | - return true; | |
| 740 | - } | |
| 741 | - | |
| 742 | 731 | /** |
| 743 | 732 | * Search and update shortcodes for this extension inside content |
| 744 | 733 | * Auto set of dataset id |
| 745 | 734 | * @param string $content - Content |
| @@ -889,29 +878,49 @@ | ||
| 889 | 878 | $replace_with = FrmProEntryMetaHelper::get_post_or_meta_value($this->get('cached_entry2'), $field, $atts); |
| 890 | 879 | } |
| 891 | 880 | } |
| 892 | 881 | |
| 893 | - if ($field->type === 'checkbox' && is_array($replace_with)) { | |
| 894 | - if (isset($atts['key']) && $atts['key']) { | |
| 895 | - if (isset($replace_with[$atts['key']])) { | |
| 896 | - $replace_with = $replace_with[$atts['key']]; | |
| 897 | - } else { | |
| 898 | - $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 | + } | |
| 899 | 890 | } |
| 900 | - } | |
| 901 | - } | |
| 902 | - | |
| 903 | - if ($field->type === 'radio') { | |
| 904 | - if (isset($atts['key']) && $atts['key'] === 'other') { | |
| 905 | - if (isset($field->options) && is_array($field->options)) { | |
| 906 | - $field_key = array_search($replace_with, array_column($field->options, 'value')); | |
| 907 | - if ($field_key !== false) { | |
| 908 | - $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 | + } | |
| 909 | 899 | } |
| 910 | 900 | } |
| 911 | - } | |
| 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; | |
| 912 | 922 | } |
| 913 | - | |
| 914 | 923 | return $replace_with; |
| 915 | 924 | } |
| 916 | 925 | |
| 917 | 926 | /** |