Version 2.17.0 of WordPress Libs is now available for public use. This release focused on getting everything ready for CMB2 version 2.7.0. It also includes many bug fixes and compatibility improvements.
CMB2 2.7.0
CMB2 released version 2.7.0 back in January. Since it took a year for that release to be ready, we wanted to wait a while to make sure there were not going to be any quick follow-up bug fixes before we implemented it. Now that we are confident it is ready for prime time, we’ve added support for the new features.
display_class
field parameter
The Field
class now contains the display_class
property to assign an entirely custom class to use for rendering within admin columns and likewise. As a custom display class should extend the CMB2_Field_Display
class, we’ve typed this property appropriately.
register_rest_field_cb
box paramter
The Box
class now contains the register_rest_field_cb
property to replace the registering of the rest fields for the particular box. Used when an entirely custom response is desired.
char_counter
field parameters
A new char_counter
method has been added to the Field
class which takes care of the heavy lifting when adding a character counter to a field. Character counters are now supported on textarea
, text
, or wysiwyg
type fields.
The method accepts the following arguments:
bool $count_words
– By default the field will count characters; if you would like it to count words, passtrue
.int $max
– If set, this will count down the characters/words until maximum is reached.bool $enforce
– If we are counting characters, you may force the field to only allow the specified$max
.array $labels
– Override the labels used for various states throughout the counting process.
Support taxonomy_select_hierarchical
field type
The Field_Type
class now contains mappings for the new taxonomy_select_hierarchical
field. It functions the same as the previously existing taxonomy_select
field except the hierarchy is indented on display.
Add disable_sorting
parameter to column
method
CMB2 now supports sorting the post list by column by default. This may be disabled per field by passing a disable_sortable
to the column
arguments. You may now set $disable_sorting
to true using the method to disable sorting.
New array_map_assoc
method
The Arrays
class now contains an array_map_assoc
method which automatically passes the array key as the second argument to the specified callback and preserves the original keys.
Settings Trait now supports a callback during update_option
Building off of the support already available with the Mutator_Trait
you may now pass a callback as the $value
argument of update_option
. This callback will receive the previous value as an argument and should return the new value.