array('type' => true, 'name' => true, 'value' => true, 'class' => true, 'placeholder' => true, 'min' => true, 'max' => true, 'required' => true, 'id' => true, 'data-id' => true), 'textarea' => array('name' => true, 'value' => true, 'class' => true, 'placeholder' => true, 'required' => true, 'readonly' => true, 'data-id' => true), 'select' => array('name' => true, 'value' => true, 'class' => true, 'required' => true, 'data-id' => true), 'option' => array('value' => true), 'button' => array('type' => true, 'class' => true, 'id' => true, 'data-settings' => true, 'data-id' => true), 'label' => array('for' => true), 'div' => array('class' => true, 'data-settings' => true, 'data-id' => true), 'span' => array('class' => true), 'b' => array(), 'i' => array(), ); public function showCreateTabContent( $id = 0, $task = array(), $showSettings = false ) { $assets = WaicAssets::_(); $frame = WaicFrame::_(); $assets->loadSlider(); $assets->loadChosenSelects(); $assets->loadCodemirror(); $module = $this->getModule(); $path = $this->getModule()->getModPath() . 'assets/'; $frame->addScript('waic-forms-admin', $path . 'js/admin.forms.js'); $assets->loadDataTables(array('responsive')); $options = $frame->getModule('options')->getModel(); $model = $module->getModel(); $isNew = empty($id); if (empty($task)) { $task = WaicFrame::_()->getModule('workspace')->getModel('tasks')->getTask($id); } $settings = empty($task) ? array() : $task['params']; $apiOptions = WaicUtils::getArrayValue($settings, 'api', array(), 2); if (empty($apiOptions)) { $apiOptions = $options->get('api'); } $lang = array( 'add-btn' => esc_html__('Add', 'ai-copilot-content-generator'), 'cancel-btn' => esc_html__('Cancel', 'ai-copilot-content-generator'), 'close-btn' => esc_html__('Close', 'ai-copilot-content-generator'), ); $this->assign('lang', $lang); $this->assign('tabs', $module->getFormsTabsList()); $this->assign('options', array('api' => $apiOptions)); $this->assign('variations', $options->getVariations()); $this->assign('defaults', $options->getDefaults()); $this->assign('admin_email', get_option('admin_email')); $this->assign('presets', $module->getFormsPresetsList()); $this->assign('task_id', $id); $this->assign('settings', $settings); $this->assign('tpl_path', WAIC_MODULES_DIR . 'workspace/views/tpl/'); $this->assign('fields_list', $model->getFields()); $this->assign('if_operators', $this->getModel()->getIfOperators()); $this->assign('then_actions', $this->getModel()->getThenActions()); $this->assign('task_title', WaicUtils::getArrayValue($task, 'title')); return parent::getContent('adminForm'); } public function renderFormHtml( $params, $taskId = 0, $log = false ) { $taskId = (int) $taskId; $module = $this->getModule(); $assets = WaicAssets::_(); $frame = WaicFrame::_(); $path = $module->getModPath() . 'assets/'; $taskModel = WaicFrame::_()->getModule('workspace')->getModel('tasks'); $task = $taskModel->getTask($taskId); if (!$task || !$taskModel->isPublished($task['status'])) { return ''; } $params = WaicUtils::getArrayValue($task, 'params', array(), 2); $general = WaicUtils::getArrayValue($params, 'general', array(), 2); $assets->loadCoreJs(true, true); //$assets->loadFontAwesome(); $frame->addScript('waic-forms-front', $path . 'js/front.forms.js'); $presets = $module->getFormsPresetsList(); $appearance = WaicUtils::getArrayValue($params, 'appearance', array(), 2); $preset = WaicUtils::getArrayValue($appearance, 'preset', 'default', 0, array_keys($presets)); $frame->addStyle('waic-forms-front', $path . 'css/front.forms.' . $preset . '.css'); $viewId = $taskId . '-' . wp_rand(0, 999999); $this->assign('view_id', $viewId); $this->assign('task_id', $taskId); $this->assign('preset', $preset); $this->assign('custom_css', WaicUtils::getArrayValue($appearance, 'custom_css')); $this->assign('title', WaicUtils::getArrayValue($general, 'title')); $this->assign('description', WaicUtils::getArrayValue($general, 'description')); $this->assign('fields', WaicUtils::getArrayValue($params, 'fields', array(), 2)); $this->assign('resets', WaicUtils::getArrayValue($params, 'resets', array(), 2)); $this->assign('submits', WaicUtils::getArrayValue($params, 'submits', array(), 2)); $this->assign('outputs', WaicUtils::getArrayValue($params, 'outputs', array(), 2)); $this->assign('rules', WaicUtils::getArrayValue($params, 'rules', array(), 2)); return parent::getContent('frontForm'); } public function renderFormOutputHtml( $id, $data ) { $settings = array(); $display = WaicUtils::getArrayValue($data, 'display'); if ('custom' == $display) { $selector = WaicUtils::getArrayValue($data, 'selector'); if (empty($selector)) { return; } $settings['selector'] = $selector; } $settings['replace'] = WaicUtils::getArrayValue($data, 'repeat') == 'replace' ? 1 : 0; $settings['hide'] = WaicUtils::getArrayValue($data, 'hide', 0, 1) ? 1 : 0; $loader = WaicUtils::getArrayValue($data, 'loader'); $initial = WaicUtils::getArrayValue($data, 'initial'); $title = WaicUtils::getArrayValue($data, 'title'); if (!empty($title)) { $title = '