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

Improve detection of WP-cli #12

Open bobbingwide opened 8 years ago

bobbingwide commented 8 years ago

When the oik-wp plugin is activated and the main plugin file is loaded under WP-cli then it needs better detection of the invoking file.

In my original wp.bat file, WP-cli was being invoked using:

cd \apache\htdocs\wordpress\wp-content\plugin\wp-cli\php
php boot-fs.php %*

In order to be able to run WP-cli against different installations I've changed this to specify the fully qualified file name.

php \apache\htdocs\wordpress\wp-content\plugin\wp-cli\php\boot-fs.php %* 

oik-wp needs to be able to detect that boot-fs.php is only part of the argv[0] paramater.

Change if ( $_SERVER['argv'][0] == "boot-fs.php" ) { to if ( basename( $_SERVER['argv'][0] ) == "boot-fs.php" ) {

As this moment in time we don't expect to try running WP-cli under PHPUnit.

bobbingwide commented 7 years ago

Re-opening to cater for WP-cli being run as a phar. Test for the WP_CLI constant before testing for top level file. We might not need to check for the top level file.

bobbingwide commented 7 years ago

This is now implemented, though the detection of PHP CLI is not protected against the problem documented in #19.