Skip to content

Releases: Chrico/wp-fields

2.0.2

19 Jun 13:24
3a7bfe7
Compare
Choose a tag to compare
  • CollectionElement // fix issue with CollectionElement::hasErrors() not checking if children have errors.

2.0.1

19 Jun 12:48
67b396a
Compare
Choose a tag to compare
  • Add missing autoload.files section in composer.json to load inc/functions.php.

2.0.0

19 Jun 10:56
68acece
Compare
Choose a tag to compare

ℹ️ 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

25 Oct 09:08
0a97839
Compare
Choose a tag to compare
  • Fix typo in method signature - Method name is configureEollection and should be configureCollection #5
  • update method names #6 .
  • Introduce unit tests to ensure Element get options #10
  • fix: be more flexible on composer constraints since we require this package in other packages #13

props to @widoz and @luislard

1.0

15 Jun 09:23
b6c8691
Compare
Choose a tag to compare
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

04 Jan 12:01
Compare
Choose a tag to compare

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 by Form::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 for Element\FormInterface instead of Element\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.

11 Apr 05:52
Compare
Choose a tag to compare
0.1.0

updated readme.md with correct links to travis and license info.