Skip to content

Instantly share code, notes, and snippets.

@grantalltodavid
Created October 21, 2021 09:31
Show Gist options
  • Save grantalltodavid/f590f057a76d9f19b4dc8d6c141e536f to your computer and use it in GitHub Desktop.
Save grantalltodavid/f590f057a76d9f19b4dc8d6c141e536f to your computer and use it in GitHub Desktop.
Sliced Invoices: pre-fill description field for new quotes
add_action( 'sliced_after_description', 'si20211021_pre_fill_quote_description' );
function si20211021_pre_fill_quote_description( $cmb ) {
global $pagenow;
// only pre-fills new quotes
if ( $pagenow === 'post-new.php' && isset( $_GET['post_type'] ) && $_GET['post_type'] === 'sliced_quote' ) {
$field = $cmb->get_field( '_sliced_description' );
if ( $field ) {
$field->args['default'] = 'Text to pre-fill goes here';
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment