Skip to content

Instantly share code, notes, and snippets.

@mklasen
Created January 16, 2017 18:44
Show Gist options
  • Save mklasen/4ee018ad7a1f52099020ae740a9f44f1 to your computer and use it in GitHub Desktop.
Save mklasen/4ee018ad7a1f52099020ae740a9f44f1 to your computer and use it in GitHub Desktop.
<?php
add_action( 'cmb2_admin_init', function() {
$prefix = 'mk_add_thickbox_';
$metabox = new_cmb2_box( array(
'id' => $prefix.'box',
'title' => 'Signature',
'object_types' => array( 'post', ),
) );
$metabox->add_field( array(
'name' => 'Signature',
'desc' => 'Draw a signature',
'id' => $prefix.'field',
'type' => 'mk_add_thickbox',
) );
});
add_action( 'cmb2_render_mk_add_thickbox', function() {
add_thickbox();
?>
<div id="mk_thickbox" style="display:none;">
<h1>Signature</h1>
<p>Draw your signature below..</p>
<div style="background: white; height: 200px; width: 100%; border: 1px solid #333; display: flex; justify-content: center; align-items: center; font-style: italic;">Draw your signature..</div>
</div>
<a href="#TB_inline?width=600&height=550&inlineId=mk_thickbox" class="thickbox">Enter signature..</a>
<?php
}, 10, 5 );
@mklasen
Copy link
Author

mklasen commented Jan 16, 2017

Custom field for CMB2 which opens thickbox.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment