PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 3.06.06
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v3.06.06
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/models/FrmEntryShortcodeFormatter.php +9 -43 6.263.06.06 View file →
@@ -1,8 +1,5 @@
1 1 <?php
2 -if ( ! defined( 'ABSPATH' ) ) {
3 - die( 'You are not allowed to call this page directly.' );
4 -}
5 2
6 3 /**
7 4 * @since 2.04
8 5 */
@@ -9,9 +6,8 @@
9 6 class FrmEntryShortcodeFormatter {
10 7
11 8 /**
12 9 * @var int
13 - *
14 10 * @since 2.04
15 11 */
16 12 protected $form_id = 0;
17 13
@@ -16,9 +12,8 @@
16 12 protected $form_id = 0;
17 13
18 14 /**
19 15 * @var array
20 - *
21 16 * @since 2.04
22 17 */
23 18 protected $skip_fields = array( 'captcha', 'html' );
24 19
@@ -23,9 +18,8 @@
23 18 protected $skip_fields = array( 'captcha', 'html' );
24 19
25 20 /**
26 21 * @var array
27 - *
28 22 * @since 3.0
29 23 */
30 24 protected $single_cell_fields = array( 'html' );
31 25
@@ -30,9 +24,8 @@
30 24 protected $single_cell_fields = array( 'html' );
31 25
32 26 /**
33 27 * @var array
34 - *
35 28 * @since 2.04
36 29 */
37 30 protected $fields = array();
38 31
@@ -37,9 +30,8 @@
37 30 protected $fields = array();
38 31
39 32 /**
40 33 * @var bool
41 - *
42 34 * @since 2.05
43 35 */
44 36 protected $is_plain_text = false;
45 37
@@ -44,23 +36,20 @@
44 36 protected $is_plain_text = false;
45 37
46 38 /**
47 39 * @var string
48 - *
49 40 * @since 2.04
50 41 */
51 42 protected $format = 'text';
52 43
53 44 /**
54 - * @var FrmTableHTMLGenerator|null
55 - *
45 + * @var FrmTableHTMLGenerator
56 46 * @since 2.04
57 47 */
58 - protected $table_generator;
48 + protected $table_generator = null;
59 49
60 50 /**
61 51 * @var array
62 - *
63 52 * @since 2.04
64 53 */
65 54 protected $array_content = array();
66 55
@@ -67,9 +56,9 @@
67 56 /**
68 57 * FrmEntryShortcodeFormatter constructor
69 58 *
70 59 * @param int|string $form_id
71 - * @param array $atts
60 + * @param array $atts
72 61 */
73 62 public function __construct( $form_id, $atts ) {
74 63 if ( ! $form_id ) {
75 64 return;
@@ -93,12 +82,9 @@
93 82 /**
94 83 * Initialize the form_id property
95 84 *
96 85 * @since 2.04
97 - *
98 - * @param int|string $form_id
99 - *
100 - * @return void
86 + * @param $form_id
101 87 */
102 88 protected function init_form_id( $form_id ) {
103 89 $this->form_id = (int) $form_id;
104 90 }
@@ -106,10 +92,8 @@
106 92 /**
107 93 * Initialize the fields property
108 94 *
109 95 * @since 2.04
110 - *
111 - * @return void
112 96 */
113 97 protected function init_fields() {
114 98 $this->fields = FrmField::get_all_for_form( $this->form_id, '', 'exclude', 'exclude' );
115 99 }
@@ -119,10 +103,8 @@
119 103 *
120 104 * @since 2.05
121 105 *
122 106 * @param array $atts
123 - *
124 - * @return void
125 107 */
126 108 protected function init_plain_text( $atts ) {
127 109 if ( isset( $atts['plain_text'] ) && $atts['plain_text'] ) {
128 110 $this->is_plain_text = true;
@@ -134,10 +116,8 @@
134 116 *
135 117 * @since 2.04
136 118 *
137 119 * @param array $atts
138 - *
139 - * @return void
140 120 */
141 121 protected function init_format( $atts ) {
142 122 if ( isset( $atts['format'] ) && is_string( $atts['format'] ) && $atts['format'] !== '' ) {
143 123 $this->format = $atts['format'];
@@ -149,10 +129,8 @@
149 129 /**
150 130 * Initialize the table_generator property
151 131 *
152 132 * @since 2.04
153 - *
154 - * @return void
155 133 */
156 134 protected function init_table_generator() {
157 135 $this->table_generator = new FrmTableHTMLGenerator( 'shortcode' );
158 136 }
@@ -160,10 +138,8 @@
160 138 /**
161 139 * Return the default HTML for an entry
162 140 *
163 141 * @since 2.04
164 - *
165 - * @return array|string
166 142 */
167 143 public function content() {
168 144 if ( ! $this->form_id || empty( $this->fields ) ) {
169 145 return '';
@@ -168,11 +144,11 @@
168 144 if ( ! $this->form_id || empty( $this->fields ) ) {
169 145 return '';
170 146 }
171 147
172 - if ( $this->format === 'array' ) {
148 + if ( $this->format == 'array' ) {
173 149 $content = $this->get_array();
174 - } elseif ( $this->is_plain_text_format() ) {
150 + } else if ( $this->is_plain_text_format() ) {
175 151 $content = $this->get_plain_text();
176 152 } else {
177 153 $content = $this->get_table();
178 154 }
@@ -183,10 +159,8 @@
183 159 /**
184 160 * Return the default HTML array
185 161 *
186 162 * @since 2.04
187 - *
188 - * @return array
189 163 */
190 164 protected function get_array() {
191 165 foreach ( $this->fields as $field ) {
192 166 $this->add_field_array( $field );
@@ -198,10 +172,8 @@
198 172 /**
199 173 * Return the default plain text for an email message
200 174 *
201 175 * @since 2.04
202 - *
203 - * @return string
204 176 */
205 177 protected function get_plain_text() {
206 178 return $this->generate_content_for_all_fields();
207 179 }
@@ -209,13 +181,11 @@
209 181 /**
210 182 * Return the default HTML for an email message
211 183 *
212 184 * @since 2.04
213 - *
214 - * @return string
215 185 */
216 186 protected function get_table() {
217 - $content = $this->table_generator->generate_table_header();
187 + $content = $this->table_generator->generate_table_header();
218 188 $content .= $this->generate_content_for_all_fields();
219 189 $content .= $this->table_generator->generate_table_footer();
220 190
221 191 return $content;
@@ -262,9 +232,9 @@
262 232 *
263 233 * @since 2.04
264 234 *
265 235 * @param stdClass $field
266 - * @param mixed $value
236 + * @param mixed $value
267 237 *
268 238 * @return string
269 239 */
270 240 protected function generate_two_cell_shortcode_row( $field, $value = null ) {
@@ -296,10 +266,8 @@
296 266 *
297 267 * @since 2.04
298 268 *
299 269 * @param stdClass $field
300 - *
301 - * @return void
302 270 */
303 271 protected function add_field_array( $field ) {
304 272 if ( in_array( $field->type, $this->skip_fields ) ) {
305 273 return;
@@ -313,11 +281,9 @@
313 281 *
314 282 * @since 2.04
315 283 *
316 284 * @param stdClass $field
317 - * @param string $value
318 - *
319 - * @return void
285 + * @param string $value
320 286 */
321 287 protected function add_single_field_array( $field, $value ) {
322 288 $array = array(
323 289 'label' => '[' . $field->id . ' show=field_label]',