Skip to content

Instantly share code, notes, and snippets.

@krugazul
Last active July 9, 2018 14:37
Show Gist options
  • Select an option

  • Save krugazul/7ce542141e29305cb24c139c93b98726 to your computer and use it in GitHub Desktop.

Select an option

Save krugazul/7ce542141e29305cb24c139c93b98726 to your computer and use it in GitHub Desktop.
Bulk Delete WooCommerce and WooCommerce Subscriptions Integration
<?php
function split_post_type_status( $str ) {
$type_status = array();
$wc_post_types = array(
'wc-active',
'wc-switched',
'wc-expired',
'wc-pending-cancel',
'wc-pending',
'wc-processing',
'wc-on-hold',
'wc-completed',
'wc-cancelled',
'wc-refunded',
'wc-failed',
);
$wc_type = false;
foreach( $wc_post_types as $wc_post_type ) {
if ( stripos( $str, $wc_post_type ) !== false ) {
$wc_type = true;
$str_arr = explode( '-wc', $str );
$type_status['status'] = 'wc' . end( $str_arr );
$type_status['type'] = $str_arr[0];
}
}
if ( false === $wc_type ) {
$str_arr = explode( '-', $str );
if ( count( $str_arr ) > 1 ) {
$type_status['status'] = end( $str_arr );
$type_status['type'] = implode( '-', array_slice( $str_arr, 0, - 1 ) );
} else {
$type_status['status'] = 'publish';
$type_status['type'] = $str;
}
}
return $type_status;
}
}
?>
<?php
//Add the following function to line 683
$wc_post_types = array(
'wc-active',
'wc-switched',
'wc-expired',
'wc-pending-cancel',
'wc-pending',
'wc-processing',
'wc-on-hold',
'wc-completed',
'wc-cancelled',
'wc-refunded',
'wc-failed',
);
foreach ( $wc_post_types as $wc_post_type ) {
if ( $post_count->$wc_post_type > 0 ) {
$types_array["$type-$wc_post_type"] = $post_count->$wc_post_type;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment