1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
<?php
class CMB2_Type_Title extends CMB2_Type_Base {
public function render() {
$name = $this->field->args( 'name' );
$tag = 'span';
if ( ! empty( $name ) ) {
$tag = $this->field->object_type == 'post' ? 'h5' : 'h3';
}
$a = $this->parse_args( 'title', array(
'tag' => $tag,
'class' => empty( $name ) ? 'cmb2-metabox-title-anchor' : 'cmb2-metabox-title',
'name' => $name,
'desc' => $this->_desc( true ),
'id' => str_replace( '_', '-', sanitize_html_class( $this->field->id() ) ),
) );
return $this->rendered(
sprintf(
'<%1$s %2$s>%3$s</%1$s>%4$s',
$a['tag'],
$this->concat_attrs( $a, array( 'tag', 'name', 'desc' ) ),
$a['name'],
$a['desc']
)
);
}
}