| @@ -102,9 +102,9 @@ | ||
| 102 | 102 | $default_fonts = ', ' . $default_fonts; |
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | $fields['font_family'] = [ |
| 106 | - 'label' => esc_html_x( 'Family', 'Typography Control', 'elementor' ), | |
| 106 | + 'label' => _x( 'Family', 'Typography Control', 'elementor' ), | |
| 107 | 107 | 'type' => Controls_Manager::FONT, |
| 108 | 108 | 'default' => '', |
| 109 | 109 | 'selector_value' => 'font-family: "{{VALUE}}"' . $default_fonts . ';', |
| 110 | 110 | ]; |
| @@ -109,22 +109,16 @@ | ||
| 109 | 109 | 'selector_value' => 'font-family: "{{VALUE}}"' . $default_fonts . ';', |
| 110 | 110 | ]; |
| 111 | 111 | |
| 112 | 112 | $fields['font_size'] = [ |
| 113 | - 'label' => esc_html_x( 'Size', 'Typography Control', 'elementor' ), | |
| 113 | + 'label' => _x( 'Size', 'Typography Control', 'elementor' ), | |
| 114 | 114 | 'type' => Controls_Manager::SLIDER, |
| 115 | - 'size_units' => [ 'px', 'em', 'rem', 'vw', 'custom' ], | |
| 115 | + 'size_units' => [ 'px', 'em', 'rem', 'vw' ], | |
| 116 | 116 | 'range' => [ |
| 117 | 117 | 'px' => [ |
| 118 | 118 | 'min' => 1, |
| 119 | 119 | 'max' => 200, |
| 120 | 120 | ], |
| 121 | - 'em' => [ | |
| 122 | - 'max' => 20, | |
| 123 | - ], | |
| 124 | - 'rem' => [ | |
| 125 | - 'max' => 20, | |
| 126 | - ], | |
| 127 | 121 | 'vw' => [ |
| 128 | 122 | 'min' => 0.1, |
| 129 | 123 | 'max' => 10, |
| 130 | 124 | 'step' => 0.1, |
| @@ -133,70 +127,63 @@ | ||
| 133 | 127 | 'responsive' => true, |
| 134 | 128 | 'selector_value' => 'font-size: {{SIZE}}{{UNIT}}', |
| 135 | 129 | ]; |
| 136 | 130 | |
| 131 | + $typo_weight_options = [ | |
| 132 | + '' => __( 'Default', 'elementor' ), | |
| 133 | + ]; | |
| 134 | + | |
| 135 | + foreach ( array_merge( [ 'normal', 'bold' ], range( 100, 900, 100 ) ) as $weight ) { | |
| 136 | + $typo_weight_options[ $weight ] = ucfirst( $weight ); | |
| 137 | + } | |
| 138 | + | |
| 137 | 139 | $fields['font_weight'] = [ |
| 138 | - 'label' => esc_html_x( 'Weight', 'Typography Control', 'elementor' ), | |
| 140 | + 'label' => _x( 'Weight', 'Typography Control', 'elementor' ), | |
| 139 | 141 | 'type' => Controls_Manager::SELECT, |
| 140 | 142 | 'default' => '', |
| 141 | - 'options' => [ | |
| 142 | - '100' => '100 ' . esc_html_x( '(Thin)', 'Typography Control', 'elementor' ), | |
| 143 | - '200' => '200 ' . esc_html_x( '(Extra Light)', 'Typography Control', 'elementor' ), | |
| 144 | - '300' => '300 ' . esc_html_x( '(Light)', 'Typography Control', 'elementor' ), | |
| 145 | - '400' => '400 ' . esc_html_x( '(Normal)', 'Typography Control', 'elementor' ), | |
| 146 | - '500' => '500 ' . esc_html_x( '(Medium)', 'Typography Control', 'elementor' ), | |
| 147 | - '600' => '600 ' . esc_html_x( '(Semi Bold)', 'Typography Control', 'elementor' ), | |
| 148 | - '700' => '700 ' . esc_html_x( '(Bold)', 'Typography Control', 'elementor' ), | |
| 149 | - '800' => '800 ' . esc_html_x( '(Extra Bold)', 'Typography Control', 'elementor' ), | |
| 150 | - '900' => '900 ' . esc_html_x( '(Black)', 'Typography Control', 'elementor' ), | |
| 151 | - '' => esc_html__( 'Default', 'elementor' ), | |
| 152 | - 'normal' => esc_html__( 'Normal', 'elementor' ), | |
| 153 | - 'bold' => esc_html__( 'Bold', 'elementor' ), | |
| 154 | - ], | |
| 143 | + 'options' => $typo_weight_options, | |
| 155 | 144 | ]; |
| 156 | 145 | |
| 157 | - $fields = $this->add_font_variables_fields( $fields ); | |
| 158 | - | |
| 159 | 146 | $fields['text_transform'] = [ |
| 160 | - 'label' => esc_html_x( 'Transform', 'Typography Control', 'elementor' ), | |
| 147 | + 'label' => _x( 'Transform', 'Typography Control', 'elementor' ), | |
| 161 | 148 | 'type' => Controls_Manager::SELECT, |
| 162 | 149 | 'default' => '', |
| 163 | 150 | 'options' => [ |
| 164 | - '' => esc_html__( 'Default', 'elementor' ), | |
| 165 | - 'uppercase' => esc_html_x( 'Uppercase', 'Typography Control', 'elementor' ), | |
| 166 | - 'lowercase' => esc_html_x( 'Lowercase', 'Typography Control', 'elementor' ), | |
| 167 | - 'capitalize' => esc_html_x( 'Capitalize', 'Typography Control', 'elementor' ), | |
| 168 | - 'none' => esc_html__( 'Normal', 'elementor' ), | |
| 151 | + '' => __( 'Default', 'elementor' ), | |
| 152 | + 'uppercase' => _x( 'Uppercase', 'Typography Control', 'elementor' ), | |
| 153 | + 'lowercase' => _x( 'Lowercase', 'Typography Control', 'elementor' ), | |
| 154 | + 'capitalize' => _x( 'Capitalize', 'Typography Control', 'elementor' ), | |
| 155 | + 'none' => _x( 'Normal', 'Typography Control', 'elementor' ), | |
| 169 | 156 | ], |
| 170 | 157 | ]; |
| 171 | 158 | |
| 172 | 159 | $fields['font_style'] = [ |
| 173 | - 'label' => esc_html_x( 'Style', 'Typography Control', 'elementor' ), | |
| 160 | + 'label' => _x( 'Style', 'Typography Control', 'elementor' ), | |
| 174 | 161 | 'type' => Controls_Manager::SELECT, |
| 175 | 162 | 'default' => '', |
| 176 | 163 | 'options' => [ |
| 177 | - '' => esc_html__( 'Default', 'elementor' ), | |
| 178 | - 'normal' => esc_html__( 'Normal', 'elementor' ), | |
| 179 | - 'italic' => esc_html_x( 'Italic', 'Typography Control', 'elementor' ), | |
| 180 | - 'oblique' => esc_html_x( 'Oblique', 'Typography Control', 'elementor' ), | |
| 164 | + '' => __( 'Default', 'elementor' ), | |
| 165 | + 'normal' => _x( 'Normal', 'Typography Control', 'elementor' ), | |
| 166 | + 'italic' => _x( 'Italic', 'Typography Control', 'elementor' ), | |
| 167 | + 'oblique' => _x( 'Oblique', 'Typography Control', 'elementor' ), | |
| 181 | 168 | ], |
| 182 | 169 | ]; |
| 183 | 170 | |
| 184 | 171 | $fields['text_decoration'] = [ |
| 185 | - 'label' => esc_html_x( 'Decoration', 'Typography Control', 'elementor' ), | |
| 172 | + 'label' => _x( 'Decoration', 'Typography Control', 'elementor' ), | |
| 186 | 173 | 'type' => Controls_Manager::SELECT, |
| 187 | 174 | 'default' => '', |
| 188 | 175 | 'options' => [ |
| 189 | - '' => esc_html__( 'Default', 'elementor' ), | |
| 190 | - 'underline' => esc_html_x( 'Underline', 'Typography Control', 'elementor' ), | |
| 191 | - 'overline' => esc_html_x( 'Overline', 'Typography Control', 'elementor' ), | |
| 192 | - 'line-through' => esc_html_x( 'Line Through', 'Typography Control', 'elementor' ), | |
| 193 | - 'none' => esc_html__( 'None', 'elementor' ), | |
| 176 | + '' => __( 'Default', 'elementor' ), | |
| 177 | + 'underline' => _x( 'Underline', 'Typography Control', 'elementor' ), | |
| 178 | + 'overline' => _x( 'Overline', 'Typography Control', 'elementor' ), | |
| 179 | + 'line-through' => _x( 'Line Through', 'Typography Control', 'elementor' ), | |
| 180 | + 'none' => _x( 'None', 'Typography Control', 'elementor' ), | |
| 194 | 181 | ], |
| 195 | 182 | ]; |
| 196 | 183 | |
| 197 | 184 | $fields['line_height'] = [ |
| 198 | - 'label' => esc_html__( 'Line Height', 'elementor' ), | |
| 185 | + 'label' => _x( 'Line-Height', 'Typography Control', 'elementor' ), | |
| 199 | 186 | 'type' => Controls_Manager::SLIDER, |
| 200 | 187 | 'desktop_default' => [ |
| 201 | 188 | 'unit' => 'em', |
| 202 | 189 | ], |
| @@ -211,16 +198,15 @@ | ||
| 211 | 198 | 'min' => 1, |
| 212 | 199 | ], |
| 213 | 200 | ], |
| 214 | 201 | 'responsive' => true, |
| 215 | - 'size_units' => [ 'px', 'em', 'rem', 'lh', 'rlh', 'custom' ], | |
| 202 | + 'size_units' => [ 'px', 'em' ], | |
| 216 | 203 | 'selector_value' => 'line-height: {{SIZE}}{{UNIT}}', |
| 217 | 204 | ]; |
| 218 | 205 | |
| 219 | 206 | $fields['letter_spacing'] = [ |
| 220 | - 'label' => esc_html__( 'Letter Spacing', 'elementor' ), | |
| 207 | + 'label' => _x( 'Letter Spacing', 'Typography Control', 'elementor' ), | |
| 221 | 208 | 'type' => Controls_Manager::SLIDER, |
| 222 | - 'size_units' => [ 'px', 'em', 'rem', 'custom' ], | |
| 223 | 209 | 'range' => [ |
| 224 | 210 | 'px' => [ |
| 225 | 211 | 'min' => -5, |
| 226 | 212 | 'max' => 10, |
| @@ -225,137 +211,16 @@ | ||
| 225 | 211 | 'min' => -5, |
| 226 | 212 | 'max' => 10, |
| 227 | 213 | 'step' => 0.1, |
| 228 | 214 | ], |
| 229 | - 'em' => [ | |
| 230 | - 'min' => 0, | |
| 231 | - 'max' => 1, | |
| 232 | - 'step' => 0.01, | |
| 233 | - ], | |
| 234 | - 'rem' => [ | |
| 235 | - 'min' => 0, | |
| 236 | - 'max' => 1, | |
| 237 | - 'step' => 0.01, | |
| 238 | - ], | |
| 239 | 215 | ], |
| 240 | 216 | 'responsive' => true, |
| 241 | 217 | 'selector_value' => 'letter-spacing: {{SIZE}}{{UNIT}}', |
| 242 | 218 | ]; |
| 243 | 219 | |
| 244 | - $fields['word_spacing'] = [ | |
| 245 | - 'label' => esc_html__( 'Word Spacing', 'elementor' ), | |
| 246 | - 'type' => Controls_Manager::SLIDER, | |
| 247 | - 'size_units' => [ 'px', 'em', 'rem', 'custom' ], | |
| 248 | - 'range' => [ | |
| 249 | - 'px' => [ | |
| 250 | - 'max' => 50, | |
| 251 | - ], | |
| 252 | - 'em' => [ | |
| 253 | - 'min' => 0, | |
| 254 | - 'max' => 5, | |
| 255 | - ], | |
| 256 | - 'rem' => [ | |
| 257 | - 'min' => 0, | |
| 258 | - 'max' => 5, | |
| 259 | - ], | |
| 260 | - ], | |
| 261 | - 'desktop_default' => [ | |
| 262 | - 'unit' => 'em', | |
| 263 | - ], | |
| 264 | - 'tablet_default' => [ | |
| 265 | - 'unit' => 'em', | |
| 266 | - ], | |
| 267 | - 'mobile_default' => [ | |
| 268 | - 'unit' => 'em', | |
| 269 | - ], | |
| 270 | - 'responsive' => true, | |
| 271 | - 'selector_value' => 'word-spacing: {{SIZE}}{{UNIT}}', | |
| 272 | - ]; | |
| 273 | - | |
| 274 | 220 | return $fields; |
| 275 | 221 | } |
| 276 | 222 | |
| 277 | - private function add_font_variables_fields( $fields ): array { | |
| 278 | - $font_variables = $this->get_font_variables(); | |
| 279 | - | |
| 280 | - if ( empty( $font_variables ) ) { | |
| 281 | - return $fields; | |
| 282 | - } | |
| 283 | - | |
| 284 | - $font_variables_conditions = [ | |
| 285 | - 'weight' => [], | |
| 286 | - 'width' => [], | |
| 287 | - ]; | |
| 288 | - | |
| 289 | - foreach ( $font_variables as $font => $variables ) { | |
| 290 | - foreach ( array_keys( $font_variables_conditions ) as $variable ) { | |
| 291 | - if ( in_array( $variable, $variables ) ) { | |
| 292 | - $font_variables_conditions[ $variable ][] = $font; | |
| 293 | - } | |
| 294 | - } | |
| 295 | - } | |
| 296 | - | |
| 297 | - if ( ! empty( $font_variables_conditions['weight'] ) ) { | |
| 298 | - $fields['weight'] = [ | |
| 299 | - 'label' => esc_html_x( 'Weight', 'Typography Control', 'elementor' ), | |
| 300 | - 'type' => Controls_Manager::SLIDER, | |
| 301 | - 'range' => [ | |
| 302 | - 'px' => [ | |
| 303 | - 'min' => 1, | |
| 304 | - 'max' => 1000, | |
| 305 | - ], | |
| 306 | - ], | |
| 307 | - 'condition' => [ | |
| 308 | - 'font_family' => $font_variables_conditions['weight'], | |
| 309 | - ], | |
| 310 | - 'responsive' => true, | |
| 311 | - 'selector_value' => 'font-weight: {{SIZE}};', | |
| 312 | - ]; | |
| 313 | - | |
| 314 | - $fields['font_weight']['condition'] = [ | |
| 315 | - 'font_family!' => $font_variables_conditions['weight'], | |
| 316 | - ]; | |
| 317 | - } | |
| 318 | - | |
| 319 | - if ( ! empty( $font_variables_conditions['width'] ) ) { | |
| 320 | - $fields['width'] = [ | |
| 321 | - 'label' => esc_html_x( 'Width', 'Typography Control', 'elementor' ), | |
| 322 | - 'type' => Controls_Manager::SLIDER, | |
| 323 | - 'range' => [ | |
| 324 | - 'px' => [ | |
| 325 | - 'min' => 0, | |
| 326 | - 'max' => 150, | |
| 327 | - ], | |
| 328 | - ], | |
| 329 | - 'condition' => [ | |
| 330 | - 'font_family' => $font_variables_conditions['width'], | |
| 331 | - ], | |
| 332 | - 'responsive' => true, | |
| 333 | - 'selector_value' => 'font-stretch: {{SIZE}}%;', | |
| 334 | - ]; | |
| 335 | - } | |
| 336 | - | |
| 337 | - $fields['font_style']['condition'] = [ | |
| 338 | - 'font_family!' => array_keys( $font_variables ), | |
| 339 | - ]; | |
| 340 | - | |
| 341 | - return $fields; | |
| 342 | - } | |
| 343 | - | |
| 344 | - private function get_font_variables() { | |
| 345 | - static $font_variables = null; | |
| 346 | - | |
| 347 | - if ( null === $font_variables ) { | |
| 348 | - $font_variables = apply_filters( 'elementor/typography/font_variables', [] ); | |
| 349 | - } | |
| 350 | - | |
| 351 | - return $font_variables; | |
| 352 | - } | |
| 353 | - | |
| 354 | - public static function get_font_variable_ranges() { | |
| 355 | - return apply_filters( 'elementor/typography/font_variable_ranges', [] ); | |
| 356 | - } | |
| 357 | - | |
| 358 | 223 | /** |
| 359 | 224 | * Prepare fields. |
| 360 | 225 | * |
| 361 | 226 | * Process typography control fields before adding them to `add_control()`. |
| @@ -432,9 +297,9 @@ | ||
| 432 | 297 | protected function get_default_options() { |
| 433 | 298 | return [ |
| 434 | 299 | 'popover' => [ |
| 435 | 300 | 'starter_name' => 'typography', |
| 436 | - 'starter_title' => esc_html__( 'Typography', 'elementor' ), | |
| 301 | + 'starter_title' => _x( 'Typography', 'Typography Control', 'elementor' ), | |
| 437 | 302 | 'settings' => [ |
| 438 | 303 | 'render_type' => 'ui', |
| 439 | 304 | 'groupType' => 'typography', |
| 440 | 305 | 'global' => [ |