• Resolved drvy

    (@drvy)


    When uninstalling, the plugin will delete “post” entries and not just “codes”. A client had to pull his backup two times as he didn’t know what was happening.

    We’ve checked the code and it seems to be a misnamed variable. This is affecting the latest version (1.1.8).

    File: uninstall.php
    Lines: 17-19.

    On line 17, an array ($ccc_post_types) is being created with the post_types to delete, however, when in the foreach loop, you’re trying to call $post_type thus resulting in a null value. This makes wordpress use the default value for the post_type field which is “post”, thus deleting posts instead of the “codes”.

    As a suggestion, the post_type supports arrays thus there is no need to use a foreach to target each post_type. A simple solution would be:

    $ccc_post_types = array("ccc_codes", "ccc_contestants");
    $posts = get_posts( array( 'post_type' => $ccc_post_types, 'post_status' => 'any', 'numberposts' => -1, 'fields' => 'ids' ) );
    if ( $posts ) {
        foreach ( $posts as $p ) {
            wp_delete_post( $p, true);
        }
    }

    Thanks.

    • This topic was modified 4 years, 6 months ago by drvy.
Viewing 1 replies (of 1 total)
  • Plugin Author mdedev

    (@mdedev)

    Hi @drvy,

    Thank you for reporting the issue to me. I have fixed the uninstall script and released 1.1.9. Sorry about that.

    Thanks,
    Mike

Viewing 1 replies (of 1 total)
  • The topic ‘[Bug] Plugin deletes posts on uninstall’ is closed to new replies.