callbacks ) ) { $callbacks = &$wp_filter[ $tag ]->callbacks; } else { $callbacks = &$wp_filter[ $tag ]; } // Exit if there aren't any callbacks for specified priority if ( ! isset( $callbacks[ $priority ] ) || empty( $callbacks[ $priority ] ) ) return FALSE; // Loop through each filter for the specified priority, looking for our class & method foreach( (array) $callbacks[ $priority ] as $filter_id => $filter ) { // Filter should always be an array - array( $this, 'method' ), if not goto next if ( ! isset( $filter[ 'function' ] ) || ! is_array( $filter[ 'function' ] ) ) continue; // If first value in array is not an object, it can't be a class if ( ! is_object( $filter[ 'function' ][ 0 ] ) ) continue; // Method doesn't match the one we're looking for, goto next if ( $filter[ 'function' ][ 1 ] !== $method_name ) continue; // Method matched, now let's check the Class if ( get_class( $filter[ 'function' ][ 0 ] ) === $class_name ) { // Now let's remove it from the array unset( $callbacks[ $priority ][ $filter_id ] ); // and if it was the only filter in that priority, unset that priority if ( empty( $callbacks[ $priority ] ) ) unset( $callbacks[ $priority ] ); // and if the only filter for that tag, set the tag to an empty array if ( empty( $callbacks ) ) $callbacks = array(); // If using WordPress older than 4.7 if ( ! is_object( $wp_filter[ $tag ] ) ) { // Remove this filter from merged_filters, which specifies if filters have been sorted unset( $GLOBALS[ 'merged_filters' ][ $tag ] ); } return TRUE; } } return FALSE; } /** * Remove Class Action Without Access to Class Object * * In order to use the core WordPress remove_action() on an action added with the callback * to a class, you either have to have access to that class object, or it has to be a call * to a static method. This method allows you to remove actions with a callback to a class * you don't have access to. * * Works with WordPress 1.2+ * * Supported for WordPress 4.7+ added on September 19, 2016 * * * @param string $tag Action to remove * @param string $class_name Class name for the action's callback * @param string $method_name Method name for the action's callback * @param int $priority Priority of the action (default 10) * * @return bool Whether the function is removed. */ function remove_class_action( $tag, $class_name = '', $method_name = '', $priority = 10 ) { remove_class_filter( $tag, $class_name, $method_name, $priority ); }