# acymailing/11.0.1/back/Controllers/Segments/Listing.php

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

- Page: https://pluginprobe.com/plugins/acymailing/11.0.1/code/back/Controllers/Segments/Listing.php
- Raw: https://pluginprobe.com/plugins/acymailing/11.0.1/raw/back/Controllers/Segments/Listing.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.0.1/code/back/Controllers/Segments/Listing.php#L10-L20`.

```php
<?php

namespace AcyMailing\Controllers\Segments;

use AcyMailing\Classes\SegmentClass;
use AcyMailing\Helpers\PaginationHelper;
use AcyMailing\Helpers\ToolbarHelper;

trait Listing
{
    public function listing(): void
    {
        if (!acym_level(ACYM_ENTERPRISE)) {
            acym_redirect(acym_completeLink('dashboard&task=upgrade&version=enterprise', false, true));
        }

    }

    private function prepareToolbar(array &$data): void
    {
        $toolbarHelper = new ToolbarHelper();
        $toolbarHelper->addSearchBar($data['search'], 'segments_search');
        $toolbarHelper->addButton(acym_translation('ACYM_CREATE'), ['data-task' => 'edit'], 'add', true);

        $data['toolbar'] = $toolbarHelper;
    }

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

        $ids = acym_getVar('array', 'elements_checked', []);

        $segmentClass = new SegmentClass();

        foreach ($ids as $id) {
            $segment = $segmentClass->getOneById($id);

            if (empty($segment)) {
                continue;
            }

            unset($segment->id);
            $segment->name .= ' - '.acym_translation('ACYM_COPY');
            $segment->creation_date = acym_date('now', 'Y-m-d H:i:s');
            $segment->filters = json_encode($segment->filters);

            $segmentClass->save($segment);
        }

        $this->listing();
    }
}

```
