Skip to content

Instantly share code, notes, and snippets.

@cyberwani
Forked from eteubert/activationhook.php
Created December 28, 2012 09:37
Show Gist options
  • Save cyberwani/4396417 to your computer and use it in GitHub Desktop.
Save cyberwani/4396417 to your computer and use it in GitHub Desktop.
<?php
class MyPlugin {
static function activation_hook() {
if ( ! version_compare( PHP_VERSION, '5.3.0', '>=' ) ) {
deactivate_plugins( __FILE__ );
wp_die( wp_sprintf( '%1s: ' . __( 'Sorry, This plugin has taken a bold step in requiring PHP 5.3.0+. Your server is currently running PHP %2s, Please bug your host to upgrade to a recent version of PHP which is less bug-prone.', 'myplugin' ), __FILE__ , PHP_VERSION ) );
}
}
}
register_activation_hook( __FILE__, array( 'MyPlugin', 'activation_hook' ) );
<?php
echo preg_replace_callback( '/^(Hello)\s(\w+)\s(World)$/', function ( $match ) {
return $match[ 1 ] . ', awesome ' . $match[ 3 ] . '!';
}, 'Hello cruel World' ); // => "Hello, awesome World!"
<?php
uasort( $array, function( $a, $b ) {
return $a > $b;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment