Skip to content

Commit

Permalink
Trying to resolve contact data input
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan DAHAN committed Oct 31, 2021
1 parent 1395f0c commit 6f205c0
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 52 deletions.
40 changes: 27 additions & 13 deletions ActionSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,34 @@ public function run($record, $ajax_handler)
$fields[$id] = $field['value'];
}

$MJF_data = ['Email' => $fields['email']];
$MJF_contactdata = [ 'Name' => $settings['MJF_name_field'], 'Value' => $fields['name'], 'Name' => $settings['MJF_firstname_field'], 'Value' => $fields['fname'],'Name' => $settings['MJF_phone_field'], 'Value' => $fields['phone'],];
$MJF_data_step2 = ['Email' => $fields['email'], 'Action' => 'addforce', ];

$MJF_data = ['Email' => $fields['email'], 'Name' => $fields['name']];
$MJF_contactdata = [
'Data' => [
[
'Name' => $settings['MJF_name_field'],
'Value' => $fields['name'],
'Name' => $settings['MJF_firstname_field'],
'Value' => $fields['fname'],
'Name' => $settings['MJF_phone_field'],
'Value' => $fields['phone'],
]
]
];
$MJF_data_step2 = ['Email' => $fields['email'], 'Action' => 'addforce'];



$MJF_API = MAILJET_API;
$MJF_SECRET = MAILJET_SECRET;
$MJF_auth = base64_encode($MJF_API . ':' . $MJF_SECRET);
$auth = base64_encode($MJF_API . ':' . $MJF_SECRET);

$MJF_data_args = ['headers' => ['Authorization' => "Basic $auth"], 'body' => $MJF_data, ];
$MJF_contactdata_args = ['method' => 'PUT', 'headers' => ['Authorization' => "Basic $auth"], 'body' => $MJF_contactdata, ];
$MJF_data_step2_args = ['headers' => ['Authorization' => "Basic $auth"], 'body' => $MJF_data_step2, ];

$MJF_data_args = ['headers' => ['Authorization' => "Basic $MJF_auth"], 'body' => $MJF_data, ];
$MJF_contactdata_args = ['headers' => ['Authorization' => "Basic $MJF_auth"], 'body' => $MJF_contactdata, ];
$MJF_data_step2_args = ['headers' => ['Authorization' => "Basic $MJF_auth"], 'body' => $MJF_data_step2, ];

$MJF_responsecontact = wp_remote_post('https://api.mailjet.com/v3/REST/contact', $MJF_data_args);
$MJF_responsecontactdata = wp_remote_post('https://api.mailjet.com/v3/REST/contactdata/' . $fields['email'], $MJF_contactdata_args);
$MJF_responsecontactdata = wp_remote_request('https://api.mailjet.com/v3/REST/contactdata/' . $fields['email'], $MJF_contactdata_args);
$MJF_responsecontactslist = wp_remote_post('https://api.mailjet.com/v3/REST/contactslist/' . $settings['MJF_listID'] . '/managecontact', $MJF_data_step2_args);

}
Expand All @@ -51,13 +65,13 @@ public function register_settings_section($widget)
{
$widget->start_controls_section('section_MJF', ['label' => __('Mailjet', 'text-domain') , 'condition' => ['submit_actions' => $this->get_name() , ], ]);

$widget->add_control('MJF_listID', ['label' => __('Mailjet List ID', 'text-domain') , 'type' => \Elementor\Controls_Manager::TEXT, 'separator' => 'before', 'description' => __('the list id you want to subscribe a user to.', 'text-domain') , ]);
$widget->add_control('MJF_listID', ['label' => __('Mailjet List ID', 'text-domain') , 'type' => \Elementor\Controls_Manager::TEXT, 'separator' => 'before', 'description' => __('Insert the list id you want to subscribe a user to.', 'text-domain') , ]);

$widget->add_control('MJF_firstname_field', ['label' => __('Mailjet FirstName field', 'text-domain') , 'type' => \Elementor\Controls_Manager::TEXT, 'separator' => 'before', 'description' => __('Name your mailjet firstname contact field.', 'text-domain') , ]);
$widget->add_control('MJF_firstname_field', ['label' => __('Mailjet FirstName field', 'text-domain') , 'type' => \Elementor\Controls_Manager::TEXT, 'separator' => 'before', 'description' => __('Set your mailjet firstname contact field.', 'text-domain') , ]);

$widget->add_control('MJF_name_field', ['label' => __('Mailjet LastName field', 'text-domain') , 'type' => \Elementor\Controls_Manager::TEXT, 'separator' => 'before', 'description' => __('Name your mailjet lastname contact field.', 'text-domain') , ]);
$widget->add_control('MJF_name_field', ['label' => __('Mailjet LastName field', 'text-domain') , 'type' => \Elementor\Controls_Manager::TEXT, 'separator' => 'before', 'description' => __('Set your mailjet lastname contact field.', 'text-domain') , ]);

$widget->add_control('MJF_phone_field', ['label' => __('Mailjet Phone field', 'text-domain') , 'type' => \Elementor\Controls_Manager::TEXT, 'separator' => 'before', 'description' => __('Name your mailjet contact phone field.', 'text-domain') , ]);
$widget->add_control('MJF_phone_field', ['label' => __('Mailjet Phone field', 'text-domain') , 'type' => \Elementor\Controls_Manager::TEXT, 'separator' => 'before', 'description' => __('Set your mailjet contact phone field.', 'text-domain') , ]);

$widget->end_controls_section();

Expand Down
Binary file added languages/mj-forms-fr_FR.mo
Binary file not shown.
61 changes: 61 additions & 0 deletions languages/mj-forms-fr_FR.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Copyright (C) 2021 Jonathan DAHAN
# This file is distributed under the same license as the Mj Forms plugin.
msgid ""
msgstr ""
"Project-Id-Version: Mj Forms 1.0.1\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/mj-forms\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2021-10-30T21:38:06+00:00\n"
"PO-Revision-Date: 2021-10-31 00:03+0200\n"
"X-Generator: Poedit 3.0\n"
"X-Domain: mj-forms\n"
"Last-Translator: Jonathan DAHAN <[email protected]>\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
"Language: fr_FR\n"

#. Plugin Name of the plugin
msgid "Mj Forms"
msgstr "Formulaires Mj"

#. Plugin URI of the plugin
msgid "https://github.com/jonathandhn/mj-forms"
msgstr ""

#. Description of the plugin
msgid "Manage your Mailjet subscribers with elementor forms."
msgstr "Gérez vos abonnés Mailjet avec elementor forms."

#. Author of the plugin
msgid "Jonathan DAHAN"
msgstr ""

#. Author URI of the plugin
msgid "https://jonathanphoto.fr"
msgstr ""

#. Elementor setting item for Mailjet Subscribe Action
msgid "Mailjet Subscribe"
msgstr "Mailjet Inscription"

#. Plugin setting of the Mailjet list ID
msgid "Mailjet List ID"
msgstr "Mailjet Liste ID"

#. Plugin setting of the Mailjet list ID description
msgid "Insert the list id you want to subscribe a user to."
msgstr "Insérer l’identifiant de la liste que vous souhaitez utiliser."

#. Plugin setting of the Mailjet firstname field
msgid "Set your mailjet firstname contact field."
msgstr "Configurez votre champs pour le prénom dans Mailjet."

#. Plugin setting of the Mailjet lastname field
msgid "Set your mailjet lastname contact field."
msgstr "Configurez votre champs pour le nom dans Mailjet."

#. Plugin setting of the Mailjet phone field
msgid "Set your mailjet contact phone field."
msgstr "Configurez votre champs pour le téléphone dans Mailjet."
36 changes: 32 additions & 4 deletions languages/mj-forms.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# This file is distributed under the same license as the Mj Forms plugin.
msgid ""
msgstr ""
"Project-Id-Version: Mj Forms 1.0.0\n"
"Project-Id-Version: Mj Forms 1.0.1\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/mj-forms\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2021-10-29T20:34:40+00:00\n"
"POT-Creation-Date: 2021-10-30T21:38:06+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.5.0\n"
"X-Domain: mj-forms\n"
Expand All @@ -19,8 +19,7 @@ msgid "Mj Forms"
msgstr ""

#. Plugin URI of the plugin
#. Author URI of the plugin
msgid "https://jonathanphoto.fr"
msgid "https://github.com/jonathandhn/mj-forms"
msgstr ""

#. Description of the plugin
Expand All @@ -30,3 +29,32 @@ msgstr ""
#. Author of the plugin
msgid "Jonathan DAHAN"
msgstr ""

#. Author URI of the plugin
msgid "https://jonathanphoto.fr"
msgstr ""

#. Elementor setting item for Mailjet Subscribe Action
msgid "Mailjet Subscribe"
msgstr ""

#. Plugin setting of the Mailjet list ID
msgid "Mailjet List ID"
msgstr ""

#. Plugin setting of the Mailjet list ID description
msgid "Insert the list id you want to subscribe a user to."
msgstr ""

#. Plugin setting of the Mailjet firstname field
msgid "Set your mailjet firstname contact field."
msgstr ""

#. Plugin setting of the Mailjet lastname field
msgid "Set your mailjet lastname contact field."
msgstr "
#. Plugin setting of the Mailjet phone field
msgid "Set your mailjet contact phone field."
msgstr "
Binary file removed languages/mj-formsfr_FR.mo
Binary file not shown.
34 changes: 0 additions & 34 deletions languages/mj-formsfr_FR.po

This file was deleted.

3 changes: 2 additions & 1 deletion mjforms.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
*/
/*
Plugin Name: Mj Forms
Plugin URI: https://jonathanphoto.fr
Plugin URI: https://github.com/jonathandhn/mj-forms
Description: Manage your Mailjet subscribers with elementor forms.
Author: Jonathan DAHAN
Version: 1.0.1
Author URI: https://jonathanphoto.fr
Domain Path: /languages
*/
if (!defined('ABSPATH'))
{
Expand Down

0 comments on commit 6f205c0

Please sign in to comment.