| @@ -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 | */ |
| @@ -28,11 +25,10 @@ | ||
| 28 | 25 | |
| 29 | 26 | /** |
| 30 | 27 | * @var string |
| 31 | 28 | * @since 2.04 |
| 32 | - * @since 5.0.16 Changed scope from `private` to `protected`. | |
| 33 | 29 | */ |
| 34 | - protected $direction = 'ltr'; | |
| 30 | + private $direction = 'ltr'; | |
| 35 | 31 | |
| 36 | 32 | /** |
| 37 | 33 | * @var bool |
| 38 | 34 | * @since 2.04 |
| @@ -41,28 +37,18 @@ | ||
| 41 | 37 | |
| 42 | 38 | /** |
| 43 | 39 | * @var string |
| 44 | 40 | * @since 2.04 |
| 45 | - * @since 5.0.16 Changed scope from `private` to `protected`. | |
| 46 | 41 | */ |
| 47 | - protected $table_style = ''; | |
| 42 | + private $table_style = ''; | |
| 48 | 43 | |
| 49 | 44 | /** |
| 50 | 45 | * @var string |
| 51 | 46 | * @since 2.04 |
| 52 | - * @since 5.0.16 Changed scope from `private` to `protected`. | |
| 53 | 47 | */ |
| 54 | - protected $td_style = ''; | |
| 48 | + private $td_style = ''; | |
| 55 | 49 | |
| 56 | 50 | /** |
| 57 | - * Used to add a class in tables. Set in Pro. | |
| 58 | - * | |
| 59 | - * @var bool | |
| 60 | - * @since 5.4.2 | |
| 61 | - */ | |
| 62 | - public $is_child = false; | |
| 63 | - | |
| 64 | - /** | |
| 65 | 51 | * FrmTableHTMLGenerator constructor. |
| 66 | 52 | * |
| 67 | 53 | * @param string $type |
| 68 | 54 | * @param array $atts |
| @@ -82,9 +68,8 @@ | ||
| 82 | 68 | * |
| 83 | 69 | * @since 2.04 |
| 84 | 70 | * |
| 85 | 71 | * @param array $atts |
| 86 | - * @return void | |
| 87 | 72 | */ |
| 88 | 73 | private function init_style_settings( $atts ) { |
| 89 | 74 | $style_settings = array( |
| 90 | 75 | 'border_color' => 'dddddd', |
| @@ -114,9 +99,8 @@ | ||
| 114 | 99 | * |
| 115 | 100 | * @since 2.04 |
| 116 | 101 | * |
| 117 | 102 | * @param array $atts |
| 118 | - * @return void | |
| 119 | 103 | */ |
| 120 | 104 | private function init_use_inline_style( $atts ) { |
| 121 | 105 | if ( isset( $atts['inline_style'] ) && ! $atts['inline_style'] ) { |
| 122 | 106 | $this->use_inline_style = false; |
| @@ -128,9 +112,8 @@ | ||
| 128 | 112 | * |
| 129 | 113 | * @since 2.04 |
| 130 | 114 | * |
| 131 | 115 | * @param array $atts |
| 132 | - * @return void | |
| 133 | 116 | */ |
| 134 | 117 | private function init_direction( $atts ) { |
| 135 | 118 | if ( isset( $atts['direction'] ) && $atts['direction'] === 'rtl' ) { |
| 136 | 119 | $this->direction = 'rtl'; |
| @@ -140,9 +123,8 @@ | ||
| 140 | 123 | /** |
| 141 | 124 | * Set the table_style property |
| 142 | 125 | * |
| 143 | 126 | * @since 2.04 |
| 144 | - * @return void | |
| 145 | 127 | */ |
| 146 | 128 | private function init_table_style() { |
| 147 | 129 | if ( $this->use_inline_style === true ) { |
| 148 | 130 | |
| @@ -159,9 +141,8 @@ | ||
| 159 | 141 | /** |
| 160 | 142 | * Set the td_style property |
| 161 | 143 | * |
| 162 | 144 | * @since 2.04 |
| 163 | - * @return void | |
| 164 | 145 | */ |
| 165 | 146 | private function init_td_style() { |
| 166 | 147 | if ( $this->use_inline_style === true ) { |
| 167 | 148 | |
| @@ -197,10 +178,10 @@ | ||
| 197 | 178 | */ |
| 198 | 179 | private function get_color_markup( $color_markup ) { |
| 199 | 180 | $color_markup = trim( $color_markup ); |
| 200 | 181 | |
| 201 | - // Check if each character in string is valid hex digit | |
| 202 | - if ( FrmAppHelper::ctype_xdigit( $color_markup ) ) { | |
| 182 | + //check if each character in string is valid hex digit | |
| 183 | + if ( ctype_xdigit( $color_markup ) ) { | |
| 203 | 184 | $color_markup = '#' . $color_markup; |
| 204 | 185 | } |
| 205 | 186 | |
| 206 | 187 | return $color_markup; |
| @@ -220,13 +201,12 @@ | ||
| 220 | 201 | /** |
| 221 | 202 | * Get the table row style |
| 222 | 203 | * |
| 223 | 204 | * @since 2.04 |
| 224 | - * @since 5.0.16 Changed scope from `private` to `protected`. | |
| 225 | 205 | * |
| 226 | 206 | * @return string |
| 227 | 207 | */ |
| 228 | - protected function tr_style() { | |
| 208 | + private function tr_style() { | |
| 229 | 209 | |
| 230 | 210 | if ( $this->type === 'shortcode' ) { |
| 231 | 211 | $tr_style = ' style="[frm-alt-color]"'; |
| 232 | 212 | } elseif ( $this->use_inline_style ) { |
| @@ -241,13 +221,10 @@ | ||
| 241 | 221 | /** |
| 242 | 222 | * Switch the odd property from true to false or false to true |
| 243 | 223 | * |
| 244 | 224 | * @since 2.04 |
| 245 | - * @since 5.0.16 Changed scope from `private` to `protected`. | |
| 246 | - * | |
| 247 | - * @return void | |
| 248 | 225 | */ |
| 249 | - protected function switch_odd() { | |
| 226 | + private function switch_odd() { | |
| 250 | 227 | if ( $this->type !== 'shortcode' ) { |
| 251 | 228 | $this->odd = ! $this->odd; |
| 252 | 229 | } |
| 253 | 230 | } |
| @@ -278,29 +255,31 @@ | ||
| 278 | 255 | * Generate a two cell row for an HTML table |
| 279 | 256 | * |
| 280 | 257 | * @since 2.04 |
| 281 | 258 | * |
| 282 | - * @param string $label The label. | |
| 283 | - * @param string $value The value. | |
| 259 | + * @param string $label | |
| 260 | + * @param string $value | |
| 284 | 261 | * |
| 285 | 262 | * @return string |
| 286 | 263 | */ |
| 287 | 264 | public function generate_two_cell_table_row( $label, $value ) { |
| 288 | 265 | $row = '<tr' . $this->tr_style(); |
| 289 | - $row .= $this->add_row_class( $value === '' ); | |
| 266 | + if ( $value === '' ) { | |
| 267 | + $row .= ' class="frm-empty-row"'; | |
| 268 | + } | |
| 290 | 269 | $row .= '>'; |
| 291 | 270 | |
| 292 | - $label = '<th' . $this->td_style . '>' . wp_kses_post( $label ) . '</th>'; | |
| 293 | - $value = '<td' . $this->td_style . '>' . wp_kses_post( $value ) . '</td>'; | |
| 294 | - | |
| 295 | 271 | if ( 'rtl' == $this->direction ) { |
| 296 | - $row .= $value; | |
| 297 | - $row .= $label; | |
| 272 | + $first = $value; | |
| 273 | + $second = $label; | |
| 298 | 274 | } else { |
| 299 | - $row .= $label; | |
| 300 | - $row .= $value; | |
| 275 | + $first = $label; | |
| 276 | + $second = $value; | |
| 301 | 277 | } |
| 302 | 278 | |
| 279 | + $row .= '<td' . $this->td_style . '>' . $first . '</td>'; | |
| 280 | + $row .= '<td' . $this->td_style . '>' . $second . '</td>'; | |
| 281 | + | |
| 303 | 282 | $row .= '</tr>' . "\r\n"; |
| 304 | 283 | |
| 305 | 284 | $this->switch_odd(); |
| 306 | 285 | |
| @@ -316,11 +295,9 @@ | ||
| 316 | 295 | * |
| 317 | 296 | * @return string |
| 318 | 297 | */ |
| 319 | 298 | public function generate_single_cell_table_row( $value ) { |
| 320 | - $row = '<tr' . $this->tr_style(); | |
| 321 | - $row .= $this->add_row_class(); | |
| 322 | - $row .= '>'; | |
| 299 | + $row = '<tr' . $this->tr_style() . '>'; | |
| 323 | 300 | $row .= '<td colspan="2"' . $this->td_style . '>' . $value . '</td>'; |
| 324 | 301 | $row .= '</tr>' . "\r\n"; |
| 325 | 302 | |
| 326 | 303 | $this->switch_odd(); |
| @@ -325,30 +302,6 @@ | ||
| 325 | 302 | |
| 326 | 303 | $this->switch_odd(); |
| 327 | 304 | |
| 328 | 305 | return $row; |
| 329 | - } | |
| 330 | - | |
| 331 | - /** | |
| 332 | - * Add classes to the tr. | |
| 333 | - * | |
| 334 | - * @since 5.4.2 | |
| 335 | - * | |
| 336 | - * @param bool $empty If the value in the row is blank. | |
| 337 | - * | |
| 338 | - * @return string | |
| 339 | - */ | |
| 340 | - protected function add_row_class( $empty = false ) { | |
| 341 | - $class = ''; | |
| 342 | - if ( $empty ) { | |
| 343 | - // Only add this class on two cell rows. | |
| 344 | - $class .= ' frm-empty-row'; | |
| 345 | - } | |
| 346 | - if ( $this->is_child ) { | |
| 347 | - $class .= ' frm-child-row'; | |
| 348 | - } | |
| 349 | - if ( $class ) { | |
| 350 | - $class = ' class="' . trim( $class ) . '"'; | |
| 351 | - } | |
| 352 | - return $class; | |
| 353 | 306 | } |
| 354 | 307 | } |