'; } /** * Check token with all the possibilities */ function acym_checkToken(): void { $token = acym_getVar('cmd', '_wpnonce'); if (!wp_verify_nonce($token, 'acymnonce')) { die('Invalid Token'); } } function acym_getFormToken(): string { $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): void { 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): void { if (!empty($currentStep)) { echo ''; } echo ''; echo ''; if ($addPage) { echo ''; } echo ''; if ($token) { acym_formToken(); } echo ''; } global $acymMetaData; function acym_addMetadata($meta, $data, string $name = 'name'): void { 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(): void { global $acymMetaData; if (!empty($acymMetaData)) { foreach ($acymMetaData as $metadata) { if (empty($metadata->data)) { echo 'name).'="'.esc_attr($metadata->meta).'"/>'; } else { echo 'name).'="'.esc_attr($metadata->meta).'" content="'.esc_attr($metadata->data).'"/>'; } } } $acymMetaData = []; } function acym_includeHeaders(): void { do_action('acym_head'); } function acym_getOptionRegacyPosition(): void { } function acym_renderForm(AcymParameter $params, array $args = []): void { acym_initModule($params); if (!empty($args['before_widget'])) { echo wp_kses_post($args['before_widget']); } $title = apply_filters('widget_title', $params->get('title')); if (!empty($title)) { if (!empty($args['before_title'])) { echo wp_kses_post($args['before_title']); } echo esc_html($title); if (!empty($args['after_title'])) { echo wp_kses_post($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); // We need the email address 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); } // Make sure we don't display a list that's in "automatically subscribe to" if (!empty($visibleLists) && !empty($hiddenLists)) { $visibleLists = array_diff($visibleLists, $hiddenLists); } if (empty($identifiedUser->id)) { //Check lists based on the option $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(); // Texts $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(); // Formatting $listPosition = $params->get('listposition', 'before'); $displayOutside = $params->get('textmode') == '0'; $showTrackingConsent = $params->get('trackingconsent', '0') == '1'; // Display success message $successMode = $params->get('successmode', 'replace'); // Redirections $redirectURL = $params->get('redirect', ''); $unsubRedirectURL = $params->get('unsubredirect', ''); $ajax = empty($redirectURL) && empty($unsubRedirectURL) && $successMode != 'standard' ? '1' : '0'; // Customization $formClass = $params->get('formclass', ''); $alignment = $params->get('alignment', 'none'); // Articles $termsURL = acym_getArticleURL($params->get('termscontent', 0), false, 'ACYM_TERMS_CONDITIONS'); $privacyURL = acym_getArticleURL($params->get('privacypolicy', 0), false, 'ACYM_PRIVACY_POLICY'); if (empty($termsURL)) { $termsURL = $params->get('termscontentURL') ?? ''; if (!empty($termsURL)) { $termsURL = ''.esc_html(acym_translation('ACYM_TERMS_CONDITIONS')).''; } } if (empty($privacyURL)) { $privacyURL = $params->get('privacypolicyURL') ?? ''; if (!empty($privacyURL)) { $privacyURL = ''.esc_html(acym_translation('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')); $buttonStyle = ''; if (!empty($params->get('button_background_color', ''))) $buttonStyle .= 'background-color: '.esc_attr($params->get('button_background_color', '')).';'; if (!empty($params->get('button_text_color', ''))) $buttonStyle .= 'color: '.esc_attr($params->get('button_text_color', '')).';'; if (strlen($params->get('button_border_size', '')) > 0) $buttonStyle .= 'border-width: '.esc_attr($params->get('button_border_size', '')).'px;'; if (!empty($params->get('button_border_type', ''))) $buttonStyle .= 'border-style: '.esc_attr($params->get('button_border_type', '')).';'; if (!empty($params->get('button_border_color', ''))) $buttonStyle .= 'border-color: '.esc_attr($params->get('button_border_color', '')).';'; if (strlen($params->get('button_border_radius', '')) > 0) $buttonStyle .= 'border-radius: '.esc_attr($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.'}'); } // Exclude default values from fields, if the user didn't fill them in ?>
>
get('introtext', ''); if (!empty($introText)) { echo '
'.esc_html($introText).'
'; } if ($params->get('mode', 'tableless') === 'tableless') { include ACYM_FOLDER.'widgets'.DS.'subscriptionform'.DS.'tmpl'.DS.'tableless.php'; } else { $displayInline = $params->get('mode', 'tableless') !== 'vertical'; include ACYM_FOLDER.'widgets'.DS.'subscriptionform'.DS.'tmpl'.DS.'default.php'; } ?>
'; if (!empty($unsubRedirectURL)) echo ''; ?> get('posttext', ''); if (!empty($postText)) { echo '
'.esc_html($postText).'
'; } ?>
get('listsdropdown', '0'))) { $listDropdown = $params->get('listsdropdown', '0'); } else { $listDropdown = $params->get('listsdropdown')[0]; } $instance = [ 'title' => $params->get('title', ''), 'lists' => $params->get('lists'), 'listschecked' => $params->get('listschecked'), 'dropdown' => $listDropdown, 'hiddenlists' => $params->get('hiddenlists'), 'fields' => $params->get('fields'), 'introtext' => $params->get('introtext', ''), 'posttext' => $params->get('posttext', ''), 'source' => $params->get('source', ''), ]; $title = apply_filters('widget_title', $instance['title']); if (!empty($title)) { $title = ''.esc_html($title).''; } $return = $title; ob_start(); acym_setVar('page', ACYM_COMPONENT.'_front'); $userController = new FrontusersController(); $data = $userController->prepareParams((object)$instance); $data['disableButtons'] = !empty($args['disableButtons']) || acym_isAdmin(); if (empty($data['user']->language)) { $cmsUserLanguage = acym_getCmsUserLanguage(); $data['user']->language = empty($cmsUserLanguage) ? acym_getLanguageTag() : $cmsUserLanguage; } acym_setVar('layout', 'profile'); $userController->display($data); $return .= ob_get_clean(); return $return; } function acym_renderFormArchive(AcymParameter $params, array $args = []): string { acym_initModule($params); if (!is_array($params->get('popup', '1'))) { $popup = $params->get('popup', '1'); } else { $popup = $params->get('popup')[0]; } if (!is_array($params->get('displayUserListOnly', '1'))) { $displayUserListOnly = $params->get('displayUserListOnly', '1'); } else { $displayUserListOnly = $params->get('displayUserListOnly')[0]; } $instance = [ 'title' => $params->get('title', ''), 'archiveNbNewslettersPerPage' => $params->get('archiveNbNewslettersPerPage', 20), 'lists' => $params->get('lists'), 'popup' => $popup, 'displayUserListOnly' => $displayUserListOnly, ]; $title = apply_filters('widget_title', $instance['title']); if (!empty($title)) { $title = ''.esc_html($title).''; } $return = $title; ob_start(); acym_setVar('page', 'front'); $searchs = acym_getVar('array', 'acym_search', []); $search = ''; if (!empty($searchs[0])) $search = $searchs[0]; $disableButtons = !empty($args['disableButtons']) || acym_isAdmin(); $viewParams = [ 'listsSent' => isset($instance['lists']) ? $instance['lists'] : [], 'popup' => isset($instance['popup']) ? $instance['popup'] : '1', 'displayUserListOnly' => isset($instance['displayUserListOnly']) ? $instance['displayUserListOnly'] : '1', 'paramsCMS' => ['widget_id' => 0, 'suffix' => ''], 'search' => $search, 'disableButtons' => $disableButtons, 'nbNewslettersPerPage' => $instance['archiveNbNewslettersPerPage'], ]; $archiveController = new ArchiveController(); $archiveController->showArchive($viewParams); $return .= ob_get_clean(); return $return; } function acym_checked(bool $checked, bool $current = true, bool $display = true): string { return checked($checked, $current, $display); } function acym_selected(bool $selected, bool $current = true, bool $display = true): string { return selected($selected, $current, $display); } function acym_disabled(bool $disabled, bool $current = true, bool $display = true): string { return disabled($disabled, $current, $display); }