PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
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 +20 -14 6.25 → trunk View file →
@@ -9,8 +9,9 @@
9 9 class FrmEntryShortcodeFormatter {
10 10
11 11 /**
12 12 * @var int
13 + *
13 14 * @since 2.04
14 15 */
15 16 protected $form_id = 0;
16 17
@@ -15,8 +16,9 @@
15 16 protected $form_id = 0;
16 17
17 18 /**
18 19 * @var array
20 + *
19 21 * @since 2.04
20 22 */
21 23 protected $skip_fields = array( 'captcha', 'html' );
22 24
@@ -21,8 +23,9 @@
21 23 protected $skip_fields = array( 'captcha', 'html' );
22 24
23 25 /**
24 26 * @var array
27 + *
25 28 * @since 3.0
26 29 */
27 30 protected $single_cell_fields = array( 'html' );
28 31
@@ -27,8 +30,9 @@
27 30 protected $single_cell_fields = array( 'html' );
28 31
29 32 /**
30 33 * @var array
34 + *
31 35 * @since 2.04
32 36 */
33 37 protected $fields = array();
34 38
@@ -33,8 +37,9 @@
33 37 protected $fields = array();
34 38
35 39 /**
36 40 * @var bool
41 + *
37 42 * @since 2.05
38 43 */
39 44 protected $is_plain_text = false;
40 45
@@ -39,8 +44,9 @@
39 44 protected $is_plain_text = false;
40 45
41 46 /**
42 47 * @var string
48 + *
43 49 * @since 2.04
44 50 */
45 51 protected $format = 'text';
46 52
@@ -45,8 +51,9 @@
45 51 protected $format = 'text';
46 52
47 53 /**
48 54 * @var FrmTableHTMLGenerator|null
55 + *
49 56 * @since 2.04
50 57 */
51 58 protected $table_generator;
52 59
@@ -51,8 +58,9 @@
51 58 protected $table_generator;
52 59
53 60 /**
54 61 * @var array
62 + *
55 63 * @since 2.04
56 64 */
57 65 protected $array_content = array();
58 66
@@ -69,9 +77,9 @@
69 77
70 78 $this->init_form_id( $form_id );
71 79 $this->init_fields();
72 80
73 - if ( empty( $this->fields ) ) {
81 + if ( ! $this->fields ) {
74 82 return;
75 83 }
76 84
77 85 $this->init_plain_text( $atts );
@@ -115,9 +123,9 @@
115 123 *
116 124 * @return void
117 125 */
118 126 protected function init_plain_text( $atts ) {
119 - if ( isset( $atts['plain_text'] ) && $atts['plain_text'] ) {
127 + if ( ! empty( $atts['plain_text'] ) ) {
120 128 $this->is_plain_text = true;
121 129 }
122 130 }
123 131
@@ -152,11 +160,13 @@
152 160 /**
153 161 * Return the default HTML for an entry
154 162 *
155 163 * @since 2.04
164 + *
165 + * @return array|string
156 166 */
157 167 public function content() {
158 - if ( ! $this->form_id || empty( $this->fields ) ) {
168 + if ( ! $this->form_id || ! $this->fields ) {
159 169 return '';
160 170 }
161 171
162 172 if ( $this->format === 'array' ) {
@@ -205,11 +215,10 @@
205 215 */
206 216 protected function get_table() {
207 217 $content = $this->table_generator->generate_table_header();
208 218 $content .= $this->generate_content_for_all_fields();
209 - $content .= $this->table_generator->generate_table_footer();
210 219
211 - return $content;
220 + return $content . $this->table_generator->generate_table_footer();
212 221 }
213 222
214 223 /**
215 224 * Generate the content for all fields
@@ -237,15 +246,13 @@
237 246 *
238 247 * @return string
239 248 */
240 249 protected function generate_field_content( $field ) {
241 - if ( in_array( $field->type, $this->skip_fields ) ) {
250 + if ( in_array( $field->type, $this->skip_fields, true ) ) {
242 251 return '';
243 252 }
244 253
245 - $row = $this->generate_two_cell_shortcode_row( $field );
246 -
247 - return $row;
254 + return $this->generate_two_cell_shortcode_row( $field );
248 255 }
249 256
250 257 /**
251 258 * Generate a two cell row of shortcodes for an HTML or plain text table
@@ -257,10 +264,9 @@
257 264 *
258 265 * @return string
259 266 */
260 267 protected function generate_two_cell_shortcode_row( $field, $value = null ) {
261 - $row = '[if ' . $field->id . ']';
262 -
268 + $row = '[if ' . $field->id . ']';
263 269 $label = '[' . $field->id . ' show=field_label]';
264 270
265 271 if ( $value === null ) {
266 272 $value = '[' . $field->id . ']';
@@ -290,9 +296,9 @@
290 296 *
291 297 * @return void
292 298 */
293 299 protected function add_field_array( $field ) {
294 - if ( in_array( $field->type, $this->skip_fields ) ) {
300 + if ( in_array( $field->type, $this->skip_fields, true ) ) {
295 301 return;
296 302 }
297 303
298 304 $this->add_single_field_array( $field, $field->id );
@@ -325,9 +331,9 @@
325 331 *
326 332 * @return bool
327 333 */
328 334 protected function is_plain_text_format() {
329 - return ( $this->format === 'text' && $this->is_plain_text === true );
335 + return $this->format === 'text' && $this->is_plain_text === true;
330 336 }
331 337
332 338 /**
333 339 * Check if the format is default HTML
@@ -336,7 +342,7 @@
336 342 *
337 343 * @return bool
338 344 */
339 345 protected function is_table_format() {
340 - return ( $this->format === 'text' && $this->is_plain_text === false );
346 + return $this->format === 'text' && $this->is_plain_text === false;
341 347 }
342 348 }