Last active
November 27, 2018 18:18
-
-
Save dancameron/b0a533c180e32685968a6060f72065a0 to your computer and use it in GitHub Desktop.
Set Default Due Date to 1st of Next Month
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // don't add this line since it's already in your functions.php file | |
/** | |
* Edited invoices | |
*/ | |
function _si_information_meta_box_args( $args ) { | |
if ( 'auto-draft' == $args['post']->post_status ) { // only adjust drafts | |
$args['due_date'] = strtotime('first day of next month'); | |
} | |
return $args; | |
} | |
add_filter( 'load_view_args_admin/meta-boxes/invoices/information.php', '_si_information_meta_box_args' ); | |
add_filter( 'load_view_args_admin/meta-boxes/estimates/information.php', '_si_information_meta_box_args' ); | |
/** | |
* Generated invoices | |
*/ | |
function _default_due_in_days() { | |
$first_day_of_next_month = strtotime('first day of next month'); | |
$days_till_next_month = ($first_day_of_next_month - time()) / (DAY_IN_SECONDS); | |
return (int) $days_till_next_month; | |
} | |
add_filter( 'si_default_due_in_days', '_default_due_in_days' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This snippet is a customization for Sprout Invoices. A customizable solution that provides a way for you to get paid via your WordPress site. For more information please don't hesitate to reach out.