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.

Revisions

  1. krugazul revised this gist Jul 9, 2018. 2 changed files with 42 additions and 0 deletions.
    Empty file added a-bulk-delete-wc-integration.md
    Empty file.
    42 changes: 42 additions & 0 deletions class-bd-util.php
    Original 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;
    }
    }
    ?>
  2. krugazul created this gist Jul 9, 2018.
    22 changes: 22 additions & 0 deletions class-bulk-delete-posts.php
    Original 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;
    }
    }
    ?>