# acymailing/11.1.0/back/Controllers/Dashboard/Walkthrough.php

AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress, version 11.1.0. 289 lines.

- Page: https://pluginprobe.com/plugins/acymailing/11.1.0/code/back/Controllers/Dashboard/Walkthrough.php
- Raw: https://pluginprobe.com/plugins/acymailing/11.1.0/raw/back/Controllers/Dashboard/Walkthrough.php
- Modified: 2026-08-03T10:18:54+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/acymailing/11.1.0/code/back/Controllers/Dashboard/Walkthrough.php#L10-L20`.

```php
<?php

namespace AcyMailing\Controllers\Dashboard;

use AcyMailing\Classes\MailClass;
use AcyMailing\Controllers\ConfigurationController;
use AcyMailing\Controllers\MailsController;
use AcyMailing\Helpers\EditorHelper;
use AcyMailing\Helpers\UpdateHelper;
use AcyMailing\Helpers\UpdatemeHelper;
use AcyMailing\Types\StepsType;

trait Walkthrough
{
    public function saveStepThankYou(): void
    {
        wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');

        if (!acym_isAllowed('configuration')) {
            return;
        }

        $this->saveWalkthrough(['step' => 'stepSenderInformation']);
        $this->stepSenderInformation();
    }

    public function saveStepSenderInformation(): void
    {
        wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');

        if (!acym_isAllowed('configuration')) {
            return;
        }

        $newConfiguration = [
            'from_name' => acym_getVar('string', 'from_name'),
            'from_email' => acym_getVar('string', 'from_email'),
        ];

        if (empty($newConfiguration['from_name']) || empty($newConfiguration['from_email'])) {
            acym_enqueueMessage(acym_translation('ACYM_FILL_ALL_INFORMATION'), 'error');
            $this->stepSenderInformation();

            return;
        }

        $this->config->saveConfig($newConfiguration);

        $this->saveWalkthrough(['step' => 'stepLicense']);
        $this->stepLicense();
    }

    public function ajaxAttachLicense(): void
    {
        wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');

        if (!acym_isAllowed('configuration')) {
            return;
        }

        $licenseKey = acym_getVar('string', 'licenseKey', '');
        if (empty($licenseKey)) {
            acym_sendAjaxResponse(acym_translation('ACYM_LICENSE_NOT_FOUND'), [], false);
        }

        $this->config->saveConfig(['license_key' => $licenseKey]);

        $configurationController = new ConfigurationController();
        $return = $configurationController->attachLicenseOnUpdateMe($licenseKey);

        if (empty($return['success'])) {
            $this->config->saveConfig(['license_key' => '']);
        } else {
            UpdatemeHelper::getLicenseInfo();
        }

        $originalMessage = $return['message'];
        $return['message'] = $configurationController->displayMessage($originalMessage, true);
        $ajaxSuccess = !empty($return['message']['type']) && $return['message']['type'] !== 'error';

        acym_sendAjaxResponse($return['message']['message'] ?? $originalMessage, [], $ajaxSuccess);
    }

    public function ajaxActivateCron(): void
    {
        wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');

        if (!acym_isAllowed('configuration')) {
            return;
        }

        $licenseKey = $this->config->get('license_key');
        if (empty($licenseKey)) {
            acym_sendAjaxResponse(acym_translation('ACYM_LICENSE_NOT_FOUND'), [], false);
        }

        $data = [
            'domain' => ACYM_LIVE,
            'cms' => ACYM_CMS,
            'version' => $this->config->get('version', ''),
            'level' => $this->config->get('level', ''),
            'activate' => true,
        ];
        $result = UpdatemeHelper::call('api/crons/modify', 'POST', $data);

        $configurationController = new ConfigurationController();
        $result['message'] = $configurationController->displayMessage($result['message'] ?? 'CRON_NOT_SAVED', true);
        $success = !empty($result['success']);

        if ($success) {
            $this->config->saveConfig(['active_cron' => 1]);
        }

        acym_sendAjaxResponse($result['message']['message'], [], $success);
    }

    public function saveStepLicense(): void
    {
        wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');

        if (!acym_isAllowed('configuration')) {
            return;
        }

        $this->saveWalkthrough(['step' => 'stepFinal']);
        $this->stepFinal();
    }

    public function startUsing(bool $campaigns = false): void
    {
        if (!$campaigns) {
            wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');
        }

        if (!acym_isAllowed('configuration')) {
            return;
        }

        $this->config->saveConfig(['walk_through' => 0]);
        $redirectUrl = $campaigns ? 'campaigns' : 'dashboard';

        acym_redirect(acym_completeLink($redirectUrl, false, true));
    }

    public function tryEditor(): void
    {
        wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');

        if (!acym_isAllowed('configuration')) {
            return;
        }

        $this->saveWalkthrough(['step' => 'stepEditor']);
        $this->stepEditor();
    }

    public function saveAjax(): void
    {
        wp_verify_nonce(acym_getVar('cmd', '_wpnonce'), 'acymnonce') || die('Invalid Token');

        if (!acym_isAllowed('configuration') || $this->config->get('walk_through', 0) != 1) {
            return;
        }

        $mailController = new MailsController();
        $mailId = $mailController->store(true);

        if (!empty($mailId)) {
            acym_sendAjaxResponse('', ['result' => $mailId]);
        } else {
            acym_sendAjaxResponse(acym_translation('ACYM_ERROR_SAVING'), [], false);
        }
    }

    private function walkthrough(): bool
    {
        if ($this->config->get('walk_through', 0) != 1 || !acym_isAllowed('configuration')) {
            return false;
        }

        $walkthroughParams = json_decode($this->config->get('walkthrough_params', '[]'), true);
        if (empty($walkthroughParams['step']) || !method_exists($this, $walkthroughParams['step'])) {
            $this->stepThankYou();
        } else {
            $this->{$walkthroughParams['step']}();
        }

        return true;
    }

    private function stepThankYou(): void
    {
        acym_setVar('layout', 'step_thank_you');

        $data = [
            'level' => $this->config->get('level'),
        ];

        parent::display($data);
    }

    private function stepSenderInformation(): void
    {
        acym_setVar('layout', 'step_sender_information');

        $data = [
            'stepsType' => new StepsType(),
            'siteName' => $this->config->get('from_name', acym_getCMSConfig('sitename')),
            'userEmail' => $this->config->get('from_email', acym_currentUserEmail()),
        ];

        parent::display($data);
    }

    private function stepLicense(): void
    {
        acym_setVar('layout', 'step_license');

        $data = [
            'stepsType' => new StepsType(),
            'level' => $this->config->get('level'),
        ];

        parent::display($data);
    }

    private function stepFinal(): void
    {
        $acyMailerApiKey = $this->config->get('acymailer_apikey');
        acym_setVar('layout', empty($acyMailerApiKey) ? 'step_final' : 'step_acymailer');

        $data = [
            'stepsType' => new StepsType(),
            'pricingPage' => ACYM_ACYMAILING_WEBSITE.'pricing',
        ];

        if (!empty($acyMailerApiKey)) {
            $data['suggestedDomain'] = acym_getDomain($this->config->get('from_email', acym_currentUserEmail()));
        }

        parent::display($data);
    }

    private function stepEditor(): void
    {
        acym_setVar('layout', 'step_editor');

        $mailClass = new MailClass();
        $mail = $mailClass->getOneByName(acym_translation(UpdateHelper::FIRST_EMAIL_NAME_KEY));

        if (empty($mail)) {
            $updateHelper = new UpdateHelper();
            $updateHelper->installNotifications();
            $mail = $mailClass->getOneByName(acym_translation(UpdateHelper::FIRST_EMAIL_NAME_KEY));
            if (empty($mail)) {
                $this->startUsing(true);

                return;
            }
        }

        $editorHelper = new EditorHelper();
        $editorHelper->content = $mail->body;
        $editorHelper->autoSave = '';
        $editorHelper->settings = $mail->settings;
        $editorHelper->stylesheet = $mail->stylesheet ?? '';
        $editorHelper->editor = 'acyEditor';
        $editorHelper->mailId = $mail->id;
        $editorHelper->walkThrough = true;

        $data = [
            'mail' => $mail,
            'social_icons' => $this->config->get('social_icons', '{}'),
            'editor' => $editorHelper,
        ];

        parent::display($data);
    }

    private function saveWalkthrough(array $params): void
    {
        $newParams = json_decode($this->config->get('walkthrough_params', '[]'), true);
        foreach ($params as $key => $value) {
            $newParams[$key] = $value;
        }
        $this->config->saveConfig(['walkthrough_params' => json_encode($newParams)]);
    }
}

```
