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