A. Use a batch file called
oikwpor similar On its own, apart from loading a complete WordPress environment on the command line, oik-wp.php doesn’t do anything. You need something to run. There are two ways of implementing this.
- Write a routine for oik-wp to load and run directly.
- Write a routine for oik-wp to load, but defer execution until requested, by responding to the “run_$filename” action”, where $filename is the basename of the file.
myplugins.phpis a load and run routine.
oikwp.bat – Windows command for invoking oik-wp.php
rem Run oik-wp in batch mode so that you can test some code outwith the browser php c:apachehtdocswordpresswp-contentpluginsoik-batchoik-wp.php %*
Running oikwpHere we’ve developed a routine called
myplugins.phpthat will return information about plugins hosted on WordPress.org. It’s located in the plugin called
myplugins. We’re going to find out about Akismet and Jetpack. For each plugin the output shows: slug, downloads, current version, compatible up to, and requires.
cd apachehtdocswordpresswp-contentpluginsmypluginsmyplugins oikwp myplugins.php akismet,jetpack
Note: Since the
oik-wp running WordPress 4.6 C:apachehtdocswordpresswp-contentpluginsmyplugins cli Shifting argv There are: 2 akismet,51194511,3.1.11,4.5.3,3.2 jetpack,27768343,4.2.2,4.6,4.5 Script required once: myplugins.php Did: run_myplugins.php
myplugins.phproutine is dependent upon code provided by the oik base plugin ( e.g. bw_as_array() ) and uses WordPress APIs such wp_remote_get() we need to run it under
oik-wp.phpin a development environment where the oik base plugin is installed. It’s not worth trying to run it under