PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 4.01.02
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v4.01.02
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 +8 -41 6.264.01.02 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;
@@ -94,11 +83,9 @@
94 83 * Initialize the form_id property
95 84 *
96 85 * @since 2.04
97 86 *
98 - * @param int|string $form_id
99 - *
100 - * @return void
87 + * @param $form_id
101 88 */
102 89 protected function init_form_id( $form_id ) {
103 90 $this->form_id = (int) $form_id;
104 91 }
@@ -106,10 +93,8 @@
106 93 /**
107 94 * Initialize the fields property
108 95 *
109 96 * @since 2.04
110 - *
111 - * @return void
112 97 */
113 98 protected function init_fields() {
114 99 $this->fields = FrmField::get_all_for_form( $this->form_id, '', 'exclude', 'exclude' );
115 100 }
@@ -119,10 +104,8 @@
119 104 *
120 105 * @since 2.05
121 106 *
122 107 * @param array $atts
123 - *
124 - * @return void
125 108 */
126 109 protected function init_plain_text( $atts ) {
127 110 if ( isset( $atts['plain_text'] ) && $atts['plain_text'] ) {
128 111 $this->is_plain_text = true;
@@ -134,10 +117,8 @@
134 117 *
135 118 * @since 2.04
136 119 *
137 120 * @param array $atts
138 - *
139 - * @return void
140 121 */
141 122 protected function init_format( $atts ) {
142 123 if ( isset( $atts['format'] ) && is_string( $atts['format'] ) && $atts['format'] !== '' ) {
143 124 $this->format = $atts['format'];
@@ -149,10 +130,8 @@
149 130 /**
150 131 * Initialize the table_generator property
151 132 *
152 133 * @since 2.04
153 - *
154 - * @return void
155 134 */
156 135 protected function init_table_generator() {
157 136 $this->table_generator = new FrmTableHTMLGenerator( 'shortcode' );
158 137 }
@@ -160,10 +139,8 @@
160 139 /**
161 140 * Return the default HTML for an entry
162 141 *
163 142 * @since 2.04
164 - *
165 - * @return array|string
166 143 */
167 144 public function content() {
168 145 if ( ! $this->form_id || empty( $this->fields ) ) {
169 146 return '';
@@ -168,9 +145,9 @@
168 145 if ( ! $this->form_id || empty( $this->fields ) ) {
169 146 return '';
170 147 }
171 148
172 - if ( $this->format === 'array' ) {
149 + if ( $this->format == 'array' ) {
173 150 $content = $this->get_array();
174 151 } elseif ( $this->is_plain_text_format() ) {
175 152 $content = $this->get_plain_text();
176 153 } else {
@@ -183,10 +160,8 @@
183 160 /**
184 161 * Return the default HTML array
185 162 *
186 163 * @since 2.04
187 - *
188 - * @return array
189 164 */
190 165 protected function get_array() {
191 166 foreach ( $this->fields as $field ) {
192 167 $this->add_field_array( $field );
@@ -198,10 +173,8 @@
198 173 /**
199 174 * Return the default plain text for an email message
200 175 *
201 176 * @since 2.04
202 - *
203 - * @return string
204 177 */
205 178 protected function get_plain_text() {
206 179 return $this->generate_content_for_all_fields();
207 180 }
@@ -209,13 +182,11 @@
209 182 /**
210 183 * Return the default HTML for an email message
211 184 *
212 185 * @since 2.04
213 - *
214 - * @return string
215 186 */
216 187 protected function get_table() {
217 - $content = $this->table_generator->generate_table_header();
188 + $content = $this->table_generator->generate_table_header();
218 189 $content .= $this->generate_content_for_all_fields();
219 190 $content .= $this->table_generator->generate_table_footer();
220 191
221 192 return $content;
@@ -262,9 +233,9 @@
262 233 *
263 234 * @since 2.04
264 235 *
265 236 * @param stdClass $field
266 - * @param mixed $value
237 + * @param mixed $value
267 238 *
268 239 * @return string
269 240 */
270 241 protected function generate_two_cell_shortcode_row( $field, $value = null ) {
@@ -296,10 +267,8 @@
296 267 *
297 268 * @since 2.04
298 269 *
299 270 * @param stdClass $field
300 - *
301 - * @return void
302 271 */
303 272 protected function add_field_array( $field ) {
304 273 if ( in_array( $field->type, $this->skip_fields ) ) {
305 274 return;
@@ -313,11 +282,9 @@
313 282 *
314 283 * @since 2.04
315 284 *
316 285 * @param stdClass $field
317 - * @param string $value
318 - *
319 - * @return void
286 + * @param string $value
320 287 */
321 288 protected function add_single_field_array( $field, $value ) {
322 289 $array = array(
323 290 'label' => '[' . $field->id . ' show=field_label]',