Plugin Directory

Changeset 3347505


Ignore:
Timestamp:
08/20/2025 11:52:54 AM (7 months ago)
Author:
fromdoppler
Message:

update plugin version 2.5.0

Location:
doppler-form
Files:
194 added
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • doppler-form/trunk/admin/doppler-admin.php

    r3313204 r3347505  
    4242        $this->error_message = false;
    4343        $this->form_controller = new DPLR_Form_Controller($doppler_service);
    44         $this->extension_manager = new Doppler_Extension_Manager();
     44        $this->extension_manager = new Doppler_Extension_Manager($doppler_service);
    4545        $this->connection_status = false;
    4646    }
     
    185185
    186186        $data = $this->get_Chart_Data();
    187 
    188187        wp_localize_script($this->plugin_name, 'chartData', ['data' => $data]);
     188    }
     189
     190    public function enqueDopplerFieldsForElementor() {
     191        $fields = $this->doppler_service->getResource('fields')->getAllFields();
     192
     193        if (
     194            empty($fields) ||
     195            !is_object($fields) ||
     196            !property_exists($fields, 'items') ||
     197            !is_array($fields->items)
     198        ) {
     199            return;
     200        }
     201       
     202        wp_localize_script('doppler-elementor', 'dopplerFields', $this->map_fields_for_elementor($fields));
     203    }
     204
     205    private function map_fields_for_elementor($fields) {
     206        $type_map = [
     207            'string'     => 'text',
     208            'email'      => 'email',
     209            'phone'      => 'tel',
     210            'boolean'    => 'acceptance',
     211            'number'     => 'number',
     212            'date'       => 'date',
     213            'permission' => 'acceptance',
     214        ];
     215        $excluded_fields = ['GENDER', 'COUNTRY'];
     216
     217        // Filter out excluded_fieldsor or read-only fields (Except for EMAIL).
     218        $filtered_fields = array_values(array_filter($fields->items, function ($field) use ($excluded_fields) {
     219            return !in_array($field->name, $excluded_fields)
     220                && (!property_exists($field, 'readonly') || $field->readonly != 1 || $field->name === 'EMAIL');
     221        }));
     222
     223        //Map fields to the format required by Elementor.
     224        $mapped = array_map(function($field) use ($type_map) {
     225            return [
     226                'remote_label'    => $field->name,
     227                'remote_type'     => $type_map[$field->type] ?? 'text',
     228                'doppler_type'    => $field->type,
     229                'remote_id'       => $field->fieldId,
     230                'remote_required' => (bool) $field->required,
     231            ];
     232        }, $filtered_fields);
     233
     234        // Sort fields by priority. Basic Fields should be shown first.
     235        $priority = ['EMAIL', 'FIRSTNAME', 'LASTNAME', 'BIRTHDAY'];
     236
     237        $prioritized = [];
     238        $others = [];
     239
     240        foreach ($mapped as $item) {
     241            $fieldName = $item['remote_label'];
     242            if (in_array($fieldName, $priority)) {
     243                $prioritized[$fieldName] = $item;
     244            } else {
     245                $others[] = $item;
     246            }
     247        }
     248
     249        // Order priority fields.
     250        $ordered_prioritized = [];
     251        foreach ($priority as $key) {
     252            if (isset($prioritized[$key])) {
     253                $ordered_prioritized[] = $prioritized[$key];
     254            }
     255        }
     256
     257        return array_merge($ordered_prioritized, $others);
    189258    }
    190259
     
    293362
    294363        try{
    295                 //Credentials are saved. Check against API only in connection screen.
    296                 if($this->doppler_service->setCredentials(['api_key' => $options['dplr_option_apikey'], 'user_account' => $options['dplr_option_useraccount']])){
    297                     //neccesary check against api here?
    298                     $connection_status = $this->doppler_service->connectionStatus();
    299 
    300                     if( is_array($connection_status) && $connection_status['response']['code'] === 200 ){
    301                         $connected = true;
    302 
    303                         $forms = $this->form_controller->getAll(true, true);
    304                     }
     364                $connection_status = $this->doppler_service->connectionStatus();
     365
     366                if( is_array($connection_status) && $connection_status['response']['code'] === 200 ){
     367                    $connected = true;
     368
     369                    $forms = $this->form_controller->getAll(true, true);
    305370                }
     371               
    306372                //If saved credentials don't pass API test, unset them, disconnect and show error.
    307373                if ($connected !== true) {
  • doppler-form/trunk/admin/partials/api-connection.php

    r3301444 r3347505  
    334334                                    <?php else:
    335335                                        if(!$this->extension_manager->has_latest_plugin_version('doppler-for-woocommerce')): ?>
    336                                             <button type="button" class="dp-button button-big primary-green button-small dp-install m-t-12 col-sm-12 button--loading"
     336                                            <button type="button" class="dp-button button-big primary-green button-small dp-install m-t-12 col-sm-12"
    337337                                                    data-extension="doppler-for-woocommerce" data-click-action=<?php _e('Updating', 'doppler-form') ?>>
    338338                                                <?php _e('Update Version', 'doppler-form') ?>
  • doppler-form/trunk/doppler-form.php

    r3331435 r3347505  
    1616 * Plugin Name:       Doppler Forms
    1717 * Description:       Crea Formularios de Suscripción con la misma estética de tu sitio web o blog en minutos. Conéctalo con Doppler y envía a tus nuevos contactos automáticamente a una Lista de Suscriptores.
    18  * Version:           2.4.8
     18 * Version:           2.5.0
    1919 * Author:            Doppler LLC
    2020 * Author URI:        https://www.fromdoppler.com/
     
    3030}
    3131
    32 if( !defined('DOPPLER_FORM_VERSION') ) define( 'DOPPLER_FORM_VERSION', '2.4.8' );
     32if( !defined('DOPPLER_FORM_VERSION') ) define( 'DOPPLER_FORM_VERSION', '2.5.0' );
    3333if( !defined('WP_DEBUG_LOG_DOPPLER_PLUGINS') ) define( 'WP_DEBUG_LOG_DOPPLER_PLUGINS', false );
    3434
     
    7373require plugin_dir_path( __FILE__ ) . 'includes/class-doppler-form.php';
    7474
     75//This action has to be added to the main plugin file to ensure that the Elementor integration script is loaded correctly.
     76add_action('elementor/editor/after_enqueue_scripts', function() {
     77    wp_enqueue_script(
     78        'doppler-elementor',
     79        plugin_dir_url(__FILE__) . 'admin/js/doppler-elementor.js',
     80        array('jquery'),
     81        '1.0.0',
     82        true
     83    );
     84});
    7585/**
    7686 * Begins execution of the plugin.
  • doppler-form/trunk/includes/class-doppler-extension-manager.php

    r3261515 r3347505  
    22
    33class Doppler_Extension_Manager {
     4
     5    private $doppler_service;
     6
     7    public function __construct(  $doppler_service ) {
     8        $this->doppler_service = $doppler_service;
     9    }
    410
    511    public $extensions = array(
     
    143149        }
    144150    }
     151
     152    public function add_elementor_action( $form_actions_registrar ) {
     153        include_once( __DIR__ .  '/class-doppler-elementor-integration.php' );
     154        $form_actions_registrar->register( new Doppler_Elementor_Integration($this->doppler_service) );
     155    }
    145156}
  • doppler-form/trunk/includes/class-doppler-form-loader.php

    r2155762 r3347505  
    8282    }
    8383
     84    public function add_elementor_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
     85        add_action('elementor/init', function() use ($hook, $component, $callback, $priority, $accepted_args) {
     86            add_action($hook, array($component, $callback), $priority, $accepted_args);
     87        });
     88    }
     89
    8490    /**
    8591     * A utility function that is used to register the actions and hooks into a single
  • doppler-form/trunk/includes/class-doppler-form.php

    r3222869 r3347505  
    8282            ]);
    8383
     84        if (
     85            !empty($options['dplr_option_apikey']) &&
     86            !empty($options['dplr_option_useraccount'])
     87        ) {
     88            $this->doppler_service->setCredentials([
     89                'api_key' => $options['dplr_option_apikey'],
     90                'user_account' => $options['dplr_option_useraccount']
     91            ]);
     92        }
     93
    8494        $this->load_shortcodes();
    8595        $this->load_dependencies();
     
    175185       
    176186        $plugin_admin = new Doppler_Admin( $this->get_plugin_name(), $this->get_version(), $this->doppler_service);
    177         $extension_manager = new Doppler_Extension_Manager();
    178 
     187        $extension_manager = new Doppler_Extension_Manager($this->doppler_service);
     188       
    179189        $this->loader->add_action( 'admin_enqueue_scripts',     $plugin_admin, 'enqueue_styles' );
    180190        $this->loader->add_action( 'admin_enqueue_scripts',     $plugin_admin, 'enqueue_scripts' );
     
    191201        $this->loader->add_action( 'wp_ajax_dplr_delete_list',  $plugin_admin, 'ajax_delete_list' );
    192202        $this->loader->add_action( 'wp_ajax_install_extension', $extension_manager, 'install_extension' );
    193 
     203        $this->loader->add_elementor_action( 'elementor_pro/forms/actions/register', $extension_manager, 'add_elementor_action' );
     204        $this->loader->add_action( 'elementor/editor/after_enqueue_scripts', $plugin_admin, 'enqueDopplerFieldsForElementor' );
    194205    }
    195206
  • doppler-form/trunk/readme.txt

    r3331435 r3347505  
    66Tested up to: 6.8.1
    77Requires PHP: 5.6.4
    8 Stable tag: 2.4.8
     8Stable tag: 2.5.0
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    8989
    9090== Changelog ==
    91 
    92 = 2.4.7 =
     91= 2.5.0 =
     92* Feat: Add integration with Elementor Pro forms.
     93
     94= 2.4.8 =
    9395* Fix: validate content when on code editor for double optin forms.
    9496* Fix: remove default escape slashing for doble optin content.
Note: See TracChangeset for help on using the changeset viewer.