I have two custom plugins that use the [WP Logging](https://github.com/pippinsplugins/wp-logging) class. It creates a custom post type called Logs, which (at least in my case) is only visible inside the admin, for example at /wp-admin/edit.php?s&post\_status=all&post\_type=wp\_log.

To make it easier to tell which plugin is creating the logs, I've added a few hooks. Both plugins use them identically. What they do is:

1. Add a sortable Type column to the manage posts screen, and add the type field (which the WP Logging library adds) to that screen.
2. Add a dropdown to the top of the screen (next to the date filter) and allow the posts to be filtered by which type value they use.

Here's the code I'm using:

```
// add a sortable Type column to the posts admin
add_filter( 'manage_edit-wp_log_columns', array( $this, 'type_column' ), 10, 1 );
add_filter( 'manage_edit-wp_log_sortable_columns', array( $this, 'sortable_columns' ), 10, 1 );
add_action( 'manage_wp_log_posts_custom_column', array( $this, 'type_column_content' ), 10, 2 );

// filter the log posts admin by log type
add_filter( 'parse_query', array( $this, 'posts_filter' ), 10, 1 );
add_action( 'restrict_manage_posts', array( $this, 'restrict_log_posts' ) );

/**
 * Add a Type column to the posts admin for this post type
 *
 * @param array $columns
 * @return array $columns
 */
public function type_column( $columns ) {
    $columns['type'] = __( 'Type', 'form-processor-mailchimp' );
    return $columns;
}

/**
 * Make the Type column in the posts admin for this post type sortable
 *
 * @param array $columns
 * @return array $columns
 */
public function sortable_columns( $columns ) {
    $columns['type'] = 'type';
    return $columns;
}

/**
 * Add the content for the Type column in the posts admin for this post type
 *
 * @param string $column_name
 * @param int $post_id
 */
public function type_column_content( $column_name, $post_id ) {
    if ( 'type' != $column_name ) {
        return;
    }
    // get wp_log_type
    $terms = wp_get_post_terms(
        $post_id,
        'wp_log_type',
        array(
            'fields' => 'names',
        )
    );
    if ( is_array( $terms ) ) {
        echo esc_attr( $terms[0] );
    }
}

/**
 * Filter log posts by the taxonomy from the dropdown when a value is present
 *
 * @param object $query
 * @return object $query
 */
public function posts_filter( $query ) {
    global $pagenow;
    $type     = 'wp_log';
    $taxonomy = 'wp_log_type';
    if ( is_admin() && 'edit.php' === $pagenow ) {
        if ( isset( $_GET['post_type'] ) && esc_attr( $_GET['post_type'] ) === $type ) {
            if ( isset( $_GET[ $taxonomy ] ) && '' !== $_GET[ $taxonomy ] ) {
                $query->post_type = $type;
                $query->tax_query = array(
                    array(
                        'taxonomy' => $taxonomy,
                        'field'    => 'slug',
                        'terms'    => esc_attr( $_GET[ $taxonomy ] ),
                    ),
                );
            }
        }
    }
}

/**
 * Add a filter form for the log admin so we can filter by wp_log_type taxonomy values
 *
 * @param object $query
 * @return object $query
 */
public function restrict_log_posts() {
    $type     = 'wp_log';
    $taxonomy = 'wp_log_type';
    // only add filter to post type you want
    if ( isset( $_GET['post_type'] ) && esc_attr( $_GET['post_type'] ) === $type ) {
        // get wp_log_type
        $terms = get_terms(
            [
                'taxonomy'   => $taxonomy,
                'hide_empty' => true,
            ]
        );
        ?>
        <select name="wp_log_type">
            <option value=""><?php _e( 'All log types ', 'form-processor-mailchimp' ); ?></option>
            <?php
            $current_log_type = isset( $_GET[ $taxonomy ] ) ? esc_attr( $_GET[ $taxonomy ] ) : '';
            foreach ( $terms as $key => $term ) {
                printf(
                    '<option value="%s"%s>%s</option>',
                    $term->slug,
                    $term->slug == $current_log_type ? ' selected="selected"' : '',
                    $term->name
                );
            }
            ?>
        </select>
        <?php
    }
}

```

The code is identical between the two plugins in this case. Of course the problem, if it's enabled in both plugins, is that it duplicates the display.

[![posts manage screen with two identical type dropdowns, and the type displayed twice in the column](https://i.stack.imgur.com/9eoSy.png)](https://i.stack.imgur.com/9eoSy.png)

Is there any way I can check to see if these additions have already been made before making them?

I thought this was worth a try (on all the filters, and using `doing_action` on all the actions):

```
if ( ! doing_filter( 'manage_edit-wp_log_columns' ) ) {
    add_filter( 'manage_edit-wp_log_columns', array( $this, 'type_column' ), 10, 1 );
}

```

But it didn't change anything. Is there anything else I can try on this?