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.
Метод класса: TaxonomiesMetaBox{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$TaxonomiesMetaBox = new TaxonomiesMetaBox(); $TaxonomiesMetaBox->add_taxonomies_meta_boxes( $screen_id, $order_type );
- $screen_id(строка) (обязательный)
- Screen ID.
- $order_type(строка) (обязательный)
- Order type to register meta boxes for.
Код TaxonomiesMetaBox::add_taxonomies_meta_boxes() TaxonomiesMetaBox::add taxonomies meta boxes WC 10.3.5
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,
)
);
}
}