You appear to be a bot. Output may be restricted
Description
Run a script in batch
Usage
oik_batch_run_script( $script );
Parameters
- $script
- ( string ) required – the file to load and run
Returns
voidTO DO
Check these comments If the file name given is in the form of a plugin file name e.g. plugin/plugin.php then we can invoke it using oik_path() If it's just a simple name then we assume it's in the ??? folder and we need to append .php and invoke it using oik_path() If it's a fully specified file name that exists then we call it directly. The script can be run by simply loading the file and/or it can implement an action hook for "run_$script"Source
File name: oik-batch/libs/oik-cli.phpLines:
1 to 30 of 30
function oik_batch_run_script( $script ) { if ( file_exists( $script ) ) { oik_require( "oik-login.inc", "oik-batch" ); require_once( $script ); echo "Script required once: $script" . PHP_EOL; do_action( "run_$script" ); echo "Did: run_$script" . PHP_EOL; } else { $script_parts = pathinfo( $script ); print_r( $script_parts ); $dirname = bw_array_get( $script_parts, "dirname", null ); if ( $dirname == "." ) { $dirname = "oik-wp"; // @TODO - make it choose the current directory $dirname = "oik-batch"; // @TODO - make it choose the current directory } $filename = bw_array_get( $script_parts, "filename", null ); $extension = bw_array_get( $script_parts, "extension", ".php" ); $required_file = WP_PLUGIN_DIR . "/$dirname/$filename$extension"; echo $required_file . PHP_EOL; if ( file_exists( $required_file ) ) { require_once( $required_file ); } else { echo "Cannot find script to run: $required_file" . PHP_EOL; } // Should this call do_action( "run_$??? " ). If so, what's $??? // How does WP-cli work? } }View on GitHub