Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * Remove the annoying Wordfence Notifications. Tested with v6.3.2
- */
- class ahRWN_Remove_Wordfence_Notification {
- private $wordfencePluginFile;
- public function __construct() {
- $this->wordfencePluginFile = "wordfence/wordfence.php";
- register_activation_hook( $this->wordfencePluginFile, array( $this, 'rwn_remove_wordfence_notifications_on_activation' ) );
- // Only disable notifications if Wordfence is active
- if ( defined( 'WORDFENCE_VERSION' ) ) {
- add_action( 'upgrader_process_complete', array( $this, 'rwn_remove_wordfence_notification_after_update' ), 11, 2 );
- }
- }
- /*
- * Check if Wordfence has been activated and remove notifications
- */
- function rwn_remove_wordfence_notifications_on_activation() {
- // If this constant is defined we know Wordfence has been activated
- if ( defined( 'WORDFENCE_VERSION' ) ) {
- ahRWN_Remove_Wordfence_Notification::rwn_remove_wordfence_notification();
- }
- }
- /*
- * Remove Wordfence Notifications after plugin has been updated
- */
- function rwn_remove_wordfence_notification_after_update( $upgrader_object, $options ) {
- // Wordfence will update its notifcations when plugins are updated so lets remove them at the same time
- if ( current_user_can( 'manage_options' ) ) {
- ahRWN_Remove_Wordfence_Notification::rwn_remove_wordfence_notification();
- }
- }
- /*
- * Turn off any active Wordfence Notifications
- */
- private function rwn_remove_wordfence_notification() {
- global $wpdb;
- $tableprefix = $wpdb->base_prefix;
- $wpdb->update(
- $tableprefix.'wfNotifications',
- array('new' => 0),
- array( 'new' => 1 )
- );
- }
- }
- new ahRWN_Remove_Wordfence_Notification();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement