Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/build
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ cd "$PLUGIN_DIR" && pnpm pda

cp -r "$PLUGIN_DIR/assets" "$BUILD_DIR/assets"
cp -r "$PLUGIN_DIR/bitwpfi.php" "$BUILD_DIR/bitwpfi.php"
cp -r "$PLUGIN_DIR/build-hash.txt" "$BUILD_DIR/build-hash.txt"
cp -r "$PLUGIN_DIR/composer.json" "$BUILD_DIR/composer.json"
cp -r "$PLUGIN_DIR/backend" "$BUILD_DIR/backend"
cp -r "$PLUGIN_DIR/languages" "$BUILD_DIR/languages"
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/plugin-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ jobs:

- name: Build plugin
run: |
pnpm build
bash .github/copy-assets
bash .github/build

- name: WordPress Plugin Check
uses: wordpress/plugin-check-action@v1
Expand All @@ -86,7 +85,6 @@ jobs:
checks: |
i18n_usage
late_escaping
plugin_header
plugin_readme
file_type
performant_wp_query_params
Expand Down
50 changes: 50 additions & 0 deletions backend/Actions/CreatorLms/CreatorLmsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

/**
* Creator LMS Integration
*/

namespace BitApps\Integrations\Actions\CreatorLms;

use WP_Error;

/**
* Provide functionality for Creator LMS integration
*/
class CreatorLmsController
{
public static function isExists()
{
if (!class_exists('CreatorLms') || !\function_exists('crlms_get_course')) {
wp_send_json_error(
__(
'Creator LMS is not activated or not installed',
'bit-integrations'
),
400
);
}
}

public static function creatorLmsAuthorize()
{
self::isExists();
wp_send_json_success(true);
}

public function execute($integrationData, $fieldValues)
{
$integrationDetails = $integrationData->flow_details;
$integId = $integrationData->id;
$fieldMap = $integrationDetails->field_map;
$utilities = isset($integrationDetails->utilities) ? $integrationDetails->utilities : [];

if (empty($fieldMap)) {
return new WP_Error('field_map_empty', __('Field map is empty', 'bit-integrations'));
}

$recordApiHelper = new RecordApiHelper($integrationDetails, $integId);

return $recordApiHelper->execute($fieldValues, $fieldMap, $utilities);
}
}
106 changes: 106 additions & 0 deletions backend/Actions/CreatorLms/RecordApiHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?php

/**
* Creator LMS Record Api
*/

namespace BitApps\Integrations\Actions\CreatorLms;

use BitApps\Integrations\Config;
use BitApps\Integrations\Core\Util\Common;
use BitApps\Integrations\Core\Util\Hooks;
use BitApps\Integrations\Log\LogHandler;

/**
* Provide functionality for Record insert, update
*/
class RecordApiHelper
{
private $_integrationID;

private $_integrationDetails;

public function __construct($integrationDetails, $integId)
{
$this->_integrationDetails = $integrationDetails;
$this->_integrationID = $integId;
}

public function execute($fieldValues, $fieldMap, $utilities)
{
if (!class_exists('CreatorLms') || !\function_exists('crlms_get_course')) {
return [
'success' => false,
'message' => __('Creator LMS is not installed or activated', 'bit-integrations')
];
}

$fieldData = $this->generateReqDataFromFieldMap($fieldMap, $fieldValues);
$mainAction = $this->_integrationDetails->mainAction ?? 'create_student';

$defaultResponse = [
'success' => false,
// translators: %s is replaced with the plugin name "Bit Integrations Pro"
'message' => wp_sprintf(__('%s plugin is not installed or activated', 'bit-integrations'), 'Bit Integrations Pro')
];

switch ($mainAction) {
case 'create_student':
$response = Hooks::apply(Config::withPrefix('creator_lms_create_student'), $defaultResponse, $fieldData);
$type = 'student';
$actionType = 'create_student';

break;
case 'update_student_data':
$response = Hooks::apply(Config::withPrefix('creator_lms_update_student_data'), $defaultResponse, $fieldData);
$type = 'student';
$actionType = 'update_student_data';

break;
case 'enroll_user_in_course':
$response = Hooks::apply(Config::withPrefix('creator_lms_enroll_user_in_course'), $defaultResponse, $fieldData);
$type = 'enrollment';
$actionType = 'enroll_user_in_course';

break;
case 'create_course':
$response = Hooks::apply(Config::withPrefix('creator_lms_create_course'), $defaultResponse, $fieldData, $this->_integrationDetails);
$type = 'course';
$actionType = 'create_course';

break;
case 'mark_lesson_completed':
$response = Hooks::apply(Config::withPrefix('creator_lms_mark_lesson_completed'), $defaultResponse, $fieldData);
$type = 'lesson';
$actionType = 'mark_lesson_completed';

break;
default:
$response = ['success' => false, 'message' => __('Invalid action', 'bit-integrations')];
$type = 'CreatorLms';
$actionType = 'unknown';

break;
}

$responseType = isset($response['success']) && $response['success'] ? 'success' : 'error';
LogHandler::save($this->_integrationID, ['type' => $type, 'type_name' => $actionType], $responseType, $response);

return $response;
}

private function generateReqDataFromFieldMap($fieldMap, $fieldValues)
{
$dataFinal = [];
foreach ($fieldMap as $item) {
$triggerValue = $item->formField;
$actionValue = $item->creatorLmsField;

$dataFinal[$actionValue] = $triggerValue === 'custom' && isset($item->customValue)
? Common::replaceFieldWithValue($item->customValue, $fieldValues)
: $fieldValues[$triggerValue] ?? '';
}

return $dataFinal;
}
}
10 changes: 10 additions & 0 deletions backend/Actions/CreatorLms/Routes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

if (!defined('ABSPATH')) {
exit;
}

use BitApps\Integrations\Actions\CreatorLms\CreatorLmsController;
use BitApps\Integrations\Core\Util\Route;

Route::post('creator_lms_authorize', [CreatorLmsController::class, 'creatorLmsAuthorize']);
13 changes: 6 additions & 7 deletions backend/Actions/Keap/RecordApiHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function insertTag($contactId, $tags)
$header['Content-Type'] = 'application/json';
$insertTagEndpoint = 'https://api.infusionsoft.com/crm/rest/v1/contacts/' . $contactId . '/tags';

return $response = HttpHelper::post($insertTagEndpoint, wp_json_encode($data), $header);
return HttpHelper::post($insertTagEndpoint, wp_json_encode($data), $header);
}

public function generateReqDataFromFieldMap($data, $fieldMap)
Expand Down Expand Up @@ -136,18 +136,17 @@ public function generateReqDataFromFieldMap($data, $fieldMap)

public function execute($defaultConf, $fieldValues, $fieldMap, $actions)
{
$fieldData = [];
$finalData = $this->generateReqDataFromFieldMap($fieldValues, $fieldMap);
$apiResponse = $this->insertCard($finalData);

$responseType = $apiResponse->id ? 'success' : 'error';
LogHandler::save($this->_integrationID, ['type' => 'contact', 'type_name' => 'add-contact'], $responseType, $apiResponse);

if ($defaultConf->actions->tags || isset($apiResponse->id)) {
$tagResponse = $this->insertTag($apiResponse->id, $defaultConf->selectedTags);
}
$reponseType = HttpHelper::$responseCode === 200 ? 'success' : 'error';
Comment on lines 145 to +147

if (!(isset($apiResponse->id))) {
LogHandler::save($this->_integrationID, ['type' => 'contact', 'type_name' => 'add-contact'], 'error', $apiResponse);
} else {
LogHandler::save($this->_integrationID, ['type' => 'record', 'type_name' => 'add-contact'], 'success', $apiResponse);
LogHandler::save($this->_integrationID, ['type' => 'record', 'type_name' => 'add-tags'], $reponseType, $tagResponse);
Comment on lines +147 to +149
Comment on lines 145 to +149
Comment on lines +147 to +149
}

return $apiResponse;
Expand Down
1 change: 1 addition & 0 deletions backend/Core/Util/AllTriggersName.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public static function allTriggersName()
'FF' => ['name' => 'Fluent Forms', 'isPro' => true, 'is_active' => false],
'FluentBoards' => ['name' => 'Fluent Boards', 'isPro' => true, 'is_active' => false],
'FluentBooking' => ['name' => 'Fluent Booking', 'isPro' => true, 'is_active' => false],
'CreatorLms' => ['name' => 'Creator LMS', 'isPro' => true, 'is_active' => false],
'FluentCart' => ['name' => 'FluentCart', 'isPro' => true, 'is_active' => false],
'FluentCrm' => ['name' => 'Fluent CRM', 'isPro' => true, 'is_active' => false],
'FluentCommunity' => ['name' => 'Fluent Community', 'isPro' => true, 'is_active' => false],
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/Utils/StaticData/tutorialLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,10 @@ const tutorialLinks = {
'https://youtube.com/playlist?list=PL7c6CDwwm-AL0ckxqJPUdiG0syI65HXg2&si=JkJ_0Q0iOA24_wtl',
docLink: 'https://bit-integrations.com/wp-docs/actions/academy-lms-integrations-as-an-action/'
},
creatorLms: {
youTubeLink: '',
docLink: 'https://bit-integrations.com/wp-docs/actions/creator-lms-integrations/'
},
woodpecker: {
youTubeLink:
'https://youtube.com/playlist?list=PL7c6CDwwm-AL0mmQk0yX6u-HnqDzJeXDu&si=MdiwtkYVb0kBIjPD',
Expand Down
1 change: 1 addition & 0 deletions frontend/src/Utils/StaticData/webhookIntegrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export const customFormIntegrations = [
'FormGent',
'GeoDirectory',
'StoreEngine',
'CreatorLms',
'FluentCart',
'MailMint',
'BookingCalendarContactForm',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default function Autonami({ formFields, setFlow, flow, allIntegURL }) {
style={{
width: step === 2 && 900,
height: step === 2 && 'auto',
minHeight: step === 2 && `${200}px`
minHeight: step === 2 && `${500}px`
}}>
<AutonamiIntegLayout
formID={formID}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
checkAddressFieldMapRequired,
handleInput,
setGrantTokenResponse,
checkMappedFields
checkMappedFields,
generateMappedField
} from './ConstantContactCommonFunc'
import ConstantContactIntegLayout from './ConstantContactIntegLayout'

Expand Down Expand Up @@ -86,7 +87,7 @@ function ConstantContact({ formFields, setFlow, flow, allIntegURL }) {
source_type: '',
tag_ids: '',
tags: [],
field_map: [{ formField: '', constantContactFormField: '' }],
field_map: generateMappedField(constantContactFields),
address_type: '',
address_field: [],
phone_type: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,10 +274,11 @@ export const checkMappedFields = sheetconf => {
return true
}

export const generateMappedField = constantContactConf => {
const requiredFlds = constantContactConf?.default?.constantContactFields.filter(
export const generateMappedField = constantContactFields => {
const requiredFlds = constantContactFields?.filter(
fld => fld.required === true
)

return requiredFlds.length > 0
? requiredFlds.map(field => ({
formField: '',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { useRecoilValue } from 'recoil'
import { $appConfigState } from '../../../GlobalStates'
import { __, sprintf } from '../../../Utils/i18nwrap'
import MtInput from '../../Utilities/MtInput'
import { SmartTagField } from '../../../Utils/StaticData/SmartTagField'
import TagifyInput from '../../Utilities/TagifyInput'
import {
addFieldMap,
delFieldMap,
handleFieldMapping
} from '../IntegrationHelpers/ConstantContactIntegrationHelpers'
import { SmartTagField } from '../../../Utils/StaticData/SmartTagField'
import { $appConfigState } from '../../../GlobalStates'
import { generateMappedField } from './ConstantContactCommonFunc'
import TagifyInput from '../../Utilities/TagifyInput'
import { handleCustomValue } from '../IntegrationHelpers/IntegrationHelpers'

export default function ConstantContactFieldMap({
Expand All @@ -19,17 +17,11 @@ export default function ConstantContactFieldMap({
constantContactConf,
setConstantContactConf
}) {
if (constantContactConf?.field_map?.length === 1 && field.constantContactFormField === '') {
const newConf = { ...constantContactConf }
const tmp = generateMappedField(newConf)
newConf.field_map = tmp
setConstantContactConf(newConf)
}

const requiredFlds =
constantContactConf?.default?.constantContactFields.filter(fld => fld.required === true) || []
const nonRequiredFlds =
constantContactConf?.default?.constantContactFields.filter(fld => fld.required === false) || []

const btcbi = useRecoilValue($appConfigState)
const { isPro } = btcbi

Expand Down
Loading
Loading