Support General Select Metaboxs by Attribute Flag Reply To: Select Metaboxs by Attribute Flag

#13349
pluginovenpluginoven
Participant

According to the new documentation (thank you, for this) I should be able to simply create an has_filter argument for the $meta_boxes object like so:

$meta_boxes[] = array(
            'id'         => 'gender_box',
            'title'      => __('Gender', 'text-domain'),
            'post_types' => 'some_post_type',
            'context'    => 'normal',
            'priority'   => 'high',
            'has_filter'  => true,

            'fields' => array( 
                ...
            ),
)

and then grab only the meta_boxes that contain this new argument using the get_by method:

$args = [
    'has_filter'   => true,
];
$meta_box_objects = rwmb_get_registry( 'meta-box' )->get_by( $args );

All fields in each returned meta_box will still need to be looped through in order to check for the specific attribute. But at least this way I do not need to loop all meta_boxs. However, there is no way to directly get only the fields that have a specific attribute set, correct?