Created
March 10, 2026 12:39
-
-
Save xlplugins/bfef8bd26776b09b790738bc2f42fe66 to your computer and use it in GitHub Desktop.
FunnelKit + Automatic CSS Checkout Fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Plugin Name: FunnelKit + Automatic CSS Checkout Fix | |
| * Description: Disables Automatic CSS on FunnelKit checkout. Add to mu-plugins. | |
| * | |
| * Automatic CSS uses a custom Style_Queue (not wp_styles), so wp_dequeue_style() has no effect. | |
| * The only way is to remove its wp_head callback. We find it by class and unset directly | |
| * since remove_action requires the exact object reference. | |
| */ | |
| add_action( 'template_redirect', 'funnelkit_disable_automaticcss_on_checkout', 1 ); | |
| function funnelkit_disable_automaticcss_on_checkout() { | |
| if ( ! function_exists( 'is_checkout' ) || ! is_checkout() ) { | |
| return; | |
| } | |
| // FunnelKit override: WFACP_Common::get_id() > 0, or option has override page | |
| $wfacp_id = class_exists( 'WFACP_Common' ) ? WFACP_Common::get_id() : 0; | |
| if ( $wfacp_id < 1 ) { | |
| $g = get_option( '_wfacp_global_settings', array() ); | |
| $wfacp_id = isset( $g['override_checkout_page_id'] ) ? absint( $g['override_checkout_page_id'] ) : 0; | |
| } | |
| if ( $wfacp_id < 1 ) { | |
| return; | |
| } | |
| global $wp_filter; | |
| if ( empty( $wp_filter['wp_head'] ) || ! ( $wp_filter['wp_head'] instanceof \WP_Hook ) ) { | |
| return; | |
| } | |
| $hook = $wp_filter['wp_head']; | |
| if ( empty( $hook->callbacks[1000000] ) ) { | |
| return; | |
| } | |
| $acss_class = 'Automatic_CSS\Framework\AssetManager\AssetManager'; | |
| foreach ( $hook->callbacks[1000000] as $key => $cb ) { | |
| if ( ! is_array( $cb['function'] ) || empty( $cb['function'][0] ) ) { | |
| continue; | |
| } | |
| if ( $cb['function'][0] instanceof $acss_class ) { | |
| remove_action( 'wp_head', $cb['function'], 1000000 ); | |
| return; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment