← All changes
|
classes/views/styles/components/FrmSliderStyleComponent.php
+15
-21
6.26
→
trunk
View file →
| @@ -27,9 +27,8 @@ | ||
| 27 | 27 | * @param mixed $field_value |
| 28 | 28 | * @param array $data |
| 29 | 29 | */ |
| 30 | 30 | public function __construct( $field_name, $field_value, $data ) { |
| 31 | - | |
| 32 | 31 | $this->init_field_data( $data, $field_name, $field_value ); |
| 33 | 32 | |
| 34 | 33 | if ( true === $this->hide_component() ) { |
| 35 | 34 | return; |
| @@ -37,9 +36,9 @@ | ||
| 37 | 36 | |
| 38 | 37 | $this->data['unit_measurement'] = $this->detect_unit_measurement(); |
| 39 | 38 | $this->data['has-multiple-values'] = count( $this->get_values() ) > 1; |
| 40 | 39 | $this->data['units'] = $this->get_units_list( $data ); |
| 41 | - $this->data['value_label'] = empty( $this->detect_unit_measurement() ) ? $field_value : (float) $field_value; | |
| 40 | + $this->data['value_label'] = $this->detect_unit_measurement() ? (float) $field_value : $field_value; | |
| 42 | 41 | |
| 43 | 42 | $this->init_defaults(); |
| 44 | 43 | $this->init_icon(); |
| 45 | 44 | $this->init_multiple_values(); |
| @@ -73,9 +72,9 @@ | ||
| 73 | 72 | * |
| 74 | 73 | * @return void |
| 75 | 74 | */ |
| 76 | 75 | private function init_defaults() { |
| 77 | - $this->data['max_value'] = empty( $this->data['max_value'] ) ? 100 : $this->data['max_value']; | |
| 76 | + $this->data['max_value'] = ! empty( $this->data['max_value'] ) ? $this->data['max_value'] : 100; | |
| 78 | 77 | } |
| 79 | 78 | |
| 80 | 79 | /** |
| 81 | 80 | * Init the slider multiple values data. It works with sliders which has multiple values only: top&bottom and left&right. |
| @@ -82,9 +81,9 @@ | ||
| 82 | 81 | * This is used for cases when there are 4 sliders in the same field. |
| 83 | 82 | * |
| 84 | 83 | * @since 6.14 |
| 85 | 84 | * |
| 86 | - * @return array | |
| 85 | + * @return void | |
| 87 | 86 | */ |
| 88 | 87 | private function init_multiple_values() { |
| 89 | 88 | if ( ! $this->data['has-multiple-values'] ) { |
| 90 | 89 | return; |
| @@ -91,40 +90,40 @@ | ||
| 91 | 90 | } |
| 92 | 91 | |
| 93 | 92 | $values = $this->get_values(); |
| 94 | 93 | $top = $values[0]; |
| 95 | - $bottom = empty( $values[2] ) ? $values[0] : $values[2]; | |
| 96 | - $left = empty( $values[3] ) ? $values[1] : $values[3]; | |
| 94 | + $bottom = ! empty( $values[2] ) ? $values[2] : $values[0]; | |
| 95 | + $left = ! empty( $values[3] ) ? $values[3] : $values[1]; | |
| 97 | 96 | $right = $values[1]; |
| 98 | 97 | |
| 99 | 98 | $this->data['vertical'] = array( |
| 100 | 99 | 'unit' => $this->detect_unit_measurement( $top ), |
| 101 | - 'value' => empty( $this->detect_unit_measurement( $top ) ) ? $top : (float) $top, | |
| 100 | + 'value' => $this->detect_unit_measurement( $top ) ? (float) $top : $top, | |
| 102 | 101 | ); |
| 103 | 102 | |
| 104 | 103 | $this->data['horizontal'] = array( |
| 105 | 104 | 'unit' => $this->detect_unit_measurement( $right ), |
| 106 | - 'value' => empty( $this->detect_unit_measurement( $right ) ) ? $right : (float) $right, | |
| 105 | + 'value' => $this->detect_unit_measurement( $right ) ? (float) $right : $right, | |
| 107 | 106 | ); |
| 108 | 107 | |
| 109 | 108 | $this->data['top'] = array( |
| 110 | 109 | 'unit' => $this->detect_unit_measurement( $top ), |
| 111 | - 'value' => empty( $this->detect_unit_measurement( $top ) ) ? $top : (float) $top, | |
| 110 | + 'value' => $this->detect_unit_measurement( $top ) ? (float) $top : $top, | |
| 112 | 111 | ); |
| 113 | 112 | |
| 114 | 113 | $this->data['bottom'] = array( |
| 115 | 114 | 'unit' => $this->detect_unit_measurement( $bottom ), |
| 116 | - 'value' => empty( $this->detect_unit_measurement( $bottom ) ) ? $bottom : (float) $bottom, | |
| 115 | + 'value' => $this->detect_unit_measurement( $bottom ) ? (float) $bottom : $bottom, | |
| 117 | 116 | ); |
| 118 | 117 | |
| 119 | 118 | $this->data['left'] = array( |
| 120 | 119 | 'unit' => $this->detect_unit_measurement( $left ), |
| 121 | - 'value' => empty( $this->detect_unit_measurement( $left ) ) ? $left : (float) $left, | |
| 120 | + 'value' => $this->detect_unit_measurement( $left ) ? (float) $left : $left, | |
| 122 | 121 | ); |
| 123 | 122 | |
| 124 | 123 | $this->data['right'] = array( |
| 125 | 124 | 'unit' => $this->detect_unit_measurement( $right ), |
| 126 | - 'value' => empty( $this->detect_unit_measurement( $right ) ) ? $right : (float) $right, | |
| 125 | + 'value' => $this->detect_unit_measurement( $right ) ? (float) $right : $right, | |
| 127 | 126 | ); |
| 128 | 127 | } |
| 129 | 128 | |
| 130 | 129 | /** |
| @@ -161,13 +160,9 @@ | ||
| 161 | 160 | if ( preg_match( '/em$/', $value ) ) { |
| 162 | 161 | return 'em'; |
| 163 | 162 | } |
| 164 | 163 | |
| 165 | - if ( preg_match( '/px$/', $value ) ) { | |
| 166 | - return 'px'; | |
| 167 | - } | |
| 168 | - | |
| 169 | - return ''; | |
| 164 | + return preg_match( '/px$/', $value ) ? 'px' : ''; | |
| 170 | 165 | } |
| 171 | 166 | |
| 172 | 167 | /** |
| 173 | 168 | * Init the field icon |
| @@ -173,12 +168,11 @@ | ||
| 173 | 168 | * Init the field icon |
| 174 | 169 | * |
| 175 | 170 | * @since 6.14 |
| 176 | 171 | * |
| 177 | - * @return array | |
| 172 | + * @return void | |
| 178 | 173 | */ |
| 179 | 174 | private function init_icon() { |
| 180 | - | |
| 181 | 175 | if ( ! empty( $this->data['icon'] ) ) { |
| 182 | 176 | return; |
| 183 | 177 | } |
| 184 | 178 | |
| @@ -188,13 +182,13 @@ | ||
| 188 | 182 | } |
| 189 | 183 | |
| 190 | 184 | switch ( $this->data['type'] ) { |
| 191 | 185 | case 'vertical-margin': |
| 192 | - $this->data['icon'] = 'frm_icon_font frm-margin-top-bottom'; | |
| 186 | + $this->data['icon'] = 'frmfont frm-margin-top-bottom'; | |
| 193 | 187 | return; |
| 194 | 188 | |
| 195 | 189 | case 'horizontal-margin': |
| 196 | - $this->data['icon'] = 'frm_icon_font frm-margin-left-right'; | |
| 190 | + $this->data['icon'] = 'frmfont frm-margin-left-right'; | |
| 197 | 191 | return; |
| 198 | 192 | |
| 199 | 193 | default: |
| 200 | 194 | $this->data['icon'] = ''; |