DWS WP Framework
  • Welcome
  • Primary goals
    • Modular design
    • No 3rd-party dependencies
  • Key concepts and dev tools
    • PHP and WP requirements
    • Object-Oriented Programming
    • Semantic Versioning
    • Version Control (git / GitHub)
    • Dependency Management (Composer)
    • Automated Testing (Codeception + Github Actions)
    • Dependency Injection (PHP-DI)
    • Coding Standards (PHPCS and PHPMD)
    • Dependencies Scoping (PHP-Scoper)
    • TypeScript and Sass
    • Task Runners (Grunt)
  • Setting up your dev environment
    • Windows
  • Your first plugin
    • Multiple plugins using the framework on the same site
  • Frequently Asked Questions
  • Bootstrapper Module
    • Motivation
    • How it works
    • How to use
    • White Labeling
  • Helpers Module
    • Motivation
    • How to use
  • Foundations Module
    • Motivation and How to use
    • Actions
      • Local action traits
      • Extension action traits
      • Integration action traits
    • States
    • Utilities
      • Stores
      • Handlers and Services
        • Logging Service
  • Plugin
    • Main Plugin Instance
    • Plugin Components
  • Hierarchies
  • Helpers
  • Utilities Module
    • Motivation and How to use
    • Hooks Service
      • Scoped Handler
    • Shortcodes Service
    • Templating Service
    • Assets Service
      • Scripts Handler
      • Styles Handler
    • CRON Events Service
      • Action Scheduler Handler
    • Admin Notices Service
    • Dependencies Service
    • Validation Service
  • Core Module
    • Motivation and How to use
    • Plugin Tree
      • Plugin Root
      • Plugin Functionality
    • Plugin Components
      • Internationalization
      • Installation / Upgrade / Uninstallation
  • Settings Module
    • Motivation and How to use
    • Settings Service
      • WordPress Handler
      • MetaBox Handler
      • ACF Handler
    • Validated Settings
  • WooCommerce Module
    • Motivation and How to use
    • Extended WC Logger
    • WC Settings Handler
Powered by GitBook
On this page

Was this helpful?

  1. Utilities Module
  2. CRON Events Service

Action Scheduler Handler

PreviousCRON Events ServiceNextAdmin Notices Service

Last updated 4 years ago

Was this helpful?

Apart from the default WordPress handler, the utilities package provides a CRON Events Handler for working with the famous Action Scheduler library of WooCommerce. You can read more about the library .

This handler is not part of the WooCommerce Module simply because it's possible to use the Action Scheduler library outside of WooCommerce.

In order to work with it, you should register it with your CRON Events Service like this:

<?php

use DeepWebSolutions\Framework\Utilities\CronEvents\CronEventsService;
use DeepWebSolutions\Framework\Utilities\CronEvents\Handlers\ActionSchedulerCronEventsHandler;

$as_handler = new ActionSchedulerCronEventsHandler( 'my-handler-id' );

// you can register the handler in the constructor...
$cron_service = new CronEventsService( $my_plugin, $my_logging_service, $my_hooks_service, array( $as_handler ) );
// ...or alternatively you can also do this
$cron_service->register_handler( $as_handler );

// now to use it ... if you set your handler's ID to 'default', you can skip the last argument
$cron_service->schedule_single_event( 'my-hook', null, array(), 'my-handler-id' );

here