callbacks ) ) { return; } try { $to_remove = array(); foreach ( $wp_filter['wp_loaded']->callbacks as $priority => $callbacks ) { foreach ( $callbacks as $cb ) { $fn = isset( $cb['function'] ) ? $cb['function'] : null; if ( ! is_array( $fn ) || ! isset( $fn[0], $fn[1] ) || ! is_object( $fn[0] ) ) { continue; } if ( 'register_block_patterns' !== $fn[1] ) { continue; } $basename = basename( str_replace( '\\', '/', get_class( $fn[0] ) ) ); if ( 'ProductFilterAttribute' === $basename ) { // Collect first — removing inside the loop mutates ->callbacks. $to_remove[] = array( $fn, (int) $priority ); } } } foreach ( $to_remove as $entry ) { remove_action( 'wp_loaded', $entry[0], $entry[1] ); } } catch ( \Throwable $e ) { unset( $e ); // Hook shape changed on this WC version — safe to ignore. } }, 0 ); }