Skip to content

Instantly share code, notes, and snippets.

@gabrieleromanato
Created January 30, 2018 16:56
Show Gist options
  • Save gabrieleromanato/e6330a4517d7e04dab185a39125d1411 to your computer and use it in GitHub Desktop.
Save gabrieleromanato/e6330a4517d7e04dab185a39125d1411 to your computer and use it in GitHub Desktop.
Unnecessary WordPress overhead: the wp hook incorrect use
<?php
// Never ever use the wp hook to run unnecessary routines
// Global overhead ahead!
function my_factorial( $n ) {
if( function_exists( 'gmp_fact' ) ) {
return gmp_fact( $n );
} else {
if ( $n < 2 ) {
return 1;
} else {
return ( $n * my_factorial( $n - 1 ) );
}
}
}
function my_wp_func() {
$numbers = range( 1, 1000000 );
$factorials = array_map( 'my_factorial', $numbers );
}
add_action( 'wp', 'my_wp_func' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment