Last active
February 4, 2016 10:03
-
-
Save KeSch/5be2394f61f6fd6e2272 to your computer and use it in GitHub Desktop.
Toolbox-Modul um das Laden von Contact Form 7 CSS und JavaScript Datein auf Seiten ohne Formular zu verhindern.
This file contains 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 | |
/* | |
Module Name: De-Register Contact Form 7 CSS & JavaScript | |
Module-URL: http://kevinschludermann.com/contact-form7/ | |
Description: Contact Form 7 CSS und JavaScript Dateien nur auf Seiten mit Formular laden. [Frontend] | |
Author: Kevin Schludermann | |
Author URI: http://kevinschludermann.com | |
*/ | |
/* Sicherheitsabfrage */ | |
if ( !class_exists('Toolbox') ) { | |
die(); | |
} | |
/* CF7 CSS-Files von Seiten ohne Formular entfernen */ | |
function ks_deregister_styles() { | |
/* 'kontakt' muss durch die Titelform (URl-Slug) der Seite mit eingebundenem Formular ersetzt werden */ | |
if ( ! is_page( 'kontakt' ) ) { | |
wp_deregister_style( 'contact-form-7' ); | |
} | |
} | |
add_action( 'wp_print_styles', 'ks_deregister_styles', 100 ); | |
/* CF7 JavaScript-Files von Seiten ohne Formular entfernen */ | |
function ks_deregister_javascript() { | |
/* 'kontakt' muss durch die Titelform (URl-Slug) der Seite mit eingebundenem Formular ersetzt werden */ | |
if ( ! is_page( 'kontakt' ) ) { | |
wp_deregister_script( 'contact-form-7' ); | |
} | |
} | |
add_action( 'wp_print_scripts', 'ks_deregister_javascript', 100 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment