PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 6.2.14
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v6.2.14
6.2.14 6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 All 196 releases
← All changes | app/Services/FormBuilder/EditorShortCode.php +82 -48 3.6.416.2.14 View file →
@@ -3,34 +3,35 @@
3 3 namespace FluentForm\App\Services\FormBuilder;
4 4
5 5 use FluentForm\App\Modules\Form\FormFieldsParser;
6 6
7 -class EditorShortcode
7 +class EditorShortCode
8 8 {
9 9 public static function getGeneralShortCodes()
10 10 {
11 11 return [
12 - 'title' => 'General SmartCodes',
12 + 'title' => __('General SmartCodes','fluentform'),
13 13 'shortcodes' => [
14 - '{wp.admin_email}' => __('Admin Email', 'fluentform'),
15 - '{wp.site_url}' => __('Site URL', 'fluentform'),
16 - '{wp.site_title}' => __('Site Title', 'fluentform'),
17 - '{ip}' => __('IP Address', 'fluentform'),
18 - '{date.m/d/Y}' => __('Date (mm/dd/yyyy)', 'fluentform'),
19 - '{date.d/m/Y}' => __('Date (dd/mm/yyyy)', 'fluentform'),
20 - '{embed_post.ID}' => __('Embedded Post/Page ID', 'fluentform'),
21 - '{embed_post.post_title}' => __('Embedded Post/Page Title', 'fluentform'),
22 - '{embed_post.permalink}' => __('Embedded URL', 'fluentform'),
23 - '{http_referer}' => __('HTTP Referer URL', 'fluentform'),
24 - '{user.ID}' => __('User ID', 'fluentform'),
25 - '{user.display_name}' => __('User Display Name', 'fluentform'),
26 - '{user.first_name}' => __('User First Name', 'fluentform'),
27 - '{user.last_name}' => __('User Last Name', 'fluentform'),
28 - '{user.user_email}' => __('User Email', 'fluentform'),
29 - '{user.user_login}' => __('User Username', 'fluentform'),
30 - '{browser.name}' => __('User Browser Client', 'fluentform'),
31 - '{browser.platform}' => __('User Operating System', 'fluentform')
32 - ]
14 + '{wp.admin_email}' => __('Admin Email', 'fluentform'),
15 + '{wp.site_url}' => __('Site URL', 'fluentform'),
16 + '{wp.site_title}' => __('Site Title', 'fluentform'),
17 + '{ip}' => __('IP Address', 'fluentform'),
18 + '{date.m/d/Y}' => __('Date (mm/dd/yyyy)', 'fluentform'),
19 + '{date.d/m/Y}' => __('Date (dd/mm/yyyy)', 'fluentform'),
20 + '{embed_post.ID}' => __('Embedded Post/Page ID', 'fluentform'),
21 + '{embed_post.post_title}' => __('Embedded Post/Page Title', 'fluentform'),
22 + '{embed_post.permalink}' => __('Embedded URL', 'fluentform'),
23 + '{http_referer}' => __('HTTP Referer URL', 'fluentform'),
24 + '{user.ID}' => __('User ID', 'fluentform'),
25 + '{user.display_name}' => __('User Display Name', 'fluentform'),
26 + '{user.first_name}' => __('User First Name', 'fluentform'),
27 + '{user.last_name}' => __('User Last Name', 'fluentform'),
28 + '{user.user_email}' => __('User Email', 'fluentform'),
29 + '{user.user_login}' => __('User Username', 'fluentform'),
30 + '{browser.name}' => __('User Browser Client', 'fluentform'),
31 + '{browser.platform}' => __('User Operating System', 'fluentform'),
32 + '{random_string.your_prefix}' => __('Random String with Prefix', 'fluentform'),
33 + ],
33 34 ];
34 35 }
35 36
36 37 public static function getFormShortCodes($form)
@@ -36,37 +37,57 @@
36 37 public static function getFormShortCodes($form)
37 38 {
38 39 $form = static::getForm($form);
39 40 $formFields = FormFieldsParser::getShortCodeInputs(
40 - $form, [
41 - 'admin_label', 'attributes', 'options'
42 - ]);
41 + $form,
42 + [
43 + 'admin_label', 'attributes', 'options',
44 + ]
45 + );
43 46
44 47 $formShortCodes = [
45 48 'shortcodes' => [],
46 - 'title' => 'Input Options'
49 + 'title' => __('Input Options','fluentform')
47 50 ];
48 51
49 52 $formShortCodes['shortcodes']['{all_data}'] = 'All Submitted Data';
53 + $formShortCodes['shortcodes']['{all_data_without_hidden_fields}'] = 'All Data Without Hidden Fields';
50 54 foreach ($formFields as $key => $value) {
51 55 $formShortCodes['shortcodes']['{inputs.' . $key . '}'] = $value['admin_label'];
52 56 }
53 57
58 + $formShortCodes['shortcodes']['{form_title}'] = __('Form Title', 'fluentform');
59 +
54 60 return $formShortCodes;
55 61 }
56 62
63 + public static function getFormLabelShortCodes($form)
64 + {
65 + $form = static::getForm($form);
66 + $formFields = FormFieldsParser::getShortCodeInputs($form, ['admin_label', 'label',]);
67 + $formLabelShortCodes = [
68 + 'shortcodes' => [],
69 + 'title' => __('Label Options','fluentform')
70 + ];
71 + foreach ($formFields as $key => $value) {
72 + $formLabelShortCodes['shortcodes']['{labels.' . $key . '}'] = wp_strip_all_tags ($value['admin_label']);
73 + }
74 + return $formLabelShortCodes;
75 + }
76 +
57 77 public static function getSubmissionShortcodes($form = false)
58 78 {
59 79 $submissionProperties = [
60 - '{submission.id}' => __('Submission ID', 'fluentform'),
61 - '{submission.serial_number}' => __('Submission Serial Number', 'fluentform'),
62 - '{submission.source_url}' => __('Source URL', 'fluentform'),
63 - '{submission.user_id}' => __('User Id', 'fluentform'),
64 - '{submission.browser}' => __('Submitter Browser', 'fluentform'),
65 - '{submission.device}' => __('Submitter Device', 'fluentform'),
66 - '{submission.status}' => __('Submission Status', 'fluentform'),
67 - '{submission.created_at}' => __('Submission Create Date', 'fluentform'),
68 - '{submission.admin_view_url}' => __('Submission Admin View URL', 'fluentform')
80 + '{submission.serial_number}' => __('#Submission Serial Number', 'fluentform'),
81 + '{submission.id}' => __('Submission ID', 'fluentform'),
82 + '{submission.user_id}' => __('User Id', 'fluentform'),
83 + '{submission.entry_uid}' => __('Entry Unique ID', 'fluentform'),
84 + '{submission.source_url}' => __('Source URL', 'fluentform'),
85 + '{submission.browser}' => __('Submitter Browser', 'fluentform'),
86 + '{submission.device}' => __('Submitter Device', 'fluentform'),
87 + '{submission.status}' => __('Submission Status', 'fluentform'),
88 + '{submission.created_at}' => __('Submission Create Date', 'fluentform'),
89 + '{submission.admin_view_url}' => __('Submission Admin View URL', 'fluentform'),
69 90 ];
70 91
71 92 if ($form) {
72 93 $form = static::getForm($form);
@@ -78,26 +99,28 @@
78 99 $submissionProperties['{submission.payment_total}'] = __('Payment Amount', 'fluentform');
79 100 }
80 101 }
81 102
82 - return [
83 - 'title' => 'Entry Attributes',
84 - 'shortcodes' => $submissionProperties
103 + $submissionShortcodes = [
104 + 'title' => __('Entry Attributes','fluentform'),
105 + 'shortcodes' => $submissionProperties,
85 106 ];
107 +
108 + return apply_filters('fluentform/submission_shortcodes', $submissionShortcodes, $form);
86 109 }
87 110
88 111 public static function getPaymentShortcodes($form)
89 112 {
90 113 return [
91 - 'title' => 'Payment Details',
114 + 'title' => __('Payment Details','fluentform'),
92 115 'shortcodes' => [
93 - '{payment.receipt}' => __('Payment Receipt', 'fluentform'),
94 - '{payment.summary}' => __('Payment Summary', 'fluentform'),
95 - '{payment.order_items}' => __('Order Items Table', 'fluentform'),
116 + '{payment.receipt}' => __('Payment Receipt', 'fluentform'),
117 + '{payment.summary}' => __('Payment Summary', 'fluentform'),
118 + '{payment.order_items}' => __('Order Items Table', 'fluentform'),
96 119 '{payment.payment_status}' => __('Payment Status', 'fluentform'),
97 - '{payment.payment_total}' => __('Payment Total', 'fluentform'),
120 + '{payment.payment_total}' => __('Payment Total', 'fluentform'),
98 121 '{payment.payment_method}' => __('Payment Method', 'fluentform'),
99 - ]
122 + ],
100 123 ];
101 124 }
102 125
103 126 public static function getShortCodes($form)
@@ -104,10 +127,11 @@
104 127 {
105 128 $form = static::getForm($form);
106 129 $groups = [
107 130 static::getFormShortCodes($form),
131 + static::getFormLabelShortCodes($form),
108 132 static::getGeneralShortCodes(),
109 - static::getSubmissionShortcodes($form)
133 + static::getSubmissionShortcodes($form),
110 134 ];
111 135
112 136 if ($form->has_payment) {
113 137 $groups[] = static::getPaymentShortcodes($form);
@@ -112,12 +136,22 @@
112 136 if ($form->has_payment) {
113 137 $groups[] = static::getPaymentShortcodes($form);
114 138 }
115 139
116 - return $groups;
140 + $groups = apply_filters_deprecated(
141 + 'fluentform_form_settings_smartcodes', [
142 + $groups,
143 + $form
144 + ],
145 + FLUENTFORM_FRAMEWORK_UPGRADE,
146 + 'fluentform/form_settings_smartcodes',
147 + 'Use fluentform/form_settings_smartcodes instead of fluentform_form_settings_smartcodes.'
148 + );
149 +
150 + return apply_filters('fluentform/form_settings_smartcodes', $groups, $form);
117 151 }
118 152
119 - public static function parse($string, $data, callable $arrayFormatter = null)
153 + public static function parse($string, $data, ?callable $arrayFormatter = null)
120 154 {
121 155 if (is_array($string)) {
122 156 return static::parseArray($string, $data, $arrayFormatter);
123 157 }
@@ -137,12 +171,12 @@
137 171
138 172 return $string;
139 173 }
140 174
141 - public static function parseString($string, $data, callable $arrayFormatter = null)
175 + public static function parseString($string, $data, ?callable $arrayFormatter = null)
142 176 {
143 177 return preg_replace_callback('/{+(.*?)}/', function ($matches) use (&$data, &$arrayFormatter) {
144 - if (!isset($data[$matches[1]])) {
178 + if (! isset($data[$matches[1]])) {
145 179 return $matches[0];
146 180 } elseif (is_array($value = $data[$matches[1]])) {
147 181 return is_callable($arrayFormatter) ? $arrayFormatter($value) : implode(', ', $value);
148 182 }