Releases: Chrico/wp-fields
2.0.2
2.0.1
2.0.0
ℹ️ This release contains a rework of the code to drop PHP <8.0 support. The public API will stay as it is.
Removed external dependencies
Following external dependencies were removed:
Pimple
The Extensions\Provider
was removed from that library. We do not need to use any Container anymore by default. You can now use directly the functions ChriCo\Fields\renderElement()
in your view/template and ChriCo\Fields\createElement()
in your controller, instead of the Factories.
inpsyde/validator and inpsyde/filter
ChriCo\Fields\Element\Element
does not rely anymore on inspyde/validator
and inpsyde/validator
.
From now on, you can simply add a callable for validation which will return either null
on success or WP_Error
on failure and for filtering (sanitization) a callback, which returns the sanitized value.
use ChriCo\Fields\Element\Element;
$text = (new Element('my-text'))
->withValidator(static function(string $value): ?WP_Error {
if(!is_email($value)){
return new WP_Error('my-text', __('Please insert a valid E-Mail address', 'your-textdomain'));
}
return null;
})
->withFilter(static fn($value): string => sanitize_text_field($value));
View\FormRow improvements
View\FormRow
will now have CSS classes with the "type" and "name" of the rendered Element. Addtionally for ChriCo\Fields\Element\Elemen::type() === "hidden"
, we will automatically add the CSS class hidden
to the row to avoid any whitespacing.
View\Collection improvements
The ChriCo\Fields\View\Collection
will now not nest anymore table > tr > td > table
for nested Collection-elements.
QoL
- Switched from Travis to Github Workflows.
1.0.1
1.0
[1] Breaking changes
There happened a complete rewrite of API, which means we're now going to PSR-2 code style instead of using the underscore methodes from WordPress.
Removing set_
*
All set_
-methods are now with
-methods in camelCase
. So e.G. set_value
is now withValue
and also are now returning the object to allow chaining.
Removing get_
All get_
-methods are now without this prefix. So e.G. get_value
is now just value
, which is way more intuitive.
BaseElement
removed
The Element\BaseElement
was removed and completly migrated into Element\Element
.
Collection add multiple Element
The method add_elements
is removed. To add multiple Element
-instances you can either use:
// v1 - chaining
$collection
->withElement($element1)
->withElement($element2);
// v2 - without chaining
$collection->withElement($element1, $element2);
// v3 - when having elements in an array
$collection->withElement(...[$element1, $element2]);
0.3.0
Added
- Introduced new view-class
View\Description
to render the description output. - Added
wp-coding-standards/wpcs
and automatic code style test via travis-ci. Form::bind_data
is now deprecated and will be removed byForm::submit
in future.- Calling
Form::submit
will now set a new state "is_submitted = TRUE". - Added new method
Form::is_submitted
.
Improvements
- Several smaller improvements in
View\FormRow
. View\Form
now checks forElement\FormInterface
instead ofElement\Form
.Form::submit
will now automatically trigger validation of elements and binding errors.- Moved documentation into
docs/
-folder and splitted it into multiple files.
First Release.
0.1.0 updated readme.md with correct links to travis and license info.