Plugin Directory

Changeset 3077542


Ignore:
Timestamp:
04/26/2024 10:50:03 AM (22 months ago)
Author:
pinpointe
Message:

Fix unknown error bug

Location:
pinpointe-form-integration/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pinpointe-form-integration/trunk/assets/js/pinpointe-admin.js

    r3074988 r3077542  
    100100    }
    101101
    102     jQuery('.pinpointe_forms_overide_confirmation').click(function() {
     102    function form_fields_on_change_handler(current_select_id, current_field_id, value, merge_fields, has_chosen_values = false)
     103    {
     104        FormEditorChanged();
     105        regenerate_tag_chosen(current_field_id);
     106
     107        if (has_chosen_values) {
     108            var values = value.split(',');
     109            value = values[values.length - 1];
     110        }
     111
     112        var select_id = current_select_id.replace('pinpointe_field_tag', '');
     113
     114        if (merge_fields[value]) {
     115
     116            jQuery('#pinpointe_forms_fields_type' + select_id).val(merge_fields[value]['type']);
     117            jQuery('#pinpointe_forms_fields_req' + select_id).val(merge_fields[value]['req']);
     118            jQuery('#pinpointe_forms_fields_us_phone' + select_id).val(merge_fields[value]['us_phone']);
     119            jQuery('#pinpointe_forms_fields_choices' + select_id).val(merge_fields[value]['choices']);
     120        }
     121    }
     122
     123    jQuery('.pinpointe_forms_overide_confirmation').click(function () {
    103124        pinpointe_hide_confirmation_email_tr(this);
    104125    });
     
    137158                        if (typeof non_selected_keys[this_key] !== 'undefined') {
    138159                            non_selected_keys[this_key]++;
    139                         }
    140                         else {
     160                        } else {
    141161                            non_selected_keys[this_key] = 1;
    142162                        }
     
    799819                placeholder: pinpointe_label_select_tag ?? "Select a field",
    800820                onChange(value) {
    801                     FormEditorChanged();
    802                     regenerate_tag_chosen(current_field_id);
    803 
    804                     // use this to support old browsers
    805                     // otherwise merge_fields[value]?.['type'] ?? '' for modern browsers
    806                     jQuery('#pinpointe_forms_fields_type' + current_select_id).val(
    807                         merge_fields[value] && merge_fields[value]['type'] || ''
    808                     );
    809                     jQuery('#pinpointe_forms_fields_req' + current_select_id).val(
    810                         merge_fields[value] && merge_fields[value]['req'] || ''
    811                     );
    812                     jQuery('#pinpointe_forms_fields_us_phone' + current_select_id).val(
    813                         merge_fields[value] && merge_fields[value]['us_phone'] || ''
    814                     );
    815                     jQuery('#pinpointe_forms_fields_choices' + current_select_id).val(
    816                         merge_fields[value] && merge_fields[value]['choices'] || ''
    817                     );
     821                    form_fields_on_change_handler(current_select_id, current_field_id, value, merge_fields);
    818822                }
    819823            });
     
    901905                        hidePlaceholder: false,
    902906                    }
    903 
     907                    var current_select = jQuery('#pinpointe_field_tag_' + current_field_id + '_' + current_id);
    904908                    new TomSelect(
    905                         "#" + jQuery('#pinpointe_field_tag_' + current_field_id + '_' + current_id).attr('id'),
     909                        "#" + current_select.attr('id'),
    906910                        {
    907911                            ...tomSelectOptions,
    908                             items: curruent_field_tag_select_value
     912                            items: curruent_field_tag_select_value,
     913                            onChange(value) {
     914                                form_fields_on_change_handler(current_select.prop('id'), current_field_id, value, merge_fields);
     915
     916                            }
    909917                        }
    910918                    );
    911919                   new TomSelect(
    912                         "#" + jQuery('#pinpointe_field_tag_' + current_field_id + '_' + next_id).attr('id'),
    913                         tomSelectOptions
     920                        "#" + cloned_select.prop('id'),
     921                       {
     922                           ...tomSelectOptions,
     923
     924                           onChange(value) {
     925                               form_fields_on_change_handler(cloned_select.prop('id'), next_id, value, merge_fields, true);
     926                           }
     927                       }
    914928                    );
    915929
  • pinpointe-form-integration/trunk/pinpointe-signup-form.php

    r3074988 r3077542  
    11<?php
    2 
    32/**
    43 * Plugin Name: Pinpointe Form Integration
     
    2726}
    2827
     28session_start(); // Start the session first
     29
    2930// Define Constants
    3031define('PINPOINTE_PLUGIN_PATH', untrailingslashit(plugin_dir_path(__FILE__)));
     
    108109
    109110                    // Load scripts/styles conditionally
    110                     $query_string = filter_input(INPUT_SERVER, 'QUERY_STRING', FILTER_SANITIZE_STRING);
     111                    $query_string = htmlspecialchars($_SERVER['QUERY_STRING'], ENT_QUOTES);
    111112                    if (isset($query_string) && preg_match('/page=pinpointe/i', $query_string) && !preg_match('/page=pinpointe_lite/i', $query_string)) {
    112113                        add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts_and_styles'));
     
    155156             */
    156157
    157             // Start session on init hook.
    158             add_action('init',[$this,'init_session']);
    159158
    160159            add_action('widgets_init', function () {
     
    185184            add_action('wp_ajax_nopriv_pinpointe_subscribe', array($this, 'ajax_subscribe'));
    186185
    187         }
    188         function init_session() {
    189             if (!session_id()) {
    190                 session_start();
    191             }
    192186        }
    193187       
     
    579573                                <input type="hidden" name="current_tab" value="<?php echo esc_attr($current_tab); ?>" />
    580574                                <?php wp_nonce_field("ajax_pinpointe_status","pinpointe_status");?>
     575                                <?php wp_nonce_field('ajax_get_lists', 'pinpointe_get_lists');?>
    581576
    582577                                <?php
     
    26702665        public static function select_form_by_conditions($forms, $allowed_forms = array())
    26712666        {
    2672             $selected_form = false;
     2667            $selected_form = [];
    26732668
    26742669            // Iterate over forms and return the first form that matches conditions
     
    26762671
    26772672                // Check if form is enabled and has mailing list set
    2678                 if ($form['condition'] == 'disable' || empty($form['list'])) {
     2673                if ($form['condition'] === 'disable' || empty($form['list'])) {
    26792674                    continue;
    26802675                }
     
    27072702
    27082703                    /**
    2709                      * PAGES
     2704                     * PAGES/POSTS
    27102705                     */
     2706                    case 'posts':
    27112707                    case 'pages':
    27122708                        global $post;
     
    27422738
    27432739                        break;
    2744 
    2745                     /**
    2746                      * POSTS
    2747                      */
    2748                     case 'posts':
    2749                         global $post;
    2750 
    2751                         // Check if we have any pages selected
    2752                         if (!$post || !isset($post->ID) || !array($form['condition']['value']) || empty($form['condition']['value'])) {
    2753                             break;
    2754                         }
    2755 
    2756                         // Check if current post is within selected posts
    2757                         if (in_array($post->ID, $form['condition']['value'])) {
    2758                             $selected_form[$form_key] = $form;
    2759                         }
    2760 
    2761                         break;
    2762 
     2740                       
    27632741                    /**
    27642742                     * POSTS NOT
     
    28492827                            if (in_array($single_cat_id, $post_category_ids)) {
    28502828                                $found = true;
     2829                                break;
    28512830                            }
    28522831                        }
     
    28622841                     */
    28632842                    case 'url':
    2864                         $request_url = sanitize_url(($_SERVER['HTTPS'] ? 'https' : 'http') . '://' .$_SERVER[HTTP_HOST] . $_SERVER[REQUEST_URI]);
     2843                        $request_url = sanitize_url(($_SERVER['HTTPS'] ? 'https' : 'http') . '://' .$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    28652844
    28662845                        if (preg_match('/' . preg_quote($form['condition']['value']) . '/i', $request_url)) {
     
    28742853                     */
    28752854                    case 'url_not':
    2876                         $request_url = sanitize_url(($_SERVER['HTTPS'] ? 'https' : 'http') . '://' . $_SERVER[HTTP_HOST] . $_SERVER[REQUEST_URI]);
     2855                        $request_url = sanitize_url(($_SERVER['HTTPS'] ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
    28772856
    28782857                        if (!preg_match('/' . preg_quote($form['condition']['value']) . '/i', $request_url)) {
     
    28902869
    28912870                // Check if we have selected this form
    2892                 if ($selected_form) {
     2871                if (!empty($selected_form)) {
    28932872                    break;
    28942873                }
     
    42964275            <?php
    42974276
    4298             echo wp_kses_post($form_html);
     4277            // Output the sanitized form HTML
     4278            echo $form_html;
    42994279        }
    43004280
Note: See TracChangeset for help on using the changeset viewer.