Automattic\WooCommerce\Internal\Admin\Orders\MetaBoxes
TaxonomiesMetaBox::add_taxonomies_meta_boxes()
Registers meta boxes to be rendered in order edit screen for taxonomies.
Note: This is re-implementation of part of WP core's register_and_do_post_meta_boxes function. Since the code block that add meta box for taxonomies is not filterable, we have to re-implement it.
Method of the class: TaxonomiesMetaBox{}
No Hooks.
Return
null
. Nothing (null).
Usage
$TaxonomiesMetaBox = new TaxonomiesMetaBox(); $TaxonomiesMetaBox->add_taxonomies_meta_boxes( $screen_id, $order_type );
- $screen_id(string) (required)
- Screen ID.
- $order_type(string) (required)
- Order type to register meta boxes for.
TaxonomiesMetaBox::add_taxonomies_meta_boxes() TaxonomiesMetaBox::add taxonomies meta boxes code WC 9.4.2
public function add_taxonomies_meta_boxes( string $screen_id, string $order_type ) { include_once ABSPATH . 'wp-admin/includes/meta-boxes.php'; $taxonomies = get_object_taxonomies( $order_type ); // All taxonomies. foreach ( $taxonomies as $tax_name ) { $taxonomy = get_taxonomy( $tax_name ); if ( ! $taxonomy->show_ui || false === $taxonomy->meta_box_cb ) { continue; } if ( 'post_categories_meta_box' === $taxonomy->meta_box_cb ) { $taxonomy->meta_box_cb = array( $this, 'order_categories_meta_box' ); } if ( 'post_tags_meta_box' === $taxonomy->meta_box_cb ) { $taxonomy->meta_box_cb = array( $this, 'order_tags_meta_box' ); } $label = $taxonomy->labels->name; if ( ! is_taxonomy_hierarchical( $tax_name ) ) { $tax_meta_box_id = 'tagsdiv-' . $tax_name; } else { $tax_meta_box_id = $tax_name . 'div'; } add_meta_box( $tax_meta_box_id, $label, $taxonomy->meta_box_cb, $screen_id, 'side', 'core', array( 'taxonomy' => $tax_name, '__back_compat_meta_box' => true, ) ); } }