Advertisement
Guest User

Untitled

a guest
Feb 28th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. * Remove the annoying Wordfence Notifications. Tested with v6.3.2
  5. */
  6. class ahRWN_Remove_Wordfence_Notification {
  7. private $wordfencePluginFile;
  8. public function __construct() {
  9. $this->wordfencePluginFile = "wordfence/wordfence.php";
  10. register_activation_hook( $this->wordfencePluginFile, array( $this, 'rwn_remove_wordfence_notifications_on_activation' ) );
  11. // Only disable notifications if Wordfence is active
  12. if ( defined( 'WORDFENCE_VERSION' ) ) {
  13. add_action( 'upgrader_process_complete', array( $this, 'rwn_remove_wordfence_notification_after_update' ), 11, 2 );
  14. }
  15. }
  16.  
  17. /*
  18. * Check if Wordfence has been activated and remove notifications
  19. */
  20. function rwn_remove_wordfence_notifications_on_activation() {
  21. // If this constant is defined we know Wordfence has been activated
  22. if ( defined( 'WORDFENCE_VERSION' ) ) {
  23. ahRWN_Remove_Wordfence_Notification::rwn_remove_wordfence_notification();
  24. }
  25. }
  26.  
  27. /*
  28. * Remove Wordfence Notifications after plugin has been updated
  29. */
  30. function rwn_remove_wordfence_notification_after_update( $upgrader_object, $options ) {
  31. // Wordfence will update its notifcations when plugins are updated so lets remove them at the same time
  32. if ( current_user_can( 'manage_options' ) ) {
  33. ahRWN_Remove_Wordfence_Notification::rwn_remove_wordfence_notification();
  34. }
  35. }
  36.  
  37. /*
  38. * Turn off any active Wordfence Notifications
  39. */
  40. private function rwn_remove_wordfence_notification() {
  41. global $wpdb;
  42. $tableprefix = $wpdb->base_prefix;
  43.  
  44. $wpdb->update(
  45. $tableprefix.'wfNotifications',
  46. array('new' => 0),
  47. array( 'new' => 1 )
  48. );
  49.  
  50. }
  51. }
  52.  
  53. new ahRWN_Remove_Wordfence_Notification();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement