breznflow/uninstall.php
Michael fd83e4810b BreznFlow 1.0.0 — WordPress.org submission
Initial public release of BreznFlow, an n8n workflow renderer for WordPress.
Fully PHPCS-compliant (WordPress Coding Standards), security-hardened,
and ready for WordPress.org plugin review.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-30 11:27:36 +00:00

56 lines
1.3 KiB
PHP

<?php
/**
* Uninstall handler for BreznFlow.
*
* Removes all workflow posts, settings, taxonomy terms, and transients
* when the plugin is deleted via the WordPress admin.
*
* @package BreznFlow
* @since 1.0.0
*/
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
exit;
}
// Delete all workflow CPT posts and their meta.
$breznflow_post_ids = get_posts(
array(
'post_type' => 'breznflow_workflow',
'post_status' => 'any',
'posts_per_page' => -1,
'fields' => 'ids',
)
);
foreach ( $breznflow_post_ids as $breznflow_post_id ) {
wp_delete_post( $breznflow_post_id, true );
}
// Delete plugin settings.
delete_option( 'breznflow_settings' );
// Delete taxonomy terms.
$breznflow_terms = get_terms(
array(
'taxonomy' => 'breznflow_category',
'hide_empty' => false,
)
);
if ( ! is_wp_error( $breznflow_terms ) ) {
foreach ( $breznflow_terms as $breznflow_term ) {
wp_delete_term( $breznflow_term->term_id, 'breznflow_category' );
}
}
// Flush transients.
global $wpdb;
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- uninstall cleanup, no caching needed.
$wpdb->query(
$wpdb->prepare(
"DELETE FROM {$wpdb->options} WHERE option_name LIKE %s OR option_name LIKE %s",
'_transient_breznflow_%',
'_transient_timeout_breznflow_%'
)
);