Plugin Directory

Changeset 3305740


Ignore:
Timestamp:
06/03/2025 12:17:15 PM (9 months ago)
Author:
flexfields
Message:

Tagging version 2.1.1

Location:
flex-forms
Files:
2 edited
11 copied

Legend:

Unmodified
Added
Removed
  • flex-forms/tags/2.1.1/includes/class-flex-forms-main.php

    r3305607 r3305740  
    9595    }
    9696
    97     /**
    98      * Render the Flex Form builder meta-box.
    99      *
    100      * @param WP_Post $post Current flex_form post.
    101      */
    10297    public function flex_form_meta_box_callback( $post ) {
    10398
    104         /* --------------------------------------------------------------------
     99        /* ---------------------------------------------------------------------
    105100         * 1. Context & stored values
    106101         * ------------------------------------------------------------------ */
    107         $screen  = get_current_screen();
    108         $is_edit = ( $screen->action !== 'add' );
    109         $form_id = $post->ID;
    110 
    111         /* Content */
    112         $content_value = $is_edit ? $post->post_content : '';
    113 
    114         /* Success & error behaviours */
    115         $success_behavior_value   = $is_edit ? get_post_meta( $form_id, '_flex_forms_success_behavior',     true ) : 'message';
    116         $success_redirect_url_val = $is_edit ? get_post_meta( $form_id, '_flex_forms_success_redirect_url', true ) : '';
    117         $success_text_val         = $is_edit ? get_post_meta( $form_id, '_flex_forms_success_text',         true ) : 'Your form has been successfully submitted!';
    118 
    119         $error_behavior_value     = $is_edit ? get_post_meta( $form_id, '_flex_forms_error_behavior',       true ) : 'message';
    120         $error_redirect_url_val   = $is_edit ? get_post_meta( $form_id, '_flex_forms_error_redirect_url',   true ) : '';
    121         $error_text_val           = $is_edit ? get_post_meta( $form_id, '_flex_forms_error_text',           true ) : 'There was an error submitting the form. Please try again.';
    122 
    123         /* Storage & e-mail */
    124         $store_in_db_val                          = $is_edit ? get_post_meta( $form_id, '_flex_forms_store_in_db',                  true ) : 0;
    125         $admin_email_subject_val                  = $is_edit ? get_post_meta( $form_id, '_flex_forms_admin_email_subject',         true ) : '';
    126         $admin_email_template_val                 = $is_edit ? get_post_meta( $form_id, '_flex_forms_admin_email_template',        true ) : '';
    127         $user_email_enable_val                    = $is_edit ? get_post_meta( $form_id, '_flex_forms_user_email_enable',           true ) : 0;
    128         $flex_forms_user_email_email_shortcode_val = $is_edit ? get_post_meta( $form_id, '_flex_forms_user_email_email_shortcode', true ) : '';
    129         $user_email_subject_val                   = $is_edit ? get_post_meta( $form_id, '_flex_forms_user_email_subject',          true ) : '';
    130         $user_email_template_val                  = $is_edit ? get_post_meta( $form_id, '_flex_forms_user_email_template',         true ) : '';
    131 
    132         /* Form-level attributes */
    133         $form_id_attr_val = $is_edit ? get_post_meta( $form_id, '_flex_forms_form_id',    true ) : '';
    134         $form_class_val   = $is_edit ? get_post_meta( $form_id, '_flex_forms_form_class', true ) : '';
    135         $form_attrs_val   = $is_edit ? get_post_meta( $form_id, '_flex_forms_form_attrs', true ) : '';
     102        $screen   = get_current_screen();
     103        $is_edit  = ( $screen->action !== 'add' );
     104        $form_id  = $post->ID;
     105
     106        // Show shortcode at page top (click-to-copy handled by JS already enqueued)
     107        if ( $is_edit ) {
     108            printf(
     109                '<p style="margin:8px 0 18px;">
     110                <strong>%s</strong>
     111                <code class="flex-forms-copy-shortcode" title="%s">[flex-form id="%d"]</code>
     112            </p>',
     113                esc_html__( 'Shortcode:', 'flex-forms' ),
     114                esc_attr__( 'Click to copy', 'flex-forms' ),
     115                absint( $form_id )
     116            );
     117        }
     118
     119        /* Core content */
     120        $content_value                = $is_edit ? $post->post_content : '';
     121
     122        /* Success / error behaviour */
     123        $success_behavior_value       = $is_edit ? get_post_meta( $form_id, '_flex_forms_success_behavior', true )       : 'message';
     124        $success_redirect_url_val     = $is_edit ? get_post_meta( $form_id, '_flex_forms_success_redirect_url', true )   : '';
     125        $success_text_val             = $is_edit ? get_post_meta( $form_id, '_flex_forms_success_text', true )           : 'Your form has been successfully submitted!';
     126
     127        $error_behavior_value         = $is_edit ? get_post_meta( $form_id, '_flex_forms_error_behavior', true )         : 'message';
     128        $error_redirect_url_val       = $is_edit ? get_post_meta( $form_id, '_flex_forms_error_redirect_url', true )     : '';
     129        $error_text_val               = $is_edit ? get_post_meta( $form_id, '_flex_forms_error_text', true )             : 'There was an error submitting the form. Please try again.';
     130
     131        /* Storage & email */
     132        $store_in_db_val              = $is_edit ? get_post_meta( $form_id, '_flex_forms_store_in_db', true )            : 0;
     133
     134        $admin_email_subject_val      = $is_edit ? get_post_meta( $form_id, '_flex_forms_admin_email_subject', true )    : '';
     135        $admin_email_template_val     = $is_edit ? get_post_meta( $form_id, '_flex_forms_admin_email_template', true )   : '';
     136
     137        $user_email_enable_val        = $is_edit ? get_post_meta( $form_id, '_flex_forms_user_email_enable', true )      : 0;
     138        $user_email_shortcode_val     = $is_edit ? get_post_meta( $form_id, '_flex_forms_user_email_email_shortcode', true ) : '';
     139        $user_email_subject_val       = $is_edit ? get_post_meta( $form_id, '_flex_forms_user_email_subject', true )     : '';
     140        $user_email_template_val      = $is_edit ? get_post_meta( $form_id, '_flex_forms_user_email_template', true )    : '';
     141
     142        /* NEW: form-level attributes */
     143        $form_id_attr_val             = $is_edit ? get_post_meta( $form_id, '_flex_forms_form_id', true )                : '';
     144        $form_class_val               = $is_edit ? get_post_meta( $form_id, '_flex_forms_form_class', true )             : '';
     145        $form_attrs_val               = $is_edit ? get_post_meta( $form_id, '_flex_forms_form_attrs', true )             : '';
    136146
    137147        /* Custom CSS */
    138         $custom_css_val   = $is_edit ? get_post_meta( $form_id, '_flex_forms_custom_css', true ) : '';
    139 
    140         /* --------------------------------------------------------------------
    141          * 2. Output
     148        $custom_css_val               = $is_edit ? get_post_meta( $form_id, '_flex_forms_custom_css', true )            : '';
     149
     150        /* ---------------------------------------------------------------------
     151         * 2. Mark-up
    142152         * ------------------------------------------------------------------ */
    143153        ?>
    144154        <div class="wrap">
    145 
    146             <?php if ( $is_edit ) : ?>
    147                 <p style="margin:8px 0 18px;">
    148                     <strong><?php esc_html_e( 'Shortcode:', 'flex-forms' ); ?></strong>
    149                     <code class="flex-forms-copy-shortcode"
    150                             title="<?php esc_attr_e( 'Click to copy', 'flex-forms' ); ?>">
    151                         [flex-form id="<?php echo absint( $form_id ); ?>"]
    152                     </code>
    153                 </p>
    154             <?php endif; ?>
    155 
    156155            <form method="post">
    157156                <?php wp_nonce_field( 'flex_forms_builder_save', 'flex_forms_builder_nonce' ); ?>
    158157
    159                 <!-- ========================================================= -->
    160                 <!--  Store submissions in DB?                                 -->
    161                 <!-- ========================================================= -->
     158                <!-- Store submissions? -->
    162159                <table class="form-table">
    163160                    <tr>
     
    169166                <hr/>
    170167
    171                 <!-- ========================================================= -->
    172                 <!--  Form Builder                                             -->
    173                 <!-- ========================================================= -->
     168                <!-- Form Builder -->
    174169                <h2><?php esc_html_e( 'Form Builder', 'flex-forms' ); ?></h2>
    175 
    176170                <div class="field-desk">
    177                     <button type="button" class="button flex-forms-field-button" data-fieldtype="text">Text</button>
    178                     <button type="button" class="button flex-forms-field-button" data-fieldtype="email">Email</button>
    179                     <button type="button" class="button flex-forms-field-button" data-fieldtype="phone">Phone</button>
    180                     <button type="button" class="button flex-forms-field-button" data-fieldtype="date">Date</button>
    181                     <button type="button" class="button flex-forms-field-button" data-fieldtype="select">Select</button>
    182                     <button type="button" class="button flex-forms-field-button" data-fieldtype="checkbox">Checkbox</button>
    183                     <button type="button" class="button flex-forms-field-button" data-fieldtype="radio">Radio</button>
    184                     <button type="button" class="button flex-forms-field-button" data-fieldtype="textarea">Textarea</button>
    185                     <button type="button" class="button flex-forms-field-button" data-fieldtype="attachment">Attachment</button>
    186                     <button type="button" class="button flex-forms-field-button" data-fieldtype="button">Button</button>
     171                    <?php foreach ( array( 'text','email','phone','date','select','checkbox','radio','textarea','attachment','button' ) as $ftype ) : ?>
     172                        <button type="button" class="button flex-forms-field-button" data-fieldtype="<?php echo esc_attr( $ftype ); ?>"><?php echo ucfirst( $ftype ); ?></button>
     173                    <?php endforeach; ?>
    187174                </div>
    188 
    189175                <p class="description"><?php esc_html_e( 'Click a button to open the modal for field attributes. You can also edit the shortcode in the box below.', 'flex-forms' ); ?></p>
    190 
    191176                <textarea id="flex_forms_content" name="post_content" rows="10" style="width:100%;"><?php echo esc_textarea( $content_value ); ?></textarea>
    192177
    193                 <!-- ========================================================= -->
    194                 <!--  Field-attribute modal (added ID row)                     -->
    195                 <!-- ========================================================= -->
     178                <!-- Field attribute modal (includes input ID row) -->
    196179                <div id="flex-forms-field-modal" class="hidden fixed inset-0 z-50">
    197180                    <div class="flex-forms-modal-bg absolute inset-0 bg-black bg-opacity-50"></div>
    198181                    <div class="flex-forms-modal-content relative bg-white p-5 mx-auto mt-20 max-w-lg rounded shadow-lg">
    199 
    200182                        <button type="button" id="flex-forms-field-modal-close" style="float:right;">&times;</button>
    201183                        <h2><?php esc_html_e( 'Add Field', 'flex-forms' ); ?></h2>
     
    208190                            </tr>
    209191                            <tr>
    210                                 <th><label for="flex_forms_flex_field_label"><?php esc_html_e( 'Label (optional)', 'flex-forms' ); ?></label></th>
     192                                <th><label for="flex_forms_flex_field_label"><?php esc_html_e( 'Label', 'flex-forms' ); ?></label></th>
    211193                                <td><input type="text" id="flex_forms_flex_field_label" class="regular-text" /></td>
    212194                            </tr>
    213195                            <tr>
    214                                 <th><label for="flex_forms_flex_field_placeholder"><?php esc_html_e( 'Placeholder (optional)', 'flex-forms' ); ?></label></th>
     196                                <th><label for="flex_forms_flex_field_placeholder"><?php esc_html_e( 'Placeholder', 'flex-forms' ); ?></label></th>
    215197                                <td><input type="text" id="flex_forms_flex_field_placeholder" class="regular-text" /></td>
    216198                            </tr>
     199                            <!-- NEW: individual input ID -->
    217200                            <tr>
    218201                                <th><label for="flex_forms_flex_field_id"><?php esc_html_e( 'ID (optional)', 'flex-forms' ); ?></label></th>
     
    220203                            </tr>
    221204                            <tr>
    222                                 <th><label for="flex_forms_flex_field_class"><?php esc_html_e( 'CSS Class (optional)', 'flex-forms' ); ?></label></th>
     205                                <th><label for="flex_forms_flex_field_class"><?php esc_html_e( 'CSS Class', 'flex-forms' ); ?></label></th>
    223206                                <td><input type="text" id="flex_forms_flex_field_class" class="regular-text" /></td>
    224207                            </tr>
    225208                            <tr>
    226                                 <th><label for="flex_forms_flex_field_default"><?php esc_html_e( 'Default Value (optional)', 'flex-forms' ); ?></label></th>
     209                                <th><label for="flex_forms_flex_field_default"><?php esc_html_e( 'Default Value', 'flex-forms' ); ?></label></th>
    227210                                <td><input type="text" id="flex_forms_flex_field_default" class="regular-text" /></td>
    228211                            </tr>
     
    260243                </div>
    261244
    262                 <!-- ========================================================= -->
    263                 <!--  …everything else in the meta-box (email, success, error) -->
    264                 <!--  is unchanged and continues here…                         -->
    265                 <!-- ========================================================= -->
    266 
    267                 <!-- (The remainder of this function is identical to the        -->
    268                 <!--  previous version you integrated, so it’s not repeated.)   -->
    269 
     245                <hr/>
     246
     247                <!-- Email Templates section (admin + user) -->
     248                <?php
     249                $current_user       = wp_get_current_user();
     250                $admin_email_from   = $is_edit ? get_post_meta( $form_id, '_flex_forms_admin_email_from', true )      : $current_user->user_email;
     251                $admin_name_from    = $is_edit ? get_post_meta( $form_id, '_flex_forms_admin_email_from_name', true ) : $current_user->display_name;
     252                $admin_email_to     = $is_edit ? get_post_meta( $form_id, '_flex_forms_admin_email_to', true )        : $current_user->user_email;
     253                ?>
     254
     255                <h2><?php esc_html_e( 'Email Templates', 'flex-forms' ); ?></h2>
     256                <p><?php esc_html_e( 'Use shortcodes like [name], [phone], etc. in your email body to include user-submitted data.', 'flex-forms' ); ?></p>
     257
     258                <!-- Admin email -->
     259                <h3><?php esc_html_e( 'Admin Email', 'flex-forms' ); ?></h3>
     260                <table class="form-table">
     261                    <tr>
     262                        <th><label for="flex_forms_admin_email_from"><?php esc_html_e( 'From Email', 'flex-forms' ); ?></label></th>
     263                        <td><input type="email" id="flex_forms_admin_email_from" name="flex_forms_admin_email_from" class="regular-text" value="<?php echo esc_attr( $admin_email_from ); ?>" required /></td>
     264                    </tr>
     265                    <tr>
     266                        <th><label for="flex_forms_admin_email_from_name"><?php esc_html_e( 'From Name', 'flex-forms' ); ?></label></th>
     267                        <td><input type="text" id="flex_forms_admin_email_from_name" name="flex_forms_admin_email_from_name" class="regular-text" value="<?php echo esc_attr( $admin_name_from ); ?>" required /></td>
     268                    </tr>
     269                    <tr>
     270                        <th><label for="flex_forms_admin_email_to"><?php esc_html_e( 'Email To', 'flex-forms' ); ?></label></th>
     271                        <td><input type="email" id="flex_forms_admin_email_to" name="flex_forms_admin_email_to" class="regular-text" value="<?php echo esc_attr( $admin_email_to ); ?>" required /></td>
     272                    </tr>
     273                    <tr>
     274                        <th><label for="flex_forms_admin_email_subject"><?php esc_html_e( 'Subject', 'flex-forms' ); ?></label></th>
     275                        <td><input type="text" id="flex_forms_admin_email_subject" name="flex_forms_admin_email_subject" class="regular-text" value="<?php echo esc_attr( $admin_email_subject_val ); ?>" placeholder="<?php esc_attr_e( 'New Form Submission', 'flex-forms' ); ?>" /></td>
     276                    </tr>
     277                    <tr>
     278                        <th><label for="flex_forms_admin_email_template"><?php esc_html_e( 'Email Body', 'flex-forms' ); ?></label></th>
     279                        <td>
     280                            <textarea id="flex_forms_admin_email_template" name="flex_forms_admin_email_template" rows="5" style="width:100%;"><?php echo esc_textarea( $admin_email_template_val ); ?></textarea>
     281                            <p class="description"><?php esc_html_e( 'HTML allowed. Use placeholders like [Name], [Email], etc.', 'flex-forms' ); ?></p>
     282                        </td>
     283                    </tr>
     284                </table>
     285
     286                <hr/>
     287
     288                <!-- User email -->
     289                <h2><?php esc_html_e( 'User Email', 'flex-forms' ); ?></h2>
     290                <table class="form-table">
     291                    <tr>
     292                        <th><?php esc_html_e( 'Enable User Email', 'flex-forms' ); ?></th>
     293                        <td>
     294                            <label>
     295                                <input type="checkbox" name="flex_forms_user_email_enable" value="1" <?php checked( 1, $user_email_enable_val ); ?> />
     296                                <?php esc_html_e( 'Send a confirmation email to the user', 'flex-forms' ); ?>
     297                            </label>
     298                        </td>
     299                    </tr>
     300                    <tr>
     301                        <th><label for="flex_forms_user_email_email_shortcode"><?php esc_html_e( 'Email shortcode', 'flex-forms' ); ?></label></th>
     302                        <td>
     303                            <div id="flex_forms_user_email_email_shortcode_wrapper"></div>
     304                            <noscript>
     305                                <input type="text" name="flex_forms_user_email_email_shortcode" class="regular-text" value="<?php echo esc_attr( $user_email_shortcode_val ); ?>" placeholder="<?php esc_attr_e( 'User email shortcode (enter manually)', 'flex-forms' ); ?>" />
     306                            </noscript>
     307                            <p class="description"><?php esc_html_e( 'Select the shortcode which corresponds to the user’s email field.', 'flex-forms' ); ?></p>
     308
     309                            <script>
     310                              document.addEventListener('DOMContentLoaded', function () {
     311                                const contentInput = document.getElementById('flex_forms_content');
     312                                const wrapper      = document.getElementById('flex_forms_user_email_email_shortcode_wrapper');
     313                                const savedValue   = <?php echo json_encode( $user_email_shortcode_val ); ?>;
     314
     315                                function extractShortcodeNames(content) {
     316                                  const regex = /\[flex-form-field[^\]]*?name\s*=\s*"(.*?)"[^\]]*?\]/g;
     317                                  let match, names = [];
     318                                  while ((match = regex.exec(content)) !== null) {
     319                                    if (!names.includes(match[1])) names.push(match[1]);
     320                                  }
     321                                  return names;
     322                                }
     323
     324                                function renderRadios() {
     325                                  const names = extractShortcodeNames(contentInput.value);
     326                                  wrapper.innerHTML = '';
     327
     328                                  if (names.length === 0) {
     329                                    wrapper.innerHTML = '<em><?php echo esc_js( __( 'No fields found. Add fields above to see options here.', 'flex-forms' ) ); ?></em>';
     330                                    return;
     331                                  }
     332
     333                                  names.forEach(name => {
     334                                    const value = `[${name}]`;
     335                                    const id    = `email_shortcode_${name}`;
     336
     337                                    const radio = document.createElement('input');
     338                                    radio.type  = 'radio';
     339                                    radio.name  = 'flex_forms_user_email_email_shortcode';
     340                                    radio.id    = id;
     341                                    radio.value = value;
     342                                    if (value === savedValue) radio.checked = true;
     343
     344                                    const label = document.createElement('label');
     345                                    label.setAttribute('for', id);
     346                                    label.style.marginRight  = '15px';
     347                                    label.style.display      = 'inline-block';
     348                                    label.appendChild(radio);
     349                                    label.append(` ${value}`);
     350
     351                                    wrapper.appendChild(label);
     352                                  });
     353                                }
     354
     355                                renderRadios();
     356                                contentInput.addEventListener('input', renderRadios);
     357                              });
     358                            </script>
     359                        </td>
     360                    </tr>
     361                    <tr>
     362                        <th><label for="flex_forms_user_email_subject"><?php esc_html_e( 'Subject', 'flex-forms' ); ?></label></th>
     363                        <td><input type="text" id="flex_forms_user_email_subject" name="flex_forms_user_email_subject" class="regular-text" value="<?php echo esc_attr( $user_email_subject_val ); ?>" placeholder="<?php esc_attr_e( 'Thank you for your submission', 'flex-forms' ); ?>" /></td>
     364                    </tr>
     365                    <tr>
     366                        <th><label for="flex_forms_user_email_template"><?php esc_html_e( 'Email Body', 'flex-forms' ); ?></label></th>
     367                        <td>
     368                            <textarea id="flex_forms_user_email_template" name="flex_forms_user_email_template" rows="5" style="width:100%;"><?php echo esc_textarea( $user_email_template_val ); ?></textarea>
     369                            <p class="description"><?php esc_html_e( 'HTML allowed. Use placeholders like [Name], [Email], etc.', 'flex-forms' ); ?></p>
     370                        </td>
     371                    </tr>
     372                </table>
     373
     374                <hr/>
     375
     376                <!-- Success settings -->
     377                <h2><?php esc_html_e( 'Success Settings', 'flex-forms' ); ?></h2>
     378                <table class="form-table">
     379                    <tr>
     380                        <th><?php esc_html_e( 'On Success', 'flex-forms' ); ?></th>
     381                        <td>
     382                            <label><input type="radio" name="flex_forms_success_behavior" value="redirect" <?php checked( 'redirect', $success_behavior_value ); ?> /> <?php esc_html_e( 'Redirect to URL', 'flex-forms' ); ?></label><br/>
     383                            <label><input type="radio" name="flex_forms_success_behavior" value="message"  <?php checked( 'message',  $success_behavior_value ); ?> /> <?php esc_html_e( 'Show Text Message', 'flex-forms' ); ?></label>
     384                        </td>
     385                    </tr>
     386                    <tr class="flex-forms-success-redirect-row">
     387                        <th><label for="flex_forms_success_redirect_url"><?php esc_html_e( 'Success Redirect URL', 'flex-forms' ); ?></label></th>
     388                        <td><input type="url" id="flex_forms_success_redirect_url" name="flex_forms_success_redirect_url" class="regular-text" value="<?php echo esc_attr( $success_redirect_url_val ); ?>" /></td>
     389                    </tr>
     390                    <tr class="flex-forms-success-text-row">
     391                        <th><label for="flex_forms_success_text"><?php esc_html_e( 'Success Message', 'flex-forms' ); ?></label></th>
     392                        <td><textarea id="flex_forms_success_text" name="flex_forms_success_text" rows="3" style="width:100%;"><?php echo esc_textarea( $success_text_val ); ?></textarea></td>
     393                    </tr>
     394                </table>
     395
     396                <hr/>
     397
     398                <!-- Error settings -->
     399                <h2><?php esc_html_e( 'Error Settings', 'flex-forms' ); ?></h2>
     400                <table class="form-table">
     401                    <tr>
     402                        <th><?php esc_html_e( 'On Error', 'flex-forms' ); ?></th>
     403                        <td>
     404                            <label><input type="radio" name="flex_forms_error_behavior" value="redirect" <?php checked( 'redirect', $error_behavior_value ); ?> /> <?php esc_html_e( 'Redirect to URL', 'flex-forms' ); ?></label><br/>
     405                            <label><input type="radio" name="flex_forms_error_behavior" value="message"  <?php checked( 'message',  $error_behavior_value ); ?> /> <?php esc_html_e( 'Show Text Message', 'flex-forms' ); ?></label>
     406                        </td>
     407                    </tr>
     408                    <tr class="flex-forms-error-redirect-row">
     409                        <th><label for="flex_forms_error_redirect_url"><?php esc_html_e( 'Error Redirect URL', 'flex-forms' ); ?></label></th>
     410                        <td><input type="url" id="flex_forms_error_redirect_url" name="flex_forms_error_redirect_url" class="regular-text" value="<?php echo esc_attr( $error_redirect_url_val ); ?>" /></td>
     411                    </tr>
     412                    <tr class="flex-forms-error-text-row">
     413                        <th><label for="flex_forms_error_text"><?php esc_html_e( 'Error Message', 'flex-forms' ); ?></label></th>
     414                        <td><textarea id="flex_forms_error_text" name="flex_forms_error_text" rows="3" style="width:100%;"><?php echo esc_textarea( $error_text_val ); ?></textarea></td>
     415                    </tr>
     416                </table>
     417
     418                <hr/>
     419
     420                <!-- NEW: form-level attributes -->
     421                <h2><?php esc_html_e( 'Form Attributes', 'flex-forms' ); ?></h2>
     422                <table class="form-table">
     423                    <tr>
     424                        <th><label for="flex_forms_form_id"><?php esc_html_e( 'Form ID attribute', 'flex-forms' ); ?></label></th>
     425                        <td><input type="text" id="flex_forms_form_id" name="flex_forms_form_id" class="regular-text" value="<?php echo esc_attr( $form_id_attr_val ); ?>" placeholder="<?php esc_attr_e( 'e.g. my-form', 'flex-forms' ); ?>" /></td>
     426                    </tr>
     427                    <tr>
     428                        <th><label for="flex_forms_form_class"><?php esc_html_e( 'Form CSS classes', 'flex-forms' ); ?></label></th>
     429                        <td><input type="text" id="flex_forms_form_class" name="flex_forms_form_class" class="regular-text" value="<?php echo esc_attr( $form_class_val ); ?>" placeholder="<?php esc_attr_e( 'class1 class2', 'flex-forms' ); ?>" /></td>
     430                    </tr>
     431                    <tr>
     432                        <th><label for="flex_forms_form_attrs"><?php esc_html_e( 'Additional attributes', 'flex-forms' ); ?></label></th>
     433                        <td><input type="text" id="flex_forms_form_attrs" name="flex_forms_form_attrs" class="regular-text" value="<?php echo esc_attr( $form_attrs_val ); ?>" placeholder='<?php esc_attr_e( 'data-theme="dark" tabindex="0"', 'flex-forms' ); ?>' /></td>
     434                    </tr>
     435                </table>
     436
     437                <hr/>
     438
     439                <!-- Custom CSS -->
     440                <h2><?php esc_html_e( 'Custom CSS', 'flex-forms' ); ?></h2>
     441                <textarea name="flex_forms_custom_css" rows="4" style="width:100%;"><?php echo esc_textarea( $custom_css_val ); ?></textarea>
     442                <p class="description"><?php esc_html_e( 'This CSS will be injected on the front end for this form only.', 'flex-forms' ); ?></p>
    270443            </form>
    271444        </div>
  • flex-forms/tags/2.1.1/readme.txt

    r3305607 r3305740  
    11=== Flex Forms ===
    2 Contributors: flexfields
    3 Donate link: https://future-systems.am/
    4 Tags: form, field, shortcode, input, email
    5 Requires at least: 5.0
    6 Tested up to: 6.8
    7 Requires PHP: 7.0
    8 Stable tag: 2.1.0
    9 License: GPLv2 or later
    10 License URI: https://www.gnu.org/licenses/gpl-2.0.html
     2Contributors:       flexfields
     3Donate link:        https://future-systems.am/
     4Tags:               form, field, shortcode, input, email
     5Requires at least:  5.0
     6Tested up to:       6.8
     7Requires PHP:       7.0
     8Stable tag:         2.1.0
     9License:            GPLv2 or later
     10License URI:        https://www.gnu.org/licenses/gpl-2.0.html
    1111
    12 Flex Forms
     12A lightweight yet powerful form builder with database storage, e-mail alerts, reCAPTCHA and deep Flex Fields integration.
    1313
    1414== Description ==
     
    2323* **When data is sent:** When a user submits a form.
    2424* **Where data is sent:** To the configured email recipient(s) via the selected email service.
    25 * **Privacy & Terms:** The email service provider's policies apply if an external service is used (e.g., SendGrid [https://sendgrid.com/policies/tos/], Mailgun [https://www.mailgun.com/legal/]).
     25* **Privacy & Terms:** The email service provider's policies apply if an external service is used (e.g., SendGrid <https://sendgrid.com/policies/tos/>, Mailgun <https://www.mailgun.com/legal/>).
    2626
    2727Additionally, Flex Forms supports Google reCAPTCHA v2 and v3 for spam protection.
     
    3737
    3838* **Privacy & Terms:**
    39   - [Google reCAPTCHA Terms of Service](https://policies.google.com/terms)
    40   - [Google reCAPTCHA Privacy Policy](https://policies.google.com/privacy)
     39  - <https://policies.google.com/terms>
     40  - <https://policies.google.com/privacy>
  • flex-forms/trunk/includes/class-flex-forms-main.php

    r3305607 r3305740  
    9595    }
    9696
    97     /**
    98      * Render the Flex Form builder meta-box.
    99      *
    100      * @param WP_Post $post Current flex_form post.
    101      */
    10297    public function flex_form_meta_box_callback( $post ) {
    10398
    104         /* --------------------------------------------------------------------
     99        /* ---------------------------------------------------------------------
    105100         * 1. Context & stored values
    106101         * ------------------------------------------------------------------ */
    107         $screen  = get_current_screen();
    108         $is_edit = ( $screen->action !== 'add' );
    109         $form_id = $post->ID;
    110 
    111         /* Content */
    112         $content_value = $is_edit ? $post->post_content : '';
    113 
    114         /* Success & error behaviours */
    115         $success_behavior_value   = $is_edit ? get_post_meta( $form_id, '_flex_forms_success_behavior',     true ) : 'message';
    116         $success_redirect_url_val = $is_edit ? get_post_meta( $form_id, '_flex_forms_success_redirect_url', true ) : '';
    117         $success_text_val         = $is_edit ? get_post_meta( $form_id, '_flex_forms_success_text',         true ) : 'Your form has been successfully submitted!';
    118 
    119         $error_behavior_value     = $is_edit ? get_post_meta( $form_id, '_flex_forms_error_behavior',       true ) : 'message';
    120         $error_redirect_url_val   = $is_edit ? get_post_meta( $form_id, '_flex_forms_error_redirect_url',   true ) : '';
    121         $error_text_val           = $is_edit ? get_post_meta( $form_id, '_flex_forms_error_text',           true ) : 'There was an error submitting the form. Please try again.';
    122 
    123         /* Storage & e-mail */
    124         $store_in_db_val                          = $is_edit ? get_post_meta( $form_id, '_flex_forms_store_in_db',                  true ) : 0;
    125         $admin_email_subject_val                  = $is_edit ? get_post_meta( $form_id, '_flex_forms_admin_email_subject',         true ) : '';
    126         $admin_email_template_val                 = $is_edit ? get_post_meta( $form_id, '_flex_forms_admin_email_template',        true ) : '';
    127         $user_email_enable_val                    = $is_edit ? get_post_meta( $form_id, '_flex_forms_user_email_enable',           true ) : 0;
    128         $flex_forms_user_email_email_shortcode_val = $is_edit ? get_post_meta( $form_id, '_flex_forms_user_email_email_shortcode', true ) : '';
    129         $user_email_subject_val                   = $is_edit ? get_post_meta( $form_id, '_flex_forms_user_email_subject',          true ) : '';
    130         $user_email_template_val                  = $is_edit ? get_post_meta( $form_id, '_flex_forms_user_email_template',         true ) : '';
    131 
    132         /* Form-level attributes */
    133         $form_id_attr_val = $is_edit ? get_post_meta( $form_id, '_flex_forms_form_id',    true ) : '';
    134         $form_class_val   = $is_edit ? get_post_meta( $form_id, '_flex_forms_form_class', true ) : '';
    135         $form_attrs_val   = $is_edit ? get_post_meta( $form_id, '_flex_forms_form_attrs', true ) : '';
     102        $screen   = get_current_screen();
     103        $is_edit  = ( $screen->action !== 'add' );
     104        $form_id  = $post->ID;
     105
     106        // Show shortcode at page top (click-to-copy handled by JS already enqueued)
     107        if ( $is_edit ) {
     108            printf(
     109                '<p style="margin:8px 0 18px;">
     110                <strong>%s</strong>
     111                <code class="flex-forms-copy-shortcode" title="%s">[flex-form id="%d"]</code>
     112            </p>',
     113                esc_html__( 'Shortcode:', 'flex-forms' ),
     114                esc_attr__( 'Click to copy', 'flex-forms' ),
     115                absint( $form_id )
     116            );
     117        }
     118
     119        /* Core content */
     120        $content_value                = $is_edit ? $post->post_content : '';
     121
     122        /* Success / error behaviour */
     123        $success_behavior_value       = $is_edit ? get_post_meta( $form_id, '_flex_forms_success_behavior', true )       : 'message';
     124        $success_redirect_url_val     = $is_edit ? get_post_meta( $form_id, '_flex_forms_success_redirect_url', true )   : '';
     125        $success_text_val             = $is_edit ? get_post_meta( $form_id, '_flex_forms_success_text', true )           : 'Your form has been successfully submitted!';
     126
     127        $error_behavior_value         = $is_edit ? get_post_meta( $form_id, '_flex_forms_error_behavior', true )         : 'message';
     128        $error_redirect_url_val       = $is_edit ? get_post_meta( $form_id, '_flex_forms_error_redirect_url', true )     : '';
     129        $error_text_val               = $is_edit ? get_post_meta( $form_id, '_flex_forms_error_text', true )             : 'There was an error submitting the form. Please try again.';
     130
     131        /* Storage & email */
     132        $store_in_db_val              = $is_edit ? get_post_meta( $form_id, '_flex_forms_store_in_db', true )            : 0;
     133
     134        $admin_email_subject_val      = $is_edit ? get_post_meta( $form_id, '_flex_forms_admin_email_subject', true )    : '';
     135        $admin_email_template_val     = $is_edit ? get_post_meta( $form_id, '_flex_forms_admin_email_template', true )   : '';
     136
     137        $user_email_enable_val        = $is_edit ? get_post_meta( $form_id, '_flex_forms_user_email_enable', true )      : 0;
     138        $user_email_shortcode_val     = $is_edit ? get_post_meta( $form_id, '_flex_forms_user_email_email_shortcode', true ) : '';
     139        $user_email_subject_val       = $is_edit ? get_post_meta( $form_id, '_flex_forms_user_email_subject', true )     : '';
     140        $user_email_template_val      = $is_edit ? get_post_meta( $form_id, '_flex_forms_user_email_template', true )    : '';
     141
     142        /* NEW: form-level attributes */
     143        $form_id_attr_val             = $is_edit ? get_post_meta( $form_id, '_flex_forms_form_id', true )                : '';
     144        $form_class_val               = $is_edit ? get_post_meta( $form_id, '_flex_forms_form_class', true )             : '';
     145        $form_attrs_val               = $is_edit ? get_post_meta( $form_id, '_flex_forms_form_attrs', true )             : '';
    136146
    137147        /* Custom CSS */
    138         $custom_css_val   = $is_edit ? get_post_meta( $form_id, '_flex_forms_custom_css', true ) : '';
    139 
    140         /* --------------------------------------------------------------------
    141          * 2. Output
     148        $custom_css_val               = $is_edit ? get_post_meta( $form_id, '_flex_forms_custom_css', true )            : '';
     149
     150        /* ---------------------------------------------------------------------
     151         * 2. Mark-up
    142152         * ------------------------------------------------------------------ */
    143153        ?>
    144154        <div class="wrap">
    145 
    146             <?php if ( $is_edit ) : ?>
    147                 <p style="margin:8px 0 18px;">
    148                     <strong><?php esc_html_e( 'Shortcode:', 'flex-forms' ); ?></strong>
    149                     <code class="flex-forms-copy-shortcode"
    150                             title="<?php esc_attr_e( 'Click to copy', 'flex-forms' ); ?>">
    151                         [flex-form id="<?php echo absint( $form_id ); ?>"]
    152                     </code>
    153                 </p>
    154             <?php endif; ?>
    155 
    156155            <form method="post">
    157156                <?php wp_nonce_field( 'flex_forms_builder_save', 'flex_forms_builder_nonce' ); ?>
    158157
    159                 <!-- ========================================================= -->
    160                 <!--  Store submissions in DB?                                 -->
    161                 <!-- ========================================================= -->
     158                <!-- Store submissions? -->
    162159                <table class="form-table">
    163160                    <tr>
     
    169166                <hr/>
    170167
    171                 <!-- ========================================================= -->
    172                 <!--  Form Builder                                             -->
    173                 <!-- ========================================================= -->
     168                <!-- Form Builder -->
    174169                <h2><?php esc_html_e( 'Form Builder', 'flex-forms' ); ?></h2>
    175 
    176170                <div class="field-desk">
    177                     <button type="button" class="button flex-forms-field-button" data-fieldtype="text">Text</button>
    178                     <button type="button" class="button flex-forms-field-button" data-fieldtype="email">Email</button>
    179                     <button type="button" class="button flex-forms-field-button" data-fieldtype="phone">Phone</button>
    180                     <button type="button" class="button flex-forms-field-button" data-fieldtype="date">Date</button>
    181                     <button type="button" class="button flex-forms-field-button" data-fieldtype="select">Select</button>
    182                     <button type="button" class="button flex-forms-field-button" data-fieldtype="checkbox">Checkbox</button>
    183                     <button type="button" class="button flex-forms-field-button" data-fieldtype="radio">Radio</button>
    184                     <button type="button" class="button flex-forms-field-button" data-fieldtype="textarea">Textarea</button>
    185                     <button type="button" class="button flex-forms-field-button" data-fieldtype="attachment">Attachment</button>
    186                     <button type="button" class="button flex-forms-field-button" data-fieldtype="button">Button</button>
     171                    <?php foreach ( array( 'text','email','phone','date','select','checkbox','radio','textarea','attachment','button' ) as $ftype ) : ?>
     172                        <button type="button" class="button flex-forms-field-button" data-fieldtype="<?php echo esc_attr( $ftype ); ?>"><?php echo ucfirst( $ftype ); ?></button>
     173                    <?php endforeach; ?>
    187174                </div>
    188 
    189175                <p class="description"><?php esc_html_e( 'Click a button to open the modal for field attributes. You can also edit the shortcode in the box below.', 'flex-forms' ); ?></p>
    190 
    191176                <textarea id="flex_forms_content" name="post_content" rows="10" style="width:100%;"><?php echo esc_textarea( $content_value ); ?></textarea>
    192177
    193                 <!-- ========================================================= -->
    194                 <!--  Field-attribute modal (added ID row)                     -->
    195                 <!-- ========================================================= -->
     178                <!-- Field attribute modal (includes input ID row) -->
    196179                <div id="flex-forms-field-modal" class="hidden fixed inset-0 z-50">
    197180                    <div class="flex-forms-modal-bg absolute inset-0 bg-black bg-opacity-50"></div>
    198181                    <div class="flex-forms-modal-content relative bg-white p-5 mx-auto mt-20 max-w-lg rounded shadow-lg">
    199 
    200182                        <button type="button" id="flex-forms-field-modal-close" style="float:right;">&times;</button>
    201183                        <h2><?php esc_html_e( 'Add Field', 'flex-forms' ); ?></h2>
     
    208190                            </tr>
    209191                            <tr>
    210                                 <th><label for="flex_forms_flex_field_label"><?php esc_html_e( 'Label (optional)', 'flex-forms' ); ?></label></th>
     192                                <th><label for="flex_forms_flex_field_label"><?php esc_html_e( 'Label', 'flex-forms' ); ?></label></th>
    211193                                <td><input type="text" id="flex_forms_flex_field_label" class="regular-text" /></td>
    212194                            </tr>
    213195                            <tr>
    214                                 <th><label for="flex_forms_flex_field_placeholder"><?php esc_html_e( 'Placeholder (optional)', 'flex-forms' ); ?></label></th>
     196                                <th><label for="flex_forms_flex_field_placeholder"><?php esc_html_e( 'Placeholder', 'flex-forms' ); ?></label></th>
    215197                                <td><input type="text" id="flex_forms_flex_field_placeholder" class="regular-text" /></td>
    216198                            </tr>
     199                            <!-- NEW: individual input ID -->
    217200                            <tr>
    218201                                <th><label for="flex_forms_flex_field_id"><?php esc_html_e( 'ID (optional)', 'flex-forms' ); ?></label></th>
     
    220203                            </tr>
    221204                            <tr>
    222                                 <th><label for="flex_forms_flex_field_class"><?php esc_html_e( 'CSS Class (optional)', 'flex-forms' ); ?></label></th>
     205                                <th><label for="flex_forms_flex_field_class"><?php esc_html_e( 'CSS Class', 'flex-forms' ); ?></label></th>
    223206                                <td><input type="text" id="flex_forms_flex_field_class" class="regular-text" /></td>
    224207                            </tr>
    225208                            <tr>
    226                                 <th><label for="flex_forms_flex_field_default"><?php esc_html_e( 'Default Value (optional)', 'flex-forms' ); ?></label></th>
     209                                <th><label for="flex_forms_flex_field_default"><?php esc_html_e( 'Default Value', 'flex-forms' ); ?></label></th>
    227210                                <td><input type="text" id="flex_forms_flex_field_default" class="regular-text" /></td>
    228211                            </tr>
     
    260243                </div>
    261244
    262                 <!-- ========================================================= -->
    263                 <!--  …everything else in the meta-box (email, success, error) -->
    264                 <!--  is unchanged and continues here…                         -->
    265                 <!-- ========================================================= -->
    266 
    267                 <!-- (The remainder of this function is identical to the        -->
    268                 <!--  previous version you integrated, so it’s not repeated.)   -->
    269 
     245                <hr/>
     246
     247                <!-- Email Templates section (admin + user) -->
     248                <?php
     249                $current_user       = wp_get_current_user();
     250                $admin_email_from   = $is_edit ? get_post_meta( $form_id, '_flex_forms_admin_email_from', true )      : $current_user->user_email;
     251                $admin_name_from    = $is_edit ? get_post_meta( $form_id, '_flex_forms_admin_email_from_name', true ) : $current_user->display_name;
     252                $admin_email_to     = $is_edit ? get_post_meta( $form_id, '_flex_forms_admin_email_to', true )        : $current_user->user_email;
     253                ?>
     254
     255                <h2><?php esc_html_e( 'Email Templates', 'flex-forms' ); ?></h2>
     256                <p><?php esc_html_e( 'Use shortcodes like [name], [phone], etc. in your email body to include user-submitted data.', 'flex-forms' ); ?></p>
     257
     258                <!-- Admin email -->
     259                <h3><?php esc_html_e( 'Admin Email', 'flex-forms' ); ?></h3>
     260                <table class="form-table">
     261                    <tr>
     262                        <th><label for="flex_forms_admin_email_from"><?php esc_html_e( 'From Email', 'flex-forms' ); ?></label></th>
     263                        <td><input type="email" id="flex_forms_admin_email_from" name="flex_forms_admin_email_from" class="regular-text" value="<?php echo esc_attr( $admin_email_from ); ?>" required /></td>
     264                    </tr>
     265                    <tr>
     266                        <th><label for="flex_forms_admin_email_from_name"><?php esc_html_e( 'From Name', 'flex-forms' ); ?></label></th>
     267                        <td><input type="text" id="flex_forms_admin_email_from_name" name="flex_forms_admin_email_from_name" class="regular-text" value="<?php echo esc_attr( $admin_name_from ); ?>" required /></td>
     268                    </tr>
     269                    <tr>
     270                        <th><label for="flex_forms_admin_email_to"><?php esc_html_e( 'Email To', 'flex-forms' ); ?></label></th>
     271                        <td><input type="email" id="flex_forms_admin_email_to" name="flex_forms_admin_email_to" class="regular-text" value="<?php echo esc_attr( $admin_email_to ); ?>" required /></td>
     272                    </tr>
     273                    <tr>
     274                        <th><label for="flex_forms_admin_email_subject"><?php esc_html_e( 'Subject', 'flex-forms' ); ?></label></th>
     275                        <td><input type="text" id="flex_forms_admin_email_subject" name="flex_forms_admin_email_subject" class="regular-text" value="<?php echo esc_attr( $admin_email_subject_val ); ?>" placeholder="<?php esc_attr_e( 'New Form Submission', 'flex-forms' ); ?>" /></td>
     276                    </tr>
     277                    <tr>
     278                        <th><label for="flex_forms_admin_email_template"><?php esc_html_e( 'Email Body', 'flex-forms' ); ?></label></th>
     279                        <td>
     280                            <textarea id="flex_forms_admin_email_template" name="flex_forms_admin_email_template" rows="5" style="width:100%;"><?php echo esc_textarea( $admin_email_template_val ); ?></textarea>
     281                            <p class="description"><?php esc_html_e( 'HTML allowed. Use placeholders like [Name], [Email], etc.', 'flex-forms' ); ?></p>
     282                        </td>
     283                    </tr>
     284                </table>
     285
     286                <hr/>
     287
     288                <!-- User email -->
     289                <h2><?php esc_html_e( 'User Email', 'flex-forms' ); ?></h2>
     290                <table class="form-table">
     291                    <tr>
     292                        <th><?php esc_html_e( 'Enable User Email', 'flex-forms' ); ?></th>
     293                        <td>
     294                            <label>
     295                                <input type="checkbox" name="flex_forms_user_email_enable" value="1" <?php checked( 1, $user_email_enable_val ); ?> />
     296                                <?php esc_html_e( 'Send a confirmation email to the user', 'flex-forms' ); ?>
     297                            </label>
     298                        </td>
     299                    </tr>
     300                    <tr>
     301                        <th><label for="flex_forms_user_email_email_shortcode"><?php esc_html_e( 'Email shortcode', 'flex-forms' ); ?></label></th>
     302                        <td>
     303                            <div id="flex_forms_user_email_email_shortcode_wrapper"></div>
     304                            <noscript>
     305                                <input type="text" name="flex_forms_user_email_email_shortcode" class="regular-text" value="<?php echo esc_attr( $user_email_shortcode_val ); ?>" placeholder="<?php esc_attr_e( 'User email shortcode (enter manually)', 'flex-forms' ); ?>" />
     306                            </noscript>
     307                            <p class="description"><?php esc_html_e( 'Select the shortcode which corresponds to the user’s email field.', 'flex-forms' ); ?></p>
     308
     309                            <script>
     310                              document.addEventListener('DOMContentLoaded', function () {
     311                                const contentInput = document.getElementById('flex_forms_content');
     312                                const wrapper      = document.getElementById('flex_forms_user_email_email_shortcode_wrapper');
     313                                const savedValue   = <?php echo json_encode( $user_email_shortcode_val ); ?>;
     314
     315                                function extractShortcodeNames(content) {
     316                                  const regex = /\[flex-form-field[^\]]*?name\s*=\s*"(.*?)"[^\]]*?\]/g;
     317                                  let match, names = [];
     318                                  while ((match = regex.exec(content)) !== null) {
     319                                    if (!names.includes(match[1])) names.push(match[1]);
     320                                  }
     321                                  return names;
     322                                }
     323
     324                                function renderRadios() {
     325                                  const names = extractShortcodeNames(contentInput.value);
     326                                  wrapper.innerHTML = '';
     327
     328                                  if (names.length === 0) {
     329                                    wrapper.innerHTML = '<em><?php echo esc_js( __( 'No fields found. Add fields above to see options here.', 'flex-forms' ) ); ?></em>';
     330                                    return;
     331                                  }
     332
     333                                  names.forEach(name => {
     334                                    const value = `[${name}]`;
     335                                    const id    = `email_shortcode_${name}`;
     336
     337                                    const radio = document.createElement('input');
     338                                    radio.type  = 'radio';
     339                                    radio.name  = 'flex_forms_user_email_email_shortcode';
     340                                    radio.id    = id;
     341                                    radio.value = value;
     342                                    if (value === savedValue) radio.checked = true;
     343
     344                                    const label = document.createElement('label');
     345                                    label.setAttribute('for', id);
     346                                    label.style.marginRight  = '15px';
     347                                    label.style.display      = 'inline-block';
     348                                    label.appendChild(radio);
     349                                    label.append(` ${value}`);
     350
     351                                    wrapper.appendChild(label);
     352                                  });
     353                                }
     354
     355                                renderRadios();
     356                                contentInput.addEventListener('input', renderRadios);
     357                              });
     358                            </script>
     359                        </td>
     360                    </tr>
     361                    <tr>
     362                        <th><label for="flex_forms_user_email_subject"><?php esc_html_e( 'Subject', 'flex-forms' ); ?></label></th>
     363                        <td><input type="text" id="flex_forms_user_email_subject" name="flex_forms_user_email_subject" class="regular-text" value="<?php echo esc_attr( $user_email_subject_val ); ?>" placeholder="<?php esc_attr_e( 'Thank you for your submission', 'flex-forms' ); ?>" /></td>
     364                    </tr>
     365                    <tr>
     366                        <th><label for="flex_forms_user_email_template"><?php esc_html_e( 'Email Body', 'flex-forms' ); ?></label></th>
     367                        <td>
     368                            <textarea id="flex_forms_user_email_template" name="flex_forms_user_email_template" rows="5" style="width:100%;"><?php echo esc_textarea( $user_email_template_val ); ?></textarea>
     369                            <p class="description"><?php esc_html_e( 'HTML allowed. Use placeholders like [Name], [Email], etc.', 'flex-forms' ); ?></p>
     370                        </td>
     371                    </tr>
     372                </table>
     373
     374                <hr/>
     375
     376                <!-- Success settings -->
     377                <h2><?php esc_html_e( 'Success Settings', 'flex-forms' ); ?></h2>
     378                <table class="form-table">
     379                    <tr>
     380                        <th><?php esc_html_e( 'On Success', 'flex-forms' ); ?></th>
     381                        <td>
     382                            <label><input type="radio" name="flex_forms_success_behavior" value="redirect" <?php checked( 'redirect', $success_behavior_value ); ?> /> <?php esc_html_e( 'Redirect to URL', 'flex-forms' ); ?></label><br/>
     383                            <label><input type="radio" name="flex_forms_success_behavior" value="message"  <?php checked( 'message',  $success_behavior_value ); ?> /> <?php esc_html_e( 'Show Text Message', 'flex-forms' ); ?></label>
     384                        </td>
     385                    </tr>
     386                    <tr class="flex-forms-success-redirect-row">
     387                        <th><label for="flex_forms_success_redirect_url"><?php esc_html_e( 'Success Redirect URL', 'flex-forms' ); ?></label></th>
     388                        <td><input type="url" id="flex_forms_success_redirect_url" name="flex_forms_success_redirect_url" class="regular-text" value="<?php echo esc_attr( $success_redirect_url_val ); ?>" /></td>
     389                    </tr>
     390                    <tr class="flex-forms-success-text-row">
     391                        <th><label for="flex_forms_success_text"><?php esc_html_e( 'Success Message', 'flex-forms' ); ?></label></th>
     392                        <td><textarea id="flex_forms_success_text" name="flex_forms_success_text" rows="3" style="width:100%;"><?php echo esc_textarea( $success_text_val ); ?></textarea></td>
     393                    </tr>
     394                </table>
     395
     396                <hr/>
     397
     398                <!-- Error settings -->
     399                <h2><?php esc_html_e( 'Error Settings', 'flex-forms' ); ?></h2>
     400                <table class="form-table">
     401                    <tr>
     402                        <th><?php esc_html_e( 'On Error', 'flex-forms' ); ?></th>
     403                        <td>
     404                            <label><input type="radio" name="flex_forms_error_behavior" value="redirect" <?php checked( 'redirect', $error_behavior_value ); ?> /> <?php esc_html_e( 'Redirect to URL', 'flex-forms' ); ?></label><br/>
     405                            <label><input type="radio" name="flex_forms_error_behavior" value="message"  <?php checked( 'message',  $error_behavior_value ); ?> /> <?php esc_html_e( 'Show Text Message', 'flex-forms' ); ?></label>
     406                        </td>
     407                    </tr>
     408                    <tr class="flex-forms-error-redirect-row">
     409                        <th><label for="flex_forms_error_redirect_url"><?php esc_html_e( 'Error Redirect URL', 'flex-forms' ); ?></label></th>
     410                        <td><input type="url" id="flex_forms_error_redirect_url" name="flex_forms_error_redirect_url" class="regular-text" value="<?php echo esc_attr( $error_redirect_url_val ); ?>" /></td>
     411                    </tr>
     412                    <tr class="flex-forms-error-text-row">
     413                        <th><label for="flex_forms_error_text"><?php esc_html_e( 'Error Message', 'flex-forms' ); ?></label></th>
     414                        <td><textarea id="flex_forms_error_text" name="flex_forms_error_text" rows="3" style="width:100%;"><?php echo esc_textarea( $error_text_val ); ?></textarea></td>
     415                    </tr>
     416                </table>
     417
     418                <hr/>
     419
     420                <!-- NEW: form-level attributes -->
     421                <h2><?php esc_html_e( 'Form Attributes', 'flex-forms' ); ?></h2>
     422                <table class="form-table">
     423                    <tr>
     424                        <th><label for="flex_forms_form_id"><?php esc_html_e( 'Form ID attribute', 'flex-forms' ); ?></label></th>
     425                        <td><input type="text" id="flex_forms_form_id" name="flex_forms_form_id" class="regular-text" value="<?php echo esc_attr( $form_id_attr_val ); ?>" placeholder="<?php esc_attr_e( 'e.g. my-form', 'flex-forms' ); ?>" /></td>
     426                    </tr>
     427                    <tr>
     428                        <th><label for="flex_forms_form_class"><?php esc_html_e( 'Form CSS classes', 'flex-forms' ); ?></label></th>
     429                        <td><input type="text" id="flex_forms_form_class" name="flex_forms_form_class" class="regular-text" value="<?php echo esc_attr( $form_class_val ); ?>" placeholder="<?php esc_attr_e( 'class1 class2', 'flex-forms' ); ?>" /></td>
     430                    </tr>
     431                    <tr>
     432                        <th><label for="flex_forms_form_attrs"><?php esc_html_e( 'Additional attributes', 'flex-forms' ); ?></label></th>
     433                        <td><input type="text" id="flex_forms_form_attrs" name="flex_forms_form_attrs" class="regular-text" value="<?php echo esc_attr( $form_attrs_val ); ?>" placeholder='<?php esc_attr_e( 'data-theme="dark" tabindex="0"', 'flex-forms' ); ?>' /></td>
     434                    </tr>
     435                </table>
     436
     437                <hr/>
     438
     439                <!-- Custom CSS -->
     440                <h2><?php esc_html_e( 'Custom CSS', 'flex-forms' ); ?></h2>
     441                <textarea name="flex_forms_custom_css" rows="4" style="width:100%;"><?php echo esc_textarea( $custom_css_val ); ?></textarea>
     442                <p class="description"><?php esc_html_e( 'This CSS will be injected on the front end for this form only.', 'flex-forms' ); ?></p>
    270443            </form>
    271444        </div>
  • flex-forms/trunk/readme.txt

    r3305607 r3305740  
    11=== Flex Forms ===
    2 Contributors: flexfields
    3 Donate link: https://future-systems.am/
    4 Tags: form, field, shortcode, input, email
    5 Requires at least: 5.0
    6 Tested up to: 6.8
    7 Requires PHP: 7.0
    8 Stable tag: 2.1.0
    9 License: GPLv2 or later
    10 License URI: https://www.gnu.org/licenses/gpl-2.0.html
     2Contributors:       flexfields
     3Donate link:        https://future-systems.am/
     4Tags:               form, field, shortcode, input, email
     5Requires at least:  5.0
     6Tested up to:       6.8
     7Requires PHP:       7.0
     8Stable tag:         2.1.0
     9License:            GPLv2 or later
     10License URI:        https://www.gnu.org/licenses/gpl-2.0.html
    1111
    12 Flex Forms
     12A lightweight yet powerful form builder with database storage, e-mail alerts, reCAPTCHA and deep Flex Fields integration.
    1313
    1414== Description ==
     
    2323* **When data is sent:** When a user submits a form.
    2424* **Where data is sent:** To the configured email recipient(s) via the selected email service.
    25 * **Privacy & Terms:** The email service provider's policies apply if an external service is used (e.g., SendGrid [https://sendgrid.com/policies/tos/], Mailgun [https://www.mailgun.com/legal/]).
     25* **Privacy & Terms:** The email service provider's policies apply if an external service is used (e.g., SendGrid <https://sendgrid.com/policies/tos/>, Mailgun <https://www.mailgun.com/legal/>).
    2626
    2727Additionally, Flex Forms supports Google reCAPTCHA v2 and v3 for spam protection.
     
    3737
    3838* **Privacy & Terms:**
    39   - [Google reCAPTCHA Terms of Service](https://policies.google.com/terms)
    40   - [Google reCAPTCHA Privacy Policy](https://policies.google.com/privacy)
     39  - <https://policies.google.com/terms>
     40  - <https://policies.google.com/privacy>
Note: See TracChangeset for help on using the changeset viewer.