wpce_enable_if v1.0
Filters whether to enable the WPCE on the given screen.
DEPRECATED
Please use the wpce_enable_for_post_types and wpce_enable_for_post filters instead.
See the deprecation section for more information.
Parameters
WPCE|bool $wpce_or_enabled_stateThe
WPCEinstance (or a boolean when other filters have already been applied).WP_Screen|object $screenThe screen that is checked. May be a mock object with just a
post_typeproperty where no screen is available.
Example
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 v3.20.
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.