'; } function acym_checkToken() { $token = acym_getVar('cmd', '_wpnonce'); if (!wp_verify_nonce($token, 'acymnonce')) { die('Invalid Token'); } } function acym_getFormToken() { $token = acym_getVar('cmd', '_wpnonce', ''); if (empty($token)) { $token = wp_create_nonce('acymnonce'); acym_setVar('_wpnonce', $token); } return '_wpnonce='.$token; } function acym_noTemplate(): string { return 'noheader=1'; } function acym_isNoTemplate(): bool { return acym_getVar('cmd', 'noheader') == '1'; } function acym_setNoTemplate(bool $status = true) { if ($status) { acym_setVar('noheader', '1'); } else { unset($_REQUEST['noheader']); } } function acym_formOptions(bool $token = true, string $task = '', string $currentStep = '', string $currentCtrl = '', bool $addPage = true) { if (!empty($currentStep)) { echo ''; } echo ''; echo ''; if ($addPage) { echo ''; } echo ''; if ($token) { echo acym_formToken(); } echo ''; } global $acymMetaData; function acym_addMetadata($meta, $data, $name = 'name') { global $acymMetaData; $tag = new stdClass(); $tag->meta = $meta; $tag->data = $data; $tag->name = $name; $acymMetaData[] = $tag; } add_action('wp_head', 'acym_head_wp'); add_action('admin_head', 'acym_head_wp'); add_action('acym_head', 'acym_head_wp'); function acym_head_wp() { global $acymMetaData; if (!empty($acymMetaData)) { foreach ($acymMetaData as $metadata) { if (empty($metadata->data)) { echo 'name.'="'.acym_escape($metadata->meta).'"/>'; } else { echo 'name.'="'.acym_escape($metadata->meta).'" content="'.acym_escape($metadata->data).'"/>'; } } } $acymMetaData = []; } function acym_includeHeaders() { do_action('acym_head'); } function acym_getOptionRegacyPosition() { } function acym_renderForm(AcymParameter $params, $args = []) { acym_initModule($params); $return = !empty($args['before_widget']) ? $args['before_widget'] : ''; $title = apply_filters('widget_title', $params->get('title')); if (!empty($title)) { if (!empty($args['before_title'])) $return .= $args['before_title']; $return .= $title; if (!empty($args['after_title'])) $return .= $args['after_title']; } $identifiedUser = null; $currentUserEmail = acym_currentUserEmail(); $userClass = new UserClass(); if ($params->get('userinfo', '1') == '1' && !empty($currentUserEmail)) { $identifiedUser = $userClass->getOneByEmail($currentUserEmail); } $visibleLists = $params->get('displists', []); $hiddenLists = $params->get('hiddenlists', []); $allFields = $params->get('fields', []); acym_arrayToInteger($visibleLists); acym_arrayToInteger($hiddenLists); acym_arrayToInteger($allFields); if (!in_array(2, $allFields)) { $allFields[] = 2; } $listClass = new ListClass(); $fieldClass = new FieldClass(); $allLists = $listClass->getAllWithoutManagement(true); $visibleLists = array_intersect($visibleLists, array_keys($allLists)); $hiddenLists = array_intersect($hiddenLists, array_keys($allLists)); $allFields = $fieldClass->getFieldsByID($allFields); $fields = []; foreach ($allFields as $field) { if (intval($field->active) === 0) continue; $fields[$field->id] = $field; } if (empty($visibleLists) && empty($hiddenLists)) { $hiddenLists = array_keys($allLists); } if (!empty($visibleLists) && !empty($hiddenLists)) { $visibleLists = array_diff($visibleLists, $hiddenLists); } if (empty($identifiedUser->id)) { $checkedLists = $params->get('listschecked', []); if (!is_array($checkedLists)) { if (strtolower($checkedLists) == 'all') { $checkedLists = $visibleLists; } elseif (strpos($checkedLists, ',') || is_numeric($checkedLists)) { $checkedLists = explode(',', $checkedLists); } else { $checkedLists = []; } } } else { $checkedLists = []; $userLists = $userClass->getUserSubscriptionById($identifiedUser->id); $countSub = 0; $countUnsub = 0; $formLists = array_merge($visibleLists, $hiddenLists); foreach ($formLists as $idOneList) { if (empty($userLists[$idOneList]) || $userLists[$idOneList]->status == 0) { $countSub++; } else { $countUnsub++; $checkedLists[] = $idOneList; } } } acym_arrayToInteger($checkedLists); $config = acym_config(); $subscribeText = $params->get('subtext', 'ACYM_SUBSCRIBE'); if (!empty($identifiedUser->id)) $subscribeText = $params->get('subtextlogged', 'ACYM_SUBSCRIBE'); $unsubscribeText = $params->get('unsubtext', 'ACYM_UNSUBSCRIBE'); $unsubButton = $params->get('unsub', '0'); $disableButtons = !empty($args['disableButtons']) || acym_isAdmin(); $listPosition = $params->get('listposition', 'before'); $displayOutside = $params->get('textmode') == '0'; $successMode = $params->get('successmode', 'replace'); $redirectURL = $params->get('redirect', ''); $unsubRedirectURL = $params->get('unsubredirect', ''); $ajax = empty($redirectURL) && empty($unsubRedirectURL) && $successMode != 'standard' ? '1' : '0'; $formClass = $params->get('formclass', ''); $alignment = $params->get('alignment', 'none'); $style = $alignment == 'none' ? '' : 'style="text-align: '.$alignment.'"'; $displayInAPopup = 0; $termsURL = acym_getArticleURL($params->get('termscontent', 0), $displayInAPopup, 'ACYM_TERMS_CONDITIONS'); $privacyURL = acym_getArticleURL($params->get('privacypolicy', 0), $displayInAPopup, 'ACYM_PRIVACY_POLICY'); if (empty($termsURL) && empty($privacyURL)) { $termslink = ''; } elseif (empty($privacyURL)) { $termslink = acym_translationSprintf('ACYM_I_AGREE_TERMS', $termsURL); } elseif (empty($termsURL)) { $termslink = acym_translationSprintf('ACYM_I_AGREE_PRIVACY', $privacyURL); } else { $termslink = acym_translationSprintf('ACYM_I_AGREE_BOTH', $termsURL, $privacyURL); } $formName = acym_getModuleFormName(); $formAction = htmlspecialchars_decode(acym_frontendLink('frontusers')); $js = "window.addEventListener('DOMContentLoaded', (event) => {"; $js .= "\n"."acymModule['excludeValues".$formName."'] = [];"; $fieldsToDisplay = []; foreach ($fields as $field) { $fieldsToDisplay[$field->id] = $field->name; $js .= "\n".'acymModule["excludeValues'.$formName.'"]["'.$field->id.'"] = "'.acym_translation($field->name, true).'";'; } $js .= " });"; $return .= ''; $buttonStyle = ''; if (!empty($params->get('button_background_color', ''))) $buttonStyle .= 'background-color: '.$params->get('button_background_color', '').';'; if (!empty($params->get('button_text_color', ''))) $buttonStyle .= 'color: '.$params->get('button_text_color', '').';'; if (strlen($params->get('button_border_size', '')) > 0) $buttonStyle .= 'border-width: '.$params->get('button_border_size', '').'px;'; if (!empty($params->get('button_border_type', ''))) $buttonStyle .= 'border-style: '.$params->get('button_border_type', '').';'; if (!empty($params->get('button_border_color', ''))) $buttonStyle .= 'border-color: '.$params->get('button_border_color', '').';'; if (strlen($params->get('button_border_radius', '')) > 0) $buttonStyle .= 'border-radius: '.$params->get('button_border_radius', '').'px;'; if (!empty($buttonStyle)) { acym_addStyle(true, '#acym_module_'.$formName.' .acysubbuttons .subbutton {'.$buttonStyle.'}'); } $globalStyle = ''; if (!empty($params->get('background_color', ''))) $globalStyle .= 'background-color: '.$params->get('background_color', '').';'; if (!empty($params->get('text_color', ''))) $globalStyle .= 'color: '.$params->get('text_color', '').';'; if (!empty($globalStyle)) { acym_addStyle(true, '#acym_module_'.$formName.', #acym_module_'.$formName.' td {'.$globalStyle.'}'); } ob_start(); ?>