-
-
Save JPry/ed3f472d537408bc276a128d200842a8 to your computer and use it in GitHub Desktop.
This file contains 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 characters
<?php | |
/** | |
* Plugin Name: Delete all subscriptions. | |
* Plugin URI: https://gist.github.com/JPry/ed3f472d537408bc276a128d200842a8 | |
* Description: PERMANENTLY delete all subscriptions. | |
* Version: 1.0 | |
* Author: Jeremy Pry | |
* Author URI: http://jeremypry.com/ | |
* License: GPL2 | |
*/ | |
// Prevent direct access to this file | |
if ( ! defined( 'ABSPATH' ) ) { | |
die( "You can't do anything by accessing this file directly." ); | |
} | |
add_action( 'init', 'jpry_delete_all_subscriptions', 20 ); | |
/** | |
* Delete all available subscriptions. | |
* | |
* WARNING: There is no going back. There is no undo. | |
* | |
* @author Jeremy Pry | |
*/ | |
function jpry_delete_all_subscriptions() { | |
$subscriptions = wcs_get_subscriptions( array( | |
'subscriptions_per_page' => 1000, | |
) ); | |
/** @var WC_Subscription $subscription */ | |
foreach ( $subscriptions as $subscription ) { | |
// If you want to allow for all of the proper hooks to be triggered, uncomment the next line. | |
//$subscription->update_status( 'cancelled' ); | |
// This is the point of no return. After ths line the subscription is gone. | |
wp_delete_post( $subscription->get_id(), true ); | |
} | |
// Explicit cleanup. | |
unset( $subscriptions ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
after using this one plugin , the site not get loaded
why it happens?