Last active
May 1, 2026 12:19
-
-
Save xlplugins/ed8e65ac15cff566b084e96d8c54e6d1 to your computer and use it in GitHub Desktop.
Plakatdyr theme compatibility
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: Plakatdyr — FunnelKit kundetype (MU) | |
| * Description: Theme customer-type radios on FunnelKit only; plakatdr CSS if missing; small #plakatdr-kundete override so WFACP’s global input[type=radio] rules do not break layout. | |
| * Version: 1.7.0 | |
| */ | |
| if ( ! defined( 'ABSPATH' ) ) { | |
| exit; | |
| } | |
| add_action( 'wfacp_checkout_page_found', 'plakatdyr_wfacp_kundete_register', 1, 2 ); | |
| add_action( 'wfacp_after_checkout_page_found', 'plakatdyr_wfacp_kundete_register', 1, 1 ); | |
| function plakatdyr_wfacp_kundete_register() { | |
| static $done = false; | |
| if ( $done ) { | |
| return; | |
| } | |
| $done = true; | |
| add_action( 'wp_enqueue_scripts', 'plakatdyr_wfacp_kundete_assets', 30 ); | |
| add_action( 'woocommerce_checkout_before_customer_details', 'plakatdyr_wfacp_kundete_echo', 5 ); | |
| add_filter( 'woocommerce_checkout_get_value', 'plakatdyr_wfacp_kundete_default', 100000, 2 ); | |
| } | |
| function plakatdyr_wfacp_kundete_assets() { | |
| $v = '1.7.0'; | |
| if ( ! wp_style_is( 'plakatdr', 'enqueued' ) && ! wp_style_is( 'plakatdr', 'to_print' ) ) { | |
| $base = get_template_directory(); | |
| $path = is_readable( $base . '/dist/main.min.css' ) ? '/dist/main.min.css' : '/style.css'; | |
| if ( is_readable( $base . $path ) ) { | |
| $u = (string) filemtime( $base . $path ); | |
| if ( ! wp_style_is( 'plakatdr', 'registered' ) ) { | |
| wp_register_style( 'plakatdr', get_template_directory_uri() . $path, [], $u ); | |
| } | |
| wp_enqueue_style( 'plakatdr' ); | |
| } | |
| } | |
| $deps = ( wp_style_is( 'plakatdr', 'registered' ) || wp_style_is( 'plakatdr', 'enqueued' ) ) ? [ 'plakatdr' ] : []; | |
| wp_register_style( 'plakatdr-wfacp-kundete', false, $deps, $v ); | |
| wp_enqueue_style( 'plakatdr-wfacp-kundete' ); | |
| $css = <<<'CSS' | |
| #wfacp-sec-wrapper #wfacp_checkout_form #plakatdr-kundete,#wfacp-e-form #wfacp_checkout_form #plakatdr-kundete{clear:both;width:100%;max-width:100%;margin:0 0 16px;box-sizing:border-box} | |
| #wfacp-sec-wrapper #wfacp_checkout_form #plakatdr-kundete input[type=radio],#wfacp-e-form #wfacp_checkout_form #plakatdr-kundete input[type=radio]{-webkit-appearance:auto!important;appearance:auto!important;position:static!important;float:none!important;clip:auto!important;opacity:1!important;display:inline-block!important;width:auto!important;height:auto!important;min-width:0!important;min-height:0!important;max-width:none!important;margin:0 6px 0 0!important;padding:0!important;vertical-align:middle;background:transparent!important;border:0!important;box-shadow:none!important;flex:0 0 auto!important;cursor:pointer} | |
| #wfacp-sec-wrapper #wfacp_checkout_form #plakatdr-kundete input[type=radio]:checked,#wfacp-e-form #wfacp_checkout_form #plakatdr-kundete input[type=radio]:checked{background:transparent!important;box-shadow:none!important} | |
| #wfacp-sec-wrapper #wfacp_checkout_form #plakatdr-kundete input[type=radio]::before,#wfacp-sec-wrapper #wfacp_checkout_form #plakatdr-kundete input[type=radio]::after,#wfacp-sec-wrapper #wfacp_checkout_form #plakatdr-kundete input[type=radio]:checked::before,#wfacp-sec-wrapper #wfacp_checkout_form #plakatdr-kundete input[type=radio]:checked::after,#wfacp-e-form #wfacp_checkout_form #plakatdr-kundete input[type=radio]::before,#wfacp-e-form #wfacp_checkout_form #plakatdr-kundete input[type=radio]::after,#wfacp-e-form #wfacp_checkout_form #plakatdr-kundete input[type=radio]:checked::before,#wfacp-e-form #wfacp_checkout_form #plakatdr-kundete input[type=radio]:checked::after{content:none!important;display:none!important} | |
| #wfacp-sec-wrapper #plakatdr-kundete .columns.is-mobile{margin:0 -6px}#wfacp-sec-wrapper #plakatdr-kundete .column{padding:0 6px;flex-grow:0} | |
| #wfacp-sec-wrapper #plakatdr-kundete .is-radio{display:inline-flex;align-items:center;white-space:nowrap;gap:6px} | |
| CSS; | |
| wp_add_inline_style( 'plakatdr-wfacp-kundete', $css ); | |
| } | |
| function plakatdyr_wfacp_kundete_default( $value, $key ) { | |
| if ( 'customer-type' === $key && ( null === $value || false === $value || '' === $value ) ) { | |
| return 'private'; | |
| } | |
| return $value; | |
| } | |
| function plakatdyr_wfacp_kundete_echo() { | |
| $checkout = function_exists( 'WC' ) ? WC()->checkout() : null; | |
| if ( ! $checkout ) { | |
| return; | |
| } | |
| $ct = (string) $checkout->get_value( 'customer-type' ); | |
| if ( '' === $ct ) { | |
| $ct = 'private'; | |
| } | |
| ?> | |
| <div id="plakatdr-kundete" class="company-toggle has-text-centered"> | |
| <div class="columns is-mobile is-centered"> | |
| <div class="column is-narrow"> | |
| <div class="field is-inline-flex justify-end"> | |
| <label class="is-radio"> | |
| <input name="customer-type" type="radio" value="private" <?php checked( $ct, 'private' ); ?> /> | |
| <?php echo esc_html( 'PRIVAT' ); ?> | |
| </label> | |
| </div> | |
| </div> | |
| <div class="column is-narrow"> | |
| <div class="field is-inline-flex"> | |
| <label class="is-radio"> | |
| <input name="customer-type" type="radio" value="company" <?php checked( $ct, 'company' ); ?> /> | |
| <?php echo esc_html( 'ERHVERV' ); ?> | |
| </label> | |
| </div> | |
| </div> | |
| <div class="column is-narrow"> | |
| <div class="field is-inline-flex"> | |
| <label class="is-radio"> | |
| <input name="customer-type" type="radio" value="institution" <?php checked( $ct, 'institution' ); ?> /> | |
| <?php echo esc_html( 'INSTITUTION' ); ?> | |
| </label> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| (function(){ | |
| var IDS = ['billing_company_field','billing_company_vat_field','billing_company_ean_field','billing_company_ean_user_id_field']; | |
| function move(){ | |
| var anchor = document.getElementById('plakatdr-kundete'); | |
| if(!anchor) return; | |
| IDS.forEach(function(id){ | |
| var el = document.getElementById(id); | |
| if(el && el.previousElementSibling !== anchor){ | |
| anchor.parentNode.insertBefore(el, anchor.nextSibling); | |
| } | |
| if(el) anchor = el; | |
| }); | |
| } | |
| if(window.jQuery){ | |
| jQuery(function(){ move(); }); | |
| jQuery(document.body).on('updated_checkout', move); | |
| } else { | |
| document.addEventListener('DOMContentLoaded', move); | |
| } | |
| })(); | |
| </script> | |
| <?php | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment