Tag Archives: PHP

Conditional activation for plugins

In this post, I present a simple way to check for things on the server before allowing a plugin to be activated.

The users are pesky. They try to do things that the programmer cannot foresee. They happily install plugins without reading the readme files or the instructions. Then they complain, they downvote, they critizice. If only there was a way to check for these things: is the user running the plugin under the correct WordPress version, or if the necessary dependendencies are installed, or if PHP was compiled with such-and-such extensions. Then we’d let the user know about all this at the plugin activation time. What if this ability was coded as an easy-to-add drop-in class, instead of bloating existing plugin code? I couldn’t find it, so I made it, and now I’m sharing it with you. Continue reading

Tagged , ,

PHP 5.2 and Interface Default Arguments: Fatal error

Something happened on the way to PHP heaven. A customer reported a fatal error where my unit tests caught none… Continue reading

Tagged ,

Run a PHP script on the background in Windows

Use this:

pclose( popen( 'start /b ' . $path_to_php_exe . ' -f ' . $script_filename . ' -- ' . $args, 'r' ) );

Now something important to note: any output from your script will prevent the above from working, including error messages. The PHP process will hang on the background and waits for you to fread() the output. Also double-check the quotes and escaping in your filenames and arguments!

Tagged ,