field-row.php
41 lines
| 1 | <?php |
| 2 | /** |
| 3 | * The Template for displaying field rows in meta-boxes. |
| 4 | * |
| 5 | * @var array $field The field. |
| 6 | * @package YITH\PluginFramework\Templates |
| 7 | */ |
| 8 | |
| 9 | defined( 'ABSPATH' ) || exit; // Exit if accessed directly. |
| 10 | |
| 11 | // Meta-box backward compatibility. |
| 12 | if ( isset( $field['label'] ) ) { |
| 13 | $field['title'] = $field['label']; |
| 14 | } |
| 15 | |
| 16 | $default_field = array( |
| 17 | 'id' => '', |
| 18 | 'title' => isset( $field['name'] ) ? $field['name'] : '', |
| 19 | 'desc' => '', |
| 20 | ); |
| 21 | $field = wp_parse_args( $field, $default_field ); |
| 22 | |
| 23 | $display_field_only = isset( $field['display-field-only'] ) ? $field['display-field-only'] : false; |
| 24 | $is_required = ! empty( $field['required'] ); |
| 25 | |
| 26 | $extra_row_classes = $is_required ? array( 'yith-plugin-fw--required' ) : array(); |
| 27 | $extra_row_classes = apply_filters( 'yith_plugin_fw_metabox_extra_row_classes', $extra_row_classes, $field ); |
| 28 | $extra_row_classes = is_array( $extra_row_classes ) ? implode( ' ', $extra_row_classes ) : ''; |
| 29 | |
| 30 | ?> |
| 31 | <div id="<?php echo esc_attr( $field['id'] ); ?>-container" <?php echo yith_field_deps_data( $field ); ?> class="yith-plugin-fw-metabox-field-row <?php echo esc_attr( $extra_row_classes ); ?>"> |
| 32 | <?php if ( $display_field_only ) : ?> |
| 33 | <?php yith_plugin_fw_get_field( $field, true ); ?> |
| 34 | <?php else : ?> |
| 35 | <label for="<?php echo esc_attr( $field['id'] ); ?>"><?php echo wp_kses_post( $field['title'] ); ?></label> |
| 36 | <?php yith_plugin_fw_get_field( $field, true ); ?> |
| 37 | <div class="clear"></div> |
| 38 | <span class="description"><?php echo wp_kses_post( $field['desc'] ); ?></span> |
| 39 | <?php endif; ?> |
| 40 | </div> |
| 41 |