Skip to content

Instantly share code, notes, and snippets.

@scarstens
Created February 21, 2015 01:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scarstens/840010696caf5cc544eb to your computer and use it in GitHub Desktop.
Save scarstens/840010696caf5cc544eb to your computer and use it in GitHub Desktop.
Example of overriding a "root level" function using a custom class. The example showcases how to override WordPress's pluggable.php function wp_mail, with a custom function.
<?php
class wpMandrill{
static function load(){
function wp_mail(){
echo 'custom mail';
}
}
}
wpMandrill::load();
if(!function_exists('wp_mail')) {
function wp_mail() {
echo 'default mail';
}
}
wp_mail();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment