Created
November 17, 2015 12:53
-
-
Save kovshenin/5d0832518f50e8b2d3cd to your computer and use it in GitHub Desktop.
Some array callables for WordPress
This file contains hidden or 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 | |
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