---
url: /hooks/filters/wpce-enable-if.md
description: >-
  Deprecated legacy filter for enabling WPCE on admin screens, replaced by the
  post-type and post-specific filters.
---

# `wpce_enable_if`&#x20;

Filters whether to enable the WPCE on the given screen.

:::warning DEPRECATED
Please use the [`wpce_enable_for_post_types`](./wpce-enable-for-post-types) and [`wpce_enable_for_post`](./wpce-enable-for-post.md) filters instead.

See [the deprecation section](#deprecation) for more information.
:::

## Parameters

1. `WPCE|bool $wpce_or_enabled_state`

   The [`WPCE`](https://bitbucket.org/ownbit/ownbit-wpce/src/dev/plugin/includes/WPCE.php) instance (or a boolean when other filters have already been applied).

2. `WP_Screen|object $screen`

   The screen that is checked. May be a mock object with just a `post_type` property where no screen is available.

## Example

```php
add_filter('wpce_enable_if', function ($wpce_or_enabled_state, $screen) {
  return in_array($screen->post_type, ['page', 'post']);
}, 10, 2);
```

## Deprecation

This hook has been deprecated in WPCE .

The filter stems from the earliest of times of the WPCE and is not properly designed to be a *filter*, as it receives the `$wpce` instance as its input but expects to return a boolean, thus not expecting the input value to be filtered more than once.

In addition, it expects the presence of a `WP_Screen` object, which is not always available.

However, as this filter is *very* widely used in OWNBIT projects, it is not worth to officially deprecate it and cause PHP deprecation messages to appear on customers' sites.

## Related

* [`wpce_enable_for_post_types`](./wpce-enable-for-post-types)
* [`wpce_enable_for_post`](./wpce-enable-for-post)
