-
Notifications
You must be signed in to change notification settings - Fork 130
Description
Loading Action Scheduler via Composer
When loading Action Scheduler via Composer, I need to autoload vendor/prospress/action-scheduler/action-scheduler.php which Composer supports natively 😃 .
"autoload": {
"files": [
"vendor/prospress/action-scheduler/action-scheduler.php"
]
},
This works great when action-scheduler.php is loaded within the context of WordPress.
The Problem with Autoloading action-scheduler.php
If a project is also using a PHP based development tool (e.g. PHP_CodeSniffer (phpcs)), that tool runs outside of the context of WordPress. Because of this when vendor/prospress/action-scheduler/action-scheduler.php is autoloaded, a Fatal Error is thrown because add_action() is not a defined function
Suggested Solution
By adding a function_exists( 'add_action' ) check before calling add_action(), we could skip this fatal error when a PHP based development tool is run and action-scheduler.php is autoloaded via Composer.
Thanks for this great library (and regardless of how I load it) it is a big help on my current project.
Thanks!