| @@ -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,26 +37,17 @@ | ||
| 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 | - /** | |
| 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 | 50 | |
| 64 | 51 | /** |
| 65 | 52 | * FrmTableHTMLGenerator constructor. |
| 66 | 53 | * |
| @@ -74,8 +61,9 @@ | ||
| 74 | 61 | $this->init_use_inline_style( $atts ); |
| 75 | 62 | $this->init_direction( $atts ); |
| 76 | 63 | $this->init_table_style(); |
| 77 | 64 | $this->init_td_style(); |
| 65 | + | |
| 78 | 66 | } |
| 79 | 67 | |
| 80 | 68 | /** |
| 81 | 69 | * Set the style_settings property |
| @@ -82,12 +70,11 @@ | ||
| 82 | 70 | * |
| 83 | 71 | * @since 2.04 |
| 84 | 72 | * |
| 85 | 73 | * @param array $atts |
| 86 | - * @return void | |
| 87 | 74 | */ |
| 88 | 75 | private function init_style_settings( $atts ) { |
| 89 | - $style_settings = array( | |
| 76 | + $style_settings = array( | |
| 90 | 77 | 'border_color' => 'dddddd', |
| 91 | 78 | 'bg_color' => 'f7f7f7', |
| 92 | 79 | 'text_color' => '444444', |
| 93 | 80 | 'font_size' => '12px', |
| @@ -104,10 +91,8 @@ | ||
| 104 | 91 | if ( $this->is_color_setting( $key ) ) { |
| 105 | 92 | $this->style_settings[ $key ] = $this->get_color_markup( $this->style_settings[ $key ] ); |
| 106 | 93 | } |
| 107 | 94 | } |
| 108 | - | |
| 109 | - $this->style_settings['class'] = isset( $atts['class'] ) ? $atts['class'] : ''; | |
| 110 | 95 | } |
| 111 | 96 | |
| 112 | 97 | /** |
| 113 | 98 | * Set the use_inline_style property |
| @@ -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 | |
| @@ -149,12 +131,8 @@ | ||
| 149 | 131 | $this->table_style = ' style="' . esc_attr( 'font-size:' . $this->style_settings['font_size'] . ';line-height:135%;' ); |
| 150 | 132 | $this->table_style .= esc_attr( 'border-bottom:' . $this->style_settings['border_width'] . ' solid ' . $this->style_settings['border_color'] . ';' ) . '"'; |
| 151 | 133 | |
| 152 | 134 | } |
| 153 | - | |
| 154 | - if ( ! empty( $this->style_settings['class'] ) ) { | |
| 155 | - $this->table_style .= ' class="' . esc_attr( $this->style_settings['class'] ) . '"'; | |
| 156 | - } | |
| 157 | 135 | } |
| 158 | 136 | |
| 159 | 137 | /** |
| 160 | 138 | * Set the td_style property |
| @@ -159,9 +137,8 @@ | ||
| 159 | 137 | /** |
| 160 | 138 | * Set the td_style property |
| 161 | 139 | * |
| 162 | 140 | * @since 2.04 |
| 163 | - * @return void | |
| 164 | 141 | */ |
| 165 | 142 | private function init_td_style() { |
| 166 | 143 | if ( $this->use_inline_style === true ) { |
| 167 | 144 | |
| @@ -197,10 +174,10 @@ | ||
| 197 | 174 | */ |
| 198 | 175 | private function get_color_markup( $color_markup ) { |
| 199 | 176 | $color_markup = trim( $color_markup ); |
| 200 | 177 | |
| 201 | - // Check if each character in string is valid hex digit | |
| 202 | - if ( FrmAppHelper::ctype_xdigit( $color_markup ) ) { | |
| 178 | + //check if each character in string is valid hex digit | |
| 179 | + if ( ctype_xdigit( $color_markup ) ) { | |
| 203 | 180 | $color_markup = '#' . $color_markup; |
| 204 | 181 | } |
| 205 | 182 | |
| 206 | 183 | return $color_markup; |
| @@ -220,17 +197,16 @@ | ||
| 220 | 197 | /** |
| 221 | 198 | * Get the table row style |
| 222 | 199 | * |
| 223 | 200 | * @since 2.04 |
| 224 | - * @since 5.0.16 Changed scope from `private` to `protected`. | |
| 225 | 201 | * |
| 226 | 202 | * @return string |
| 227 | 203 | */ |
| 228 | - protected function tr_style() { | |
| 204 | + private function tr_style() { | |
| 229 | 205 | |
| 230 | 206 | if ( $this->type === 'shortcode' ) { |
| 231 | 207 | $tr_style = ' style="[frm-alt-color]"'; |
| 232 | - } elseif ( $this->use_inline_style ) { | |
| 208 | + } else if ( $this->use_inline_style ) { | |
| 233 | 209 | $tr_style = ' style="background-color:' . $this->table_row_background_color() . ';"'; |
| 234 | 210 | } else { |
| 235 | 211 | $tr_style = ''; |
| 236 | 212 | } |
| @@ -241,13 +217,10 @@ | ||
| 241 | 217 | /** |
| 242 | 218 | * Switch the odd property from true to false or false to true |
| 243 | 219 | * |
| 244 | 220 | * @since 2.04 |
| 245 | - * @since 5.0.16 Changed scope from `private` to `protected`. | |
| 246 | - * | |
| 247 | - * @return void | |
| 248 | 221 | */ |
| 249 | - protected function switch_odd() { | |
| 222 | + private function switch_odd() { | |
| 250 | 223 | if ( $this->type !== 'shortcode' ) { |
| 251 | 224 | $this->odd = ! $this->odd; |
| 252 | 225 | } |
| 253 | 226 | } |
| @@ -278,29 +251,27 @@ | ||
| 278 | 251 | * Generate a two cell row for an HTML table |
| 279 | 252 | * |
| 280 | 253 | * @since 2.04 |
| 281 | 254 | * |
| 282 | - * @param string $label The label. | |
| 283 | - * @param string $value The value. | |
| 255 | + * @param string $label | |
| 256 | + * @param string $value | |
| 284 | 257 | * |
| 285 | 258 | * @return string |
| 286 | 259 | */ |
| 287 | 260 | public function generate_two_cell_table_row( $label, $value ) { |
| 288 | - $row = '<tr' . $this->tr_style(); | |
| 289 | - $row .= $this->add_row_class( $value === '' ); | |
| 290 | - $row .= '>'; | |
| 261 | + $row = '<tr' . $this->tr_style() . '>'; | |
| 291 | 262 | |
| 292 | - $label = '<th' . $this->td_style . '>' . wp_kses_post( $label ) . '</th>'; | |
| 293 | - $value = '<td' . $this->td_style . '>' . wp_kses_post( $value ) . '</td>'; | |
| 294 | - | |
| 295 | 263 | if ( 'rtl' == $this->direction ) { |
| 296 | - $row .= $value; | |
| 297 | - $row .= $label; | |
| 264 | + $first = $value; | |
| 265 | + $second = $label; | |
| 298 | 266 | } else { |
| 299 | - $row .= $label; | |
| 300 | - $row .= $value; | |
| 267 | + $first = $label; | |
| 268 | + $second = $value; | |
| 301 | 269 | } |
| 302 | 270 | |
| 271 | + $row .= '<td' . $this->td_style . '>' . $first . '</td>'; | |
| 272 | + $row .= '<td' . $this->td_style . '>' . $second . '</td>'; | |
| 273 | + | |
| 303 | 274 | $row .= '</tr>' . "\r\n"; |
| 304 | 275 | |
| 305 | 276 | $this->switch_odd(); |
| 306 | 277 | |
| @@ -316,11 +287,9 @@ | ||
| 316 | 287 | * |
| 317 | 288 | * @return string |
| 318 | 289 | */ |
| 319 | 290 | public function generate_single_cell_table_row( $value ) { |
| 320 | - $row = '<tr' . $this->tr_style(); | |
| 321 | - $row .= $this->add_row_class(); | |
| 322 | - $row .= '>'; | |
| 291 | + $row = '<tr' . $this->tr_style() . '>'; | |
| 323 | 292 | $row .= '<td colspan="2"' . $this->td_style . '>' . $value . '</td>'; |
| 324 | 293 | $row .= '</tr>' . "\r\n"; |
| 325 | 294 | |
| 326 | 295 | $this->switch_odd(); |
| @@ -325,30 +294,6 @@ | ||
| 325 | 294 | |
| 326 | 295 | $this->switch_odd(); |
| 327 | 296 | |
| 328 | 297 | 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 | 298 | } |
| 354 | 299 | } |