wp_schedule_event seems to be being added twice

I want to add to wp_schedule_event when the plugin is activated, the code I need does run on the hour, but seems to run twice and I can’t work out why, I expect I am doing something incorrect with the way I am calling this.

This is what I have

plugin.php file

namespace GrantName {
  if ( ! defined('ABSPATH' ) ){
  class Plugin {
    private static $instance = null;
    private static $plugin_dir;  

    private function __construct(){
      $autoloader_path = self::getPluginFilePath("/autoloader.php");

      new AdminSupport();
      $adminClass = new AdminSupport(); 
      **register_activation_hook(__FILE__, array($adminClass, 'my_activation'));
      register_deactivation_hook( __FILE__, array($adminClass,'my_deactivation' ));**



namespace GrantName;
class AdminSupport {

  public function onInitialize(){
    add_action('my_hourly_event', array($this, 'do_this_hourly' ));

  public function my_activation() {
    wp_schedule_event( time(), 'hourly', 'my_hourly_event' );

  public function do_this_hourly() {
    // do something every hour

  public function my_deactivation() {
    wp_clear_scheduled_hook( 'my_hourly_event' );

public function assessplugins(){
//Does some things


It seem that the scheduled tasks runs twice, one after the other. I installed a plugin to show the tasks and I see that the job has two actions (do_this_hourly() twice).

Can anyone see what I am doing wrong



Read more here: wp_schedule_event seems to be being added twice

Leave a Reply

Your email address will not be published. Required fields are marked *