Skip to content

Instantly share code, notes, and snippets.

@kovshenin
Created November 17, 2015 12:53
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kovshenin/5d0832518f50e8b2d3cd to your computer and use it in GitHub Desktop.
Save kovshenin/5d0832518f50e8b2d3cd to your computer and use it in GitHub Desktop.
Some array callables for WordPress
<?php
function __array_append( $item ) {
return function( $array ) use ( $item ) {
$array[] = $item;
return $array;
};
}
function __array_set( $key, $value ) {
return function( $array ) use ( $key, $value ) {
$array[ $key ] = $value;
return $array;
}
}
// Examples:
add_filter( 'body_class', __array_append( 'foo' ) );
add_filter( 'shortcode_atts_gallery', __array_set( 'columns', 4 ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment