Skip to content
Snippets Groups Projects
Commit 388c069a authored by Orzo Cogorzo's avatar Orzo Cogorzo Committed by Lucas García
Browse files

Namespace renaming

parent 5ecef169
No related branches found
No related tags found
No related merge requests found
......@@ -8,11 +8,11 @@
/* return wpct_forms_ce_option_getter('wpct_forms_ce_general', 'coord_id'); */
/* } */
add_filter('gform_field_value_current_lang', 'wpct_forms_ce_populate_current_lang');
function wpct_forms_ce_populate_current_lang($value)
add_filter('gform_field_value_current_lang', 'wpct_crm_forms_populate_current_lang');
function wpct_crm_forms_populate_current_lang($value)
{
if ($value) {
$locale = wpct_forms_ce_format_current_lang($value);
$locale = wpct_crm_forms_format_current_lang($value);
} else {
$language = apply_filters('wpml_post_language_details', null);
......@@ -26,7 +26,7 @@ function wpct_forms_ce_populate_current_lang($value)
return $locale;
}
function wpct_forms_ce_format_current_lang($code)
function wpct_crm_forms_format_current_lang($code)
{
$languages = apply_filters('wpml_active_languages', null);
if ($languages && !is_wp_error($languages) && isset($languages[$code])) {
......
......@@ -3,28 +3,28 @@
/**
* Define menu page.
*/
add_action('admin_menu', 'wpct_forms_ce_add_admin_menu');
function wpct_forms_ce_add_admin_menu()
add_action('admin_menu', 'wpct_crm_forms_add_admin_menu');
function wpct_crm_forms_add_admin_menu()
{
add_options_page(
'WPCT Forms CE',
'WPCT Forms CE',
'WPCT CRM Forms',
'WPCT CRM Forms',
'manage_options',
'wpct_forms_ce',
'wpct_forms_ce_render'
'wpct_crm_forms',
'wpct_crm_forms_render'
);
}
/**
* Paint the settings page
*/
function wpct_forms_ce_render()
function wpct_crm_forms_render()
{
echo '<div class="wrap">';
echo '<h1>WPCT CE Forms</h1>';
echo '<form action="options.php" method="post">';
settings_fields('wpct_forms_ce');
do_settings_sections('wpct_forms_ce');
settings_fields('wpct_crm_forms');
do_settings_sections('wpct_crm_forms');
submit_button();
echo '</form>';
echo '</div>';
......@@ -33,18 +33,18 @@ function wpct_forms_ce_render()
/**
* Define settings.
*/
add_action('admin_init', 'wpct_forms_ce_init_settings', 50);
function wpct_forms_ce_init_settings()
add_action('admin_init', 'wpct_crm_forms_init_settings', 50);
function wpct_crm_forms_init_settings()
{
register_setting(
'wpct_forms_ce',
'wpct_forms_ce_general',
'wpct_crm_forms',
'wpct_crm_forms_general',
array(
'type' => 'array',
'description' => __('Configuració global dels formularis', 'wpct-forms-ce'),
'description' => __('Configuració global dels formularis', 'wpct-crm-forms'),
'show_in_rest' => false,
'default' => array(
'coord_id' => 0,
'coord_id' => 1,
'notification_receiver' => 'admin@example.com'
)
)
......@@ -52,42 +52,42 @@ function wpct_forms_ce_init_settings()
// Secció general
add_settings_section(
'wpct_forms_ce_general_section',
__('Global', 'wpct-forms-ce'),
'wpct_forms_ce_general_section_render',
'wpct_forms_ce'
'wpct_crm_forms_general_section',
__('Global', 'wpct-crm-forms'),
'wpct_crm_forms_general_section_render',
'wpct_crm_forms'
);
add_settings_field(
'notification_receiver',
__('Error notification receiver', 'wpct-forms-ce'),
fn () => wpct_forms_ce_option_render('notification_receiver'),
'wpct_forms_ce',
'wpct_forms_ce_general_section'
__('Error notification receiver', 'wpct-crm-forms'),
fn () => wpct_crm_forms_option_render('notification_receiver'),
'wpct_crm_forms',
'wpct_crm_forms_general_section'
);
add_settings_field(
'coord_id',
__('ID de la coordinadora', 'wpct-forms-ce'),
fn () => wpct_forms_ce_option_render('coord_id'),
'wpct_forms_ce',
'wpct_forms_ce_general_section'
__('ID de la coordinadora', 'wpct-crm-forms'),
fn () => wpct_crm_forms_option_render('coord_id'),
'wpct_crm_forms',
'wpct_crm_forms_general_section'
);
}
function wpct_forms_ce_option_getter($group, $option)
function wpct_crm_forms_option_getter($group, $option)
{
$options = get_option($group) ? get_option($group) : [];
return key_exists($option, $options) ? $options[$option] : '';
}
function wpct_forms_ce_option_render($option)
function wpct_crm_forms_option_render($option)
{
echo '<input type="text" name="wpct_forms_ce_general[' . $option . ']" value="' . wpct_forms_ce_option_getter('wpct_forms_ce_general', $option) . '">';
echo '<input type="text" name="wpct_crm_forms_general[' . $option . ']" value="' . wpct_crm_forms_option_getter('wpct_crm_forms_general', $option) . '">';
}
/**
* Callbacks for the settings sections
*/
function wpct_forms_ce_general_section_render()
function wpct_crm_forms_general_section_render()
{
echo __('General settings', 'wpct-forms-ce');
echo __('General settings', 'wpct-crm-forms');
}
......@@ -3,7 +3,7 @@
/**
* Gent gform entry and form objects and parse it to a form values array
*/
function wpct_forms_ce_parse_form_entry($entry, $form)
function wpct_crm_forms_parse_form_entry($entry, $form)
{
$form_vals = array(
'entry_id' => $entry['id']
......@@ -48,18 +48,19 @@ function wpct_forms_ce_parse_form_entry($entry, $form)
return $form_vals;
}
function wpct_forms_ce_add_cord_id($form_values)
function wpct_crm_forms_add_cord_id($form_values)
{
if (!isset($form_values['company_id']) || !$form_values['company_id']) {
$form_values['company_id'] = wpct_forms_ce_option_getter('wpct_forms_ce_general', 'coord_id');
$form_values['company_id'] = wpct_crm_forms_option_getter('wpct_crm_forms_general', 'coord_id');
}
return $form_values;
}
/**
* Remove empty fields from form submission
*/
function wpct_forms_ce_cleanup_empties($form_vals)
function wpct_crm_forms_cleanup_empties($form_vals)
{
foreach ($form_vals as $key => $val) {
if (empty($val)) {
......@@ -74,7 +75,7 @@ function wpct_forms_ce_cleanup_empties($form_vals)
/**
* Transform form submission array into a payload data structure
*/
function wpct_forms_ce_get_submission_payload($form_vals)
function wpct_crm_forms_get_submission_payload($form_vals)
{
$payload = array(
'name' => $form_vals['source_xml_id'] . ' submission: ' . $form_vals['entry_id'],
......@@ -103,11 +104,11 @@ function wpct_forms_ce_get_submission_payload($form_vals)
/**
* Pipe form submission transformations to get the submission post payload
*/
function wpct_forms_ce_prepare_submission($form_vals)
function wpct_crm_forms_prepare_submission($form_vals)
{
$form_vals = wpct_forms_ce_add_cord_id($form_vals);
$form_vals = wpct_forms_ce_cleanup_empties($form_vals);
return wpct_forms_ce_get_submission_payload($form_vals);
$form_vals = wpct_crm_forms_add_cord_id($form_vals);
$form_vals = wpct_crm_forms_cleanup_empties($form_vals);
return wpct_crm_forms_get_submission_payload($form_vals);
}
add_filter('wpct_forms_ce_prepare_submission', 'wpct_forms_ce_prepare_submission', 10, 2);
add_filter('wpct_crm_forms_prepare_submission', 'wpct_crm_forms_prepare_submission', 10, 2);
<?php
add_action('gform_after_submission', 'wpct_forms_ce_api_submissions', 10, 2);
function wpct_forms_ce_api_submissions($entry, $form)
add_action('gform_after_submission', 'wpct_crm_forms_api_submissions', 10, 2);
function wpct_crm_forms_api_submissions($entry, $form)
{
$form_vals = wpct_forms_ce_parse_form_entry($entry, $form);
$form_vals = wpct_crm_forms_parse_form_entry($entry, $form);
if (!isset($form_vals['source_xml_id'])) throw new Exception('Error Processing Request', 400);
$submission_payload = apply_filters('wpct_forms_ce_prepare_submission', $form_vals);
$submission_payload = apply_filters('wpct_crm_forms_prepare_submission', $form_vals);
$response = wpct_oc_post_odoo('/api/private/crm-lead', $submission_payload);
if (!$response) {
$to = wpct_forms_ce_option_getter('wpct_forms_ce_general', 'notification_receiver');
$to = wpct_crm_forms_option_getter('wpct_crm_forms_general', 'notification_receiver');
$subject = 'Odoo subscription request submission error: Form(' . $form['id'] . ') Entry (' . $entry['id'] . ')';
$body = 'Submission subscription request for entry: ' . $entry['id'] . ' failed.<br/>Form id: ' . $form['id'] . "<br/>Form title: " . $form['title'];
wp_mail($to, $subject, $body);
......
{
"name": "wpct-forms-ce",
"version": "0.1.0",
"name": "wpct-crm-forms",
"version": "1.0.0",
"main": "Gruntfile.js",
"author": "YOUR NAME HERE",
"scripts" : {
"start" : "grunt default" ,
"readme" : "grunt readme",
"i18n" : "grunt i18n"
"author": "codeccoop",
"scripts": {
"start": "grunt default",
"readme": "grunt readme",
"i18n": "grunt i18n"
},
"devDependencies": {
"grunt": "~0.4.5",
......
......@@ -4,11 +4,11 @@ Tags: forms, odoo, crm
Requires at least: 6.3.1
Tested up to: 6.3.1
Requires PHP: 8.0
Stable tag: 0.1.0
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
GravityForm's submissions to the CRM Lead Odoo module
Form submissions to the CRM Lead Odoo module
== Description ==
......
<?php
/**
* Plugin Name: Wpct Forms CE
* Plugin URI: https://git.coopdevs.org/coopdevs/website/wp/wp-plugins/wpct-forms-ce
* Description: Configuration options for CE forms
* Author: Coopdevs Treball SCCL
* Author URI: https://coopdevs.org
* Text Domain: wpct-forms-ce
* Plugin Name: WPCT CRM Forms
* Plugin URI: https://git.coopdevs.org/coopdevs/website/wp/wp-plugins/wpct-crm-forms
* Description: Plugin to wire gravity forms submissions with Odoo CRM Leads module
* Author: Còdec Cooperativa
* Author URI: https://www.codeccoop.org
* Text Domain: wpct-crm-forms
* Domain Path: /languages
* Version: 0.1.9
*
* @package Wpct_Forms_CE
* @package WPCT_CRM_Forms
*/
/* Options Page */
......@@ -26,6 +26,6 @@ require_once "includes/fields-population.php";
/* Dependencies */
add_filter('wpct_dependencies_check', function ($dependencies) {
$dependencies['Gravity Forms'] = '<a href="https://www.gravityforms.com/">Gravity Forms</a>';
$dependencies['Wpct Odoo Connect'] = '<a href="https://git.coopdevs.org/coopdevs/website/wp/wp-plugins/wpct-odoo-connect">Wpct Odoo Connect</a>';
$dependencies['WPCT Odoo Connect'] = '<a href="https://git.coopdevs.org/coopdevs/website/wp/wp-plugins/wpct-odoo-connect">WPCT Odoo Connect</a>';
return $dependencies;
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment