Closed Rayken closed 7 years ago
Thanks for the report. I've given this some thought, and I can certainly see a use case for this, but this is easy enough to solve with an anonymous closure and the use
statement.
I don't want to overcomplicate a parameter which is essentially a callable
and fits a widely used pattern.
Example of how you could achieve this:
add_filter( 'ext-cpts/my-cpt/args', function( $args ) {
$something_useful = 123;
$args['admin_cols']['my_custom_column'] = array(
'title' => __( 'Custom column name', 'textdomain' ),
'function' => function() use ( $something_useful ) {
Foo( $something_useful );
}
);
return $args;
});
So I've found the need to pass arguments to this function, therefore I'd suggest using
call_user_func_array
instead. Perhaps usingis_callable
to decide which to use? Anyhow the point is that I'm using namespaces and I'm adding custom admin columns after registering the post types and being able to provide arguments gives higher flexibility!https://github.com/johnbillion/extended-cpts/blob/master/extended-cpts.php#L1610
Edit: oh I guess the same goes for "filters" and "sortables" but not sure, haven't looked
Edit2: on second though, maybe simply something like
which in turn would mean I can do:
I think.