diff --git a/lib/Config/Menu.php b/lib/Config/Menu.php index 93bb7caf58..0d00431dc3 100644 --- a/lib/Config/Menu.php +++ b/lib/Config/Menu.php @@ -7,6 +7,7 @@ use MailPoet\Models\CustomField; use MailPoet\Models\Form; use MailPoet\Models\Segment; use MailPoet\Models\Setting; +use MailPoet\Newsletter\Shortcodes\ShortcodesHelper; use MailPoet\Settings\Charsets; use MailPoet\Settings\Hosts; use MailPoet\Settings\Pages; @@ -419,15 +420,8 @@ class Menu { } function newletterEditor() { - $custom_fields = array_map(function($field) { - return array( - 'text' => $field['name'], - 'shortcode' => 'field:' . $field['id'], - ); - }, CustomField::findArray()); - $data = array( - 'customFields' => $custom_fields, + 'shortcodes' => ShortcodesHelper::getShortcodes(), 'settings' => Setting::getAll(), 'sub_menu' => 'mailpoet-newsletters' ); diff --git a/views/newsletter/editor.html b/views/newsletter/editor.html index 77c815a80c..c2dc0dd548 100644 --- a/views/newsletter/editor.html +++ b/views/newsletter/editor.html @@ -1168,93 +1168,7 @@ }, }, }, - customFields: { - '<%= __('Subscriber') %>': [ - { - text: '<%= __('First Name') %>', - shortcode: 'user:firstname | default:reader', - }, - { - text: '<%= __('Last Name') %>', - shortcode: 'user:lastname | default:reader', - }, - { - text: '<%= __('Email Address') %>', - shortcode: 'user:email', - }, - { - text: '<%= __('Wordpress user display name') %>', - shortcode: 'user:displayname | default:member', - }, - { - text: '<%= __('Total of subscribers') %>', - shortcode: 'user:count', - } - ], - '<%= __('Newsletter') %>': [ - { - text: '<%= __('Newsletter Subject') %>', - shortcode: 'newsletter:subject', - }, - ], - '<%= __('Post Notifications') %>': [ - { - text: '<%= __('Total number of posts or pages') %>', - shortcode: 'newsletter:total', - }, - { - text: '<%= __('Latest post title') %>', - shortcode: 'newsletter:post_title', - }, - { - text: '<%= __('Issue number') %>', - shortcode: 'newsletter:number', - } - ], - '<%= __('Date') %>': [ - { - text: '<%= __('Current day of the month number') %>', - shortcode: 'date:d', - }, - { - text: '<%= __('Current day of the month in ordinal, ie. 2nd, 3rd, etc.') %>', - shortcode: 'date:dordinal', - }, - { - text: '<%= __('Full name of current day') %>', - shortcode: 'date:dtext', - }, - { - text: '<%= __('Current month number') %>', - shortcode: 'date:m', - }, - { - text: '<%= __('Full name of current month') %>', - shortcode: 'date:mtext', - }, - { - text: '<%= __('Year') %>', - shortcode: 'date:y', - } - ], - '<%= __('Links') %>': [ - { - text: '<%= __('Unsubscribe link') %>', - shortcode: 'link:subscription_unsubscribe', - }, - { - text: '<%= __('Edit subscription page link') %>', - shortcode: 'link:subscription_manage', - }, - { - text: '<%= __('View in browser link') %>', - shortcode: 'link:newsletter_view_in_browser', - } - ], - <% if customFields %> - '<%= __('Custom fields') %>': <%= json_encode(customFields) %>, - <% endif %> - }, + shortcodes: <%= json_encode(shortcodes) %>, sidepanelWidth: '331px', validation: { validateUnsubscribeLinkPresent: true, // TODO: Add validation based on whether Mailpoet MTA is used or not