From 5c0b79fa8655c3798dad7147f5c94d3756f6bad5 Mon Sep 17 00:00:00 2001 From: Ian Dunn Date: Thu, 17 Mar 2022 14:38:19 -0700 Subject: [PATCH] Bin: Add script to deactivate pledges. --- bin/deactivate-pledges.php | 71 +++++++++++++++++++++++++++++++++++++ bin/modify-profile-data.php | 1 + 2 files changed, 72 insertions(+) create mode 100644 bin/deactivate-pledges.php diff --git a/bin/deactivate-pledges.php b/bin/deactivate-pledges.php new file mode 100644 index 0000000..c816687 --- /dev/null +++ b/bin/deactivate-pledges.php @@ -0,0 +1,71 @@ +post_type ) { + WP_ClI::error( "$id is not a pledge post.", false ); + continue; + } + + // We don't want to email someone twice if they were already deactivated. + if ( DEACTIVE_STATUS === $pledge->post_status ) { + WP_ClI::warning( sprintf( "%s (%d) is already deactivated.", $pledge->post_title, $id ) ); + continue; + } + + $emails[] = get_post_meta( $id, '5ftf_org-pledge-email', true ); + deactivate( $id, false, $reason ); + } + + WP_CLI::line( "\n" ); + WP_CLI::success( 'Done' ); + + WP_ClI::line( "Email addresses of deactivated organizations: \n" ); + WP_ClI::line( implode( ', ', $emails ) ); +} diff --git a/bin/modify-profile-data.php b/bin/modify-profile-data.php index 4cbfc9a..0dedffd 100644 --- a/bin/modify-profile-data.php +++ b/bin/modify-profile-data.php @@ -18,6 +18,7 @@ wp_debug_mode(); // re-set `display_errors` after WP-CLI overrides it, see ht /** @var array $args The arguments passed to this script from the command line */ main( $file, $args ); +defined( 'WP_CLI' ) || die( 'Nope' ); /** * The main controller