bobbingwide / oik-batch

Batch interface to WordPress
https://www.oik-plugins.com/oik-plugins/oik-batch
GNU General Public License v2.0
0 stars 0 forks source link

Support direct invocation of batch logic in a plugin #2

Closed bobbingwide closed 8 years ago

bobbingwide commented 8 years ago

The first version of the schunter routine was originally developed to run as a batch process. When the schunter.php file was loaded ran the logic to hunt for shortcodes. Now that there's a rudimentary admin interface the batch logic should only run when invoked in a batch environment. We need a simple API to allow a plugin to decide what it should be doing.

Proposed solution

Develop some functions for oik-wp.php that will allow a plugin to determine whether or not it should be running its batch logic.

oik_batch_load_cli_functions() will load the 'oik-cli' library logic which will provide oik_batch_run_me() oik_batch_run_me() will return true if the plugin is being run directly or if it's being run under oik-wp.php with the first parameter being the plugin's basename.

Note: The current solution contains duplicated functions in oik-wp.php and oik-batch.php. These should be migrated into a shared library.