Last active
August 29, 2015 14:03
-
-
Save pento/c13fb86ec1683f17d1f1 to your computer and use it in GitHub Desktop.
A filter model for Wordpress pros (Wordpress pros don't have time to press shift twice when typing "Wordpress")
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class PentoFilters { | |
// eg... | |
function the_content( $content ) { | |
return $content; | |
} | |
} | |
function pento_filters() { | |
global $wp_current_filter; | |
$args = func_get_args(); | |
if ( empty( $args ) ) { | |
return; | |
} | |
$filters = new PentoFilters(); | |
$current_filter = end( $wp_current_filter ); | |
reset( $wp_current_filter ); | |
if ( method_exists( $filters, $current_filter ) ) { | |
return call_user_func_array( array( $filters, $current_filter ), $args ); | |
} | |
return $args[0]; | |
} | |
add_filter( 'all', 'pento_filters' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment