Plugin Directory

Changeset 3265807


Ignore:
Timestamp:
04/02/2025 05:17:52 PM (11 months ago)
Author:
maximumsoftware
Message:

Deploy from Git

Location:
pdf-forms-for-wpforms/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pdf-forms-for-wpforms/trunk/css/admin.css

    r3214289 r3265807  
    115115.pdf-forms-for-wpforms-admin .mapping-table
    116116{
    117     table-layout: fixed;
    118117    width: 100%;
    119118}
  • pdf-forms-for-wpforms/trunk/pdf-forms-for-wpforms.php

    r3246282 r3265807  
    44 * Plugin URI: https://pdfformsfiller.org/
    55 * Description: Build WPForms from PDF forms. Get PDFs filled automatically and attached to email messages and/or website responses on form submissions.
    6  * Version: 1.2.0
     6 * Version: 1.3.0
    77 * Requires at least: 5.4
    88 * Requires PHP: 5.5
     
    2525    class Pdf_Forms_For_WPForms
    2626    {
    27         const VERSION = '1.2.0';
     27        const VERSION = '1.3.0';
    2828        const MIN_WPFORMS_VERSION = '1.6.9';
    2929        const MAX_WPFORMS_VERSION = '1.9.99';
     
    3838        private $tmp_dir = null;
    3939        private $wpforms_mail_attachments = array();
     40        private $need_plaintext_smart_tag_value_flag = false;
    4041       
    4142        private function __construct()
     
    7980           
    8081            add_filter( 'wpforms_save_form_args', array( $this, 'wpforms_save_form_args' ), 10, 3 );
     82           
     83            add_filter( 'wpforms_smarttags_process_value', array( $this, 'plaintext_smart_tag_value_workaround_filter' ), PHP_INT_MAX, 6 );
    8184            // fill_pdfs: we can't use wpforms_process_complete (because notifications have already been sent) and wpforms_process because uploaded files haven't been processed yet
    8285            add_filter( 'wpforms_process_after_filter', array( $this, 'fill_pdfs' ), 999999, 3 );
     
    841844       
    842845        /**
     846         * Wrapper for WPForms' wpforms_process_smart_tags()
     847         *
     848         * The function wpforms_process_smart_tags() formats smart tag values for HTML output (via `wp_kses_post()`), but we need plain text.
     849         * Additional issue is that the content we are passing into wpforms_process_smart_tags() is plain text mixed with smart tags, but the smart tags will be formatted in HTML.
     850         * So, we need to use a workaround to make sure we get plain text smart tag values.
     851         */
     852        public function wpforms_process_smart_tags( $content, $form_data, $fields = [], $entry_id = '', $context = '' )
     853        {
     854            // enable flag to convert smart tag values from HTML to plain text
     855            $this->need_plaintext_smart_tag_value_flag = true;
     856           
     857            $value = wpforms_process_smart_tags( $content, $form_data, $fields, $entry_id, $context );
     858           
     859            // disable conversion
     860            $this->need_plaintext_smart_tag_value_flag = false;
     861           
     862            return $value;
     863        }
     864       
     865        /**
     866         * Filter the smart tag values late to convert HTML to plain text when we are inside our own wpforms_process_smart_tags call
     867         */
     868        public function plaintext_smart_tag_value_workaround_filter( $value, $tag_name, $form_data, $fields, $entry_id, $smart_tag_object )
     869        {
     870            if( $this->need_plaintext_smart_tag_value_flag )
     871                return html_entity_decode( strip_tags( $value ), ENT_QUOTES, 'UTF-8' );
     872            else
     873                return $value;
     874        }
     875       
     876        /**
    843877         * We need to fill the pdf's document fields and then create attachment file and attach them
    844878         */
     
    882916                        $url = $wpforms_fields[$embed["wpf_field"]]['value'];
    883917                    if( isset( $embed['smart_tags'] ) )
    884                         $url = wpforms_process_smart_tags( $embed["smart_tags"], $form_data, $wpforms_fields, $entry_id );
     918                        $url = $this->wpforms_process_smart_tags( $embed["smart_tags"], $form_data, $wpforms_fields, $entry_id );
    885919                   
    886920                    if( $url != null )
     
    10351069                       
    10361070                        if( isset( $mapping["smart_tags"] ) )
    1037                             $data[$field] = wpforms_process_smart_tags( $mapping["smart_tags"], $form_data, $wpforms_fields, $entry_id );
     1071                            $data[$field] = $this->wpforms_process_smart_tags( $mapping["smart_tags"], $form_data, $wpforms_fields, $entry_id );
    10381072                       
    10391073                        if( $multiple )
     
    12821316                    $destfilename = strval( $attachment['options']['filename'] );
    12831317                    if( $destfilename != "" )
    1284                         $destfilename = strval( wpforms_process_smart_tags( $destfilename, $form_data, $wpforms_fields, $entry_id ) );
     1318                        $destfilename = strval( $this->wpforms_process_smart_tags( $destfilename, $form_data, $wpforms_fields, $entry_id ) );
    12851319                    if( $destfilename == "" )
    12861320                        $destfilename = sanitize_file_name( get_the_title( $attachment_id ) );
     
    13571391                            $tag_replaced_path_elements = array();
    13581392                            foreach ( $path_elements as $key => $value )
    1359                                 $tag_replaced_path_elements[$key] = wpforms_process_smart_tags( $value, $form_data, $wpforms_fields, $entry_id );
     1393                                $tag_replaced_path_elements[$key] = $this->wpforms_process_smart_tags( $value, $form_data, $wpforms_fields, $entry_id );
    13601394                           
    13611395                            foreach( $tag_replaced_path_elements as $elmid => &$new_element )
  • pdf-forms-for-wpforms/trunk/readme.txt

    r3246282 r3265807  
    11=== PDF Forms Filler for WPForms ===
    2 Version: 1.2.0
    3 Stable tag: 1.2.0
    4 Tested up to: 6.7
     2Version: 1.3.0
     3Stable tag: 1.3.0
     4Tested up to: 6.8
    55Tags: pdf, form, wpforms, email, download
    66Plugin URI: https://pdfformsfiller.org/
     
    5252== Changelog ==
    5353
     54= 1.3.0 =
     55
     56* Release date: April 2, 2025
     57
     58* WARNING: This version includes changes that may affect plugin behavior. Please test your forms thoroughly after updating.
     59* Fixed an issue with smart tags rendering: smart tag values were HTML-escaped when we need plain text
     60* Field Mapper Tool UI issue fixed (column widths).
     61
    5462= 1.2.0 =
    5563
     
    172180== Upgrade Notice ==
    173181
     182= 1.3.0 =
     183WARNING: This version includes changes that may affect plugin behavior. Please test your forms thoroughly after updating.
     184The specific issue is that (in previous versions) smart tag values were HTML-escaped, causing unwanted HTML escape sequences to appear when smart tag containing strings were rendered.
     185This version fixes the issue by unescaping smart tag values. Smart tag mappings and image embeds are affected, as well as PDF filenames and save paths that have smart tags.
     186
    174187= 1.2.0 =
    175188WARNING: This version includes changes that may affect plugin behavior. Please test your forms thoroughly after updating.
Note: See TracChangeset for help on using the changeset viewer.