Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_filter( 'cmb2_override_meta_value', 'dcwd_cmb2_override_meta_value', 10, 4 );
- //add_filter( 'cmb2_override_tracking_number_meta_value', 'dcwd_cmb2_override_meta_value', 10, 4 );
- function dcwd_cmb2_override_meta_value( $type, $object_id, $a, $this_obj ) {
- error_log( 'Type: '. $type );
- error_log( 'Post/object ID: '. $object_id );
- error_log( '$a: '. var_export( $a, true ) );
- return 'cmb2_field_no_override_val';
- }
- add_filter( 'cmb2_override_meta_save', 'dcwd_cmb2_override_meta_save', 10, 4 );
- add_filter( 'cmb2_override_tracking_number_meta_save', 'dcwd_cmb2_override_meta_save', 10, 4 );
- add_filter( 'cmb2_override_tracking_url_meta_save', 'dcwd_cmb2_override_meta_save', 10, 4 );
- function dcwd_cmb2_override_meta_save( $override, $a, $args, $this_obj ) {
- error_log( 'Type: cmb2_override_*' . $a['field_id'] . '*_meta_save' );
- error_log( '$a: '. var_export( $a, true ) );
- error_log( '$_POST: '. var_export( $_POST, true ) );
- return $override;
- }
- add_filter( 'cmb2_can_save', 'dcwd_cmb2_can_save', 10, 2 );
- function dcwd_cmb2_can_save( $can_save, $cmb_obj ) {
- $current_screen = get_current_screen();
- if ( 'woocommerce_page_wc-orders' == $current_screen->id ) {
- if ( array_key_exists( 'tracking_number', $_POST ) && ( !empty( $_POST[ 'tracking_number' ] ) ) ) {
- if ( array_key_exists( 'tracking_url', $_POST ) && ( !empty( $_POST[ 'tracking_url' ] ) ) )
- error_log( 'dcwd_cmb2_can_save: Return true as tracking_number and tracking_url are in $_POST.' );
- return true;
- }
- }
- return $can_save;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement