Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  bump to 1.16.0
  add text_number() method to CMB2 Field_Types
  • Loading branch information
lipemat committed Dec 18, 2018
2 parents 445509b + ee14d60 commit f49ef13
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# WordPress Libs
WordPress library which supports a core plugin and theme.

**Version [1.15.0](https://github.com/lipemat/wordpress-lipe-libs/releases/tag/1.15.0)**
**Version [1.16.0](https://github.com/lipemat/wordpress-lipe-libs/releases/tag/1.16.0)**

### Requirements
1. PHP Version 7.1.3+ (Recommended 7.2.0+)
Expand Down
25 changes: 25 additions & 0 deletions src/CMB2/Field_Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,31 @@ public function text_money() {
return $this->set( [ 'type' => $this->text_money ] );
}

/**
* HTML number field
* Custom to WP-Libs
*
* @link https://www.w3schools.com/tags/att_input_type_number.asp
*
* @param float $step
* @param float|null $min
* @param float|null $max
*
* @return Field
*/
public function text_number( float $step = 1, ?float $min = null, ?float $max = null ) : Field {
$this->field->attributes['type'] = 'number';
$this->field->attributes['step'] = $step;
if ( null !== $min ) {
$this->field->attributes['min'] = $min;
}
if ( null !== $max ) {
$this->field->attributes['max'] = $max;
}

return $this->set( [ 'type' => $this->text_small ] );
}


/**
* Standard textarea.
Expand Down

0 comments on commit f49ef13

Please sign in to comment.