Last active
June 3, 2019 09:52
-
-
Save asharirfan/8e9a3f18c45d32c56bf2e82917017e0e to your computer and use it in GitHub Desktop.
Clear the file changes notifications of WFCM plugin on activation.
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: WFCM Clear Notifications | |
* Plugin URI: http://www.wpwhitesecurity.com/ | |
* Description: Clear the file changes notifications of WFCM plugin. | |
* Author: mrasharirfan | |
* Contributors: WP White Security, mrasharirfan | |
* Version: 1.0 | |
* Text Domain: wfcm-clear-notifications | |
* Author URI: https://asharirfan.com/ | |
* License: GPL3 | |
* | |
* @package wfcm-clear-notifications | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; // Exit if accessed directly. | |
} | |
/** | |
* Clear WFCM notifications. | |
*/ | |
function wfcm_clear_notifications() { | |
$wfcm_events = get_posts( | |
array( | |
'post_type' => 'wfcm_file_event', | |
'post_status' => 'private', | |
'posts_per_page' => -1, | |
) | |
); | |
if ( ! empty( $wfcm_events ) ) { | |
foreach ( $wfcm_events as $wfcm_event ) { | |
wp_delete_post( $wfcm_event->ID, true ); | |
} | |
} | |
} | |
add_action( 'init', 'wfcm_clear_notifications' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment