Skip to content

Instantly share code, notes, and snippets.

@pento
Last active August 29, 2015 14:03
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 pento/c13fb86ec1683f17d1f1 to your computer and use it in GitHub Desktop.
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")
<?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