Releases: lipemat/wordpress-libs
Cron Abstract
Registering Crons Via New Abstract
use Lipe\Lib\Cron\Cron_Abstract;
class Daily_Report extends Cron_Abstract {
public const NAME = 'cron/daily-report';
public function get_recurrence() : string {
return 'daily';
}
public function run() : void {
/**
* This could send an email
* or update field, or anything a cron can do.
*
*/
}
}
Disabled And Readonly
Enhancements around disabled and readonly fields
- New
readonly
method onCMB2\Field
which makes a field asreadonly
as well as marking fieldsdisabled
of types that can only be disabled to be readonly. - New
save_button
method onCMB2\Options_Page
which supports disabling the save button for a readonly settings page.
A few other misc enhancements
- New
remove_box_wrap
method forCMB2\Box
. - Improved
True_False
field markup. - Improved
CMB2\Field::attributes()
method to merge in attributes instead of squashing existing.
CMB2 True False
Introducing a True/False field type for CMB2
Similar to the field you can find in ACF. Works just like a checkbox, but with a clean on/off switch UI.
$box->field( 'switch-field', "I'm a switch!" )
->true_false();
CMB2 Number Field
Text Number Field Support For CMB2
When using the Field object to register CMB2 a new method called text_number
creates a number
input with support for specifying step
, min
, and max
.
$box->field( 'a-number-field', 'Number Field' )
->text_number( 1, 50, 2000 );
Gutenberg Support For Custom_Post_Type
Enable or disable the block editor via a class property
Set the property and all requirements and/or filters will be taken care of automatically.
$post = new Custom_Post_Type_Extended( 'products' );
$post->gutenberg_compatible = false;
CMB2 Box Descriptions
CMB2 support for displaying a description above an options-page or a metabox
$box = new Box( self::NAME, $object_types, 'Ad Data' );
$box->description( 'test description' );
Gutenberg Ready
WordPress 5.0 was Finally release today with support for Gutenberg. This release contains all the latest notes and enhancements available with WordPress 5.0
While the last version of this library works without issue with WordPress 5.0, to have all the latest enhancements you can update.
Some Enhancements
- Support Gutenberg properties via
display_when_gutenberg_active
andgutenberg_compatible
within theSchema/Meta_Box
class. - Support Gutenberg properties via
display_when_gutenberg_active
andgutenberg_compatible
within theCMB2/Box
class. - Add
tab_group
property to theCMB2/Options_Page
class. - Add new
register_post_type
labels to thePost_Type/Custom_Post_Type
class. - Make notes about
show_in_rest
requirements.
Thanks For The Memories - Filter Closures
This version adds a nice new method to the Util/Actions
class called 'add_filter_as_action()'
Solves a long tedium when you need to hook into an apply_filters()
call without actually filtering anything. When you just wish you had a do_action()
there instead of an apply_filters()
.
Observe
Old Way
add_filter( 'some_conviently_placed_filter', function( $value ) {
custom_function_call();
return $value;
});
New Way
Actions::in()->add_filter_as_action( 'some_conviently_placed_filter', 'custom_function_call' );
CMB2 Compact Checkboxes
CMB2 compact layout for checkboxes. Useful for side meta boxes that get very long using the default layout.
// shorthand
$box->field( self::FIELD_ID, 'Compact Checkbox' )
->checkbox( 'compact' )
CMB2 Group Layouts
CMB2 Group layouts allow displaying a CMB2 group in either a row
or table
layout. Displays group items in a more compact and pleasing UI.
// shorthand
$group = $box->group( self::GROUP_ID, 'Table GROUP' )
->layout( 'table' );
Other Enhancements
- Support using keyed and flat arrays at the same time with Class_Names
- Support
LIKE
queries inSchema\Db
- Support '' queries in
Schema\Db