| @@ -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 | */ |
| @@ -44,12 +41,12 @@ | ||
| 44 | 41 | */ |
| 45 | 42 | protected $format = 'text'; |
| 46 | 43 | |
| 47 | 44 | /** |
| 48 | - * @var FrmTableHTMLGenerator|null | |
| 45 | + * @var FrmTableHTMLGenerator | |
| 49 | 46 | * @since 2.04 |
| 50 | 47 | */ |
| 51 | - protected $table_generator; | |
| 48 | + protected $table_generator = null; | |
| 52 | 49 | |
| 53 | 50 | /** |
| 54 | 51 | * @var array |
| 55 | 52 | * @since 2.04 |
| @@ -59,9 +56,9 @@ | ||
| 59 | 56 | /** |
| 60 | 57 | * FrmEntryShortcodeFormatter constructor |
| 61 | 58 | * |
| 62 | 59 | * @param int|string $form_id |
| 63 | - * @param array $atts | |
| 60 | + * @param array $atts | |
| 64 | 61 | */ |
| 65 | 62 | public function __construct( $form_id, $atts ) { |
| 66 | 63 | if ( ! $form_id ) { |
| 67 | 64 | return; |
| @@ -86,11 +83,9 @@ | ||
| 86 | 83 | * Initialize the form_id property |
| 87 | 84 | * |
| 88 | 85 | * @since 2.04 |
| 89 | 86 | * |
| 90 | - * @param int|string $form_id | |
| 91 | - * | |
| 92 | - * @return void | |
| 87 | + * @param $form_id | |
| 93 | 88 | */ |
| 94 | 89 | protected function init_form_id( $form_id ) { |
| 95 | 90 | $this->form_id = (int) $form_id; |
| 96 | 91 | } |
| @@ -98,10 +93,8 @@ | ||
| 98 | 93 | /** |
| 99 | 94 | * Initialize the fields property |
| 100 | 95 | * |
| 101 | 96 | * @since 2.04 |
| 102 | - * | |
| 103 | - * @return void | |
| 104 | 97 | */ |
| 105 | 98 | protected function init_fields() { |
| 106 | 99 | $this->fields = FrmField::get_all_for_form( $this->form_id, '', 'exclude', 'exclude' ); |
| 107 | 100 | } |
| @@ -111,10 +104,8 @@ | ||
| 111 | 104 | * |
| 112 | 105 | * @since 2.05 |
| 113 | 106 | * |
| 114 | 107 | * @param array $atts |
| 115 | - * | |
| 116 | - * @return void | |
| 117 | 108 | */ |
| 118 | 109 | protected function init_plain_text( $atts ) { |
| 119 | 110 | if ( isset( $atts['plain_text'] ) && $atts['plain_text'] ) { |
| 120 | 111 | $this->is_plain_text = true; |
| @@ -126,10 +117,8 @@ | ||
| 126 | 117 | * |
| 127 | 118 | * @since 2.04 |
| 128 | 119 | * |
| 129 | 120 | * @param array $atts |
| 130 | - * | |
| 131 | - * @return void | |
| 132 | 121 | */ |
| 133 | 122 | protected function init_format( $atts ) { |
| 134 | 123 | if ( isset( $atts['format'] ) && is_string( $atts['format'] ) && $atts['format'] !== '' ) { |
| 135 | 124 | $this->format = $atts['format']; |
| @@ -141,10 +130,8 @@ | ||
| 141 | 130 | /** |
| 142 | 131 | * Initialize the table_generator property |
| 143 | 132 | * |
| 144 | 133 | * @since 2.04 |
| 145 | - * | |
| 146 | - * @return void | |
| 147 | 134 | */ |
| 148 | 135 | protected function init_table_generator() { |
| 149 | 136 | $this->table_generator = new FrmTableHTMLGenerator( 'shortcode' ); |
| 150 | 137 | } |
| @@ -158,9 +145,9 @@ | ||
| 158 | 145 | if ( ! $this->form_id || empty( $this->fields ) ) { |
| 159 | 146 | return ''; |
| 160 | 147 | } |
| 161 | 148 | |
| 162 | - if ( $this->format === 'array' ) { | |
| 149 | + if ( $this->format == 'array' ) { | |
| 163 | 150 | $content = $this->get_array(); |
| 164 | 151 | } elseif ( $this->is_plain_text_format() ) { |
| 165 | 152 | $content = $this->get_plain_text(); |
| 166 | 153 | } else { |
| @@ -173,10 +160,8 @@ | ||
| 173 | 160 | /** |
| 174 | 161 | * Return the default HTML array |
| 175 | 162 | * |
| 176 | 163 | * @since 2.04 |
| 177 | - * | |
| 178 | - * @return array | |
| 179 | 164 | */ |
| 180 | 165 | protected function get_array() { |
| 181 | 166 | foreach ( $this->fields as $field ) { |
| 182 | 167 | $this->add_field_array( $field ); |
| @@ -188,10 +173,8 @@ | ||
| 188 | 173 | /** |
| 189 | 174 | * Return the default plain text for an email message |
| 190 | 175 | * |
| 191 | 176 | * @since 2.04 |
| 192 | - * | |
| 193 | - * @return string | |
| 194 | 177 | */ |
| 195 | 178 | protected function get_plain_text() { |
| 196 | 179 | return $this->generate_content_for_all_fields(); |
| 197 | 180 | } |
| @@ -199,13 +182,11 @@ | ||
| 199 | 182 | /** |
| 200 | 183 | * Return the default HTML for an email message |
| 201 | 184 | * |
| 202 | 185 | * @since 2.04 |
| 203 | - * | |
| 204 | - * @return string | |
| 205 | 186 | */ |
| 206 | 187 | protected function get_table() { |
| 207 | - $content = $this->table_generator->generate_table_header(); | |
| 188 | + $content = $this->table_generator->generate_table_header(); | |
| 208 | 189 | $content .= $this->generate_content_for_all_fields(); |
| 209 | 190 | $content .= $this->table_generator->generate_table_footer(); |
| 210 | 191 | |
| 211 | 192 | return $content; |
| @@ -252,9 +233,9 @@ | ||
| 252 | 233 | * |
| 253 | 234 | * @since 2.04 |
| 254 | 235 | * |
| 255 | 236 | * @param stdClass $field |
| 256 | - * @param mixed $value | |
| 237 | + * @param mixed $value | |
| 257 | 238 | * |
| 258 | 239 | * @return string |
| 259 | 240 | */ |
| 260 | 241 | protected function generate_two_cell_shortcode_row( $field, $value = null ) { |
| @@ -286,10 +267,8 @@ | ||
| 286 | 267 | * |
| 287 | 268 | * @since 2.04 |
| 288 | 269 | * |
| 289 | 270 | * @param stdClass $field |
| 290 | - * | |
| 291 | - * @return void | |
| 292 | 271 | */ |
| 293 | 272 | protected function add_field_array( $field ) { |
| 294 | 273 | if ( in_array( $field->type, $this->skip_fields ) ) { |
| 295 | 274 | return; |
| @@ -303,11 +282,9 @@ | ||
| 303 | 282 | * |
| 304 | 283 | * @since 2.04 |
| 305 | 284 | * |
| 306 | 285 | * @param stdClass $field |
| 307 | - * @param string $value | |
| 308 | - * | |
| 309 | - * @return void | |
| 286 | + * @param string $value | |
| 310 | 287 | */ |
| 311 | 288 | protected function add_single_field_array( $field, $value ) { |
| 312 | 289 | $array = array( |
| 313 | 290 | 'label' => '[' . $field->id . ' show=field_label]', |