Last active
July 9, 2018 14:37
-
-
Save krugazul/7ce542141e29305cb24c139c93b98726 to your computer and use it in GitHub Desktop.
Revisions
-
krugazul revised this gist
Jul 9, 2018 . 2 changed files with 42 additions and 0 deletions.There are no files selected for viewing
Empty file.This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ <?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; } } ?> -
krugazul created this gist
Jul 9, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ <?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; } } ?>