Just wondering what the preferred method of using anonymous functions is.
First I had some code like this:
function page_columns( $columns ) {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => 'Title',
'author' => 'Author',
'template' => 'Template',
'date' => 'Date'
);
return $columns;
}
add_filter('manage_edit-page_columns', 'page_columns');
But I know WordPress discourages using variables for things that will only be used once so I switched it to
function page_columns( $columns ) {
return array(
'cb' => '<input type="checkbox" />',
'title' => 'Title',
'author' => 'Author',
'template' => 'Template',
'date' => 'Date'
);
}
add_filter('manage_edit-page_columns', 'page_columns');
But now I'm thinking why even use a function at all?
add_filter('manage_edit-page_columns', function(){
return array(
'cb' => '<input type="checkbox" />',
'title' => 'Title',
'author' => 'Author',
'template' => 'Template',
'date' => 'Date'
);
});
What is the preferred method? Any reason why? Perhaps update the WordPress Coding Standards?
