Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for custom column in admin. #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cjhaas
Copy link

@cjhaas cjhaas commented Mar 9, 2017

These changes allow custom columns to be displayed in the backend for groups using WordPress filters. To be clear, it doesn't add support to set these values, it just exposes filters for other plugins to add their own columns and value.

Usage:

//Add a new column that is not sortable
add_filter(
            'groups_admin_columns',
            function( $column_display_names )
            {
                return array_merge(
                                    $column_display_names,
                                    array(
                                            'test' => array( 'column_display_name' => 'Test' )
                                        )
                                );
            }
        );

//Render the custom column
add_filter(
            'groups_admin_columns_cell_html_contents_test',
            function( $cell_html_contents, $result )
            {
                return 'Custom test for group ' . $result->group_id;
            },
            10,
            2
        );

//Set the column's CSS classes
add_filter(
            'groups_admin_columns_cell_html_classes_test',
            function( $cell_html_classes, $result )
            {
                return array( 'test-column' );
            },
            10,
            2
        );

//Optionally change the cell's wrapper tag. No real good reason but consistent with other changes
add_filter(
            'groups_admin_columns_cell_html_tag_test',
            function( $cell_html_tag, $result )
            {
                return 'th';
            },
            10,
            2
        );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant