Adds meta boxes to the page.
Description
See also
Parameters
- $form
-
(awsmug\Torro_Forms\DB_Objects\Forms\Form) (Required) Current form.
Source
File: src/db-objects/forms/form-edit-page-handler.php
private function add_meta_boxes( $form ) { $this->current_form = $form; if ( ! did_action( "{$this->form_manager->get_prefix()}add_form_meta_content" ) ) { /** * Fires when meta boxes for the form edit page should be added. * * @since 1.0.0 * * @param Form_Edit_Page_Handler $edit_page Form edit page. */ do_action( "{$this->form_manager->get_prefix()}add_form_meta_content", $this ); } foreach ( $this->meta_boxes as $id => $args ) { add_meta_box( $id, $args['title'], function( $post, $box ) { $prefix = $this->form_manager->get_prefix(); if ( ! empty( $box['args']['description'] ) ) { echo '<p class="description">' . $box['args']['description'] . '</p>'; } $tab_id_prefix = 'metabox-' . $box['id'] . '-tab-'; $tabpanel_id_prefix = 'metabox-' . $box['id'] . '-tabpanel-'; $tabs = wp_list_filter( $this->tabs, array( 'meta_box' => $box['id'] ) ); $first = true; /** * Fires before a form meta box is rendered. * * The dynamic portion of the hook name refers to the meta box identifier. * * @since 1.0.0 * * @param int $form_id Current form ID. */ do_action( "{$prefix}metabox_{$box['id']}_before", $this->current_form->id ); ?> <h3 class="torro-metabox-tab-wrapper" role="tablist"> <?php foreach ( $tabs as $id => $args ) : ?> <a id="<?php echo esc_attr( $tab_id_prefix . $id ); ?>" class="torro-metabox-tab" href="<?php echo esc_attr( '#' . $tabpanel_id_prefix . $id ); ?>" aria-controls="<?php echo esc_attr( $tabpanel_id_prefix . $id ); ?>" aria-selected="<?php echo $first ? 'true' : 'false'; ?>" role="tab"> <?php echo $args['title']; ?> </a> <?php $first = false; ?> <?php endforeach; ?> </h3> <?php $first = true; ?> <?php foreach ( $tabs as $id => $args ) : ?> <div id="<?php echo esc_attr( $tabpanel_id_prefix . $id ); ?>" class="torro-metabox-tab-panel" aria-labelledby="<?php echo esc_attr( $tab_id_prefix . $id ); ?>" aria-hidden="<?php echo $first ? 'false' : 'true'; ?>" role="tabpanel"> <?php /** * Fires before a form meta box tab is rendered. * * The dynamic portions of the hook name refer to the meta box identifier and * tab identifier respectively. * * @since 1.0.0 * * @param int $form_id Current form ID. */ do_action( "{$prefix}metabox_{$box['id']}_tab_{$id}_before", $this->current_form->id ); ?> <?php if ( ! empty( $args['description'] ) ) : ?> <p class="description"><?php echo $args['description']; ?></p> <?php endif; ?> <table class="form-table"> <?php $box['args']['field_manager']->render( $id ); ?> </table> <?php /** * Fires after a form meta box tab has been rendered. * * The dynamic portions of the hook name refer to the meta box identifier and * tab identifier respectively. * * @since 1.0.0 * * @param int $form_id Current form ID. */ do_action( "{$prefix}metabox_{$box['id']}_tab_{$id}_after", $this->current_form->id ); ?> </div> <?php $first = false; ?> <?php endforeach; ?> <?php /** * Fires after a form meta box has been rendered. * * The dynamic portion of the hook name refers to the meta box identifier. * * @since 1.0.0 * * @param int $form_id Current form ID. */ do_action( "{$prefix}metabox_{$box['id']}_after", $this->current_form->id ); ?> <?php }, null, $args['context'], $args['priority'], $args ); } /** * Fires when meta boxes for the form edit page should be added. * * @since 1.0.0 * * @param Form $form Form that is being edited. */ do_action( "{$this->form_manager->get_prefix()}add_form_meta_boxes", $form ); }
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |