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
<?php
class CMB2_Type_Textarea_Code extends CMB2_Type_Textarea {
public function render( $args = array() ) {
$args = wp_parse_args( $args, array(
'class' => 'cmb2-textarea-code',
'desc' => '</pre>' . $this->_desc( true ),
) );
if ( true !== $this->field->options( 'disable_codemirror' )
&& function_exists( 'wp_enqueue_code_editor' ) ) {
$args['js_dependencies'] = array( 'code-editor' );
} else {
$args['class'] = rtrim( $args['class'] ) . ' disable-codemirror';
}
return $this->rendered(
sprintf( '<pre>%s', parent::render( $args ) )
);
}
}