Created
April 18, 2017 10:01
-
-
Save reuhno/7ec0e59a628ef1254aaa844540b93a08 to your computer and use it in GitHub Desktop.
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 | |
function nettoyage_header() | |
{ | |
//Cache la barre d'admin du côté frontend | |
add_filter('show_admin_bar', '__return_false'); | |
//Retire la meta Generator avec la version de WP | |
add_filter('the_generator', '__return_false'); | |
remove_action( 'wp_head', 'wp_generator' ); | |
//Retire la meta Generator du Plugin RevSlider | |
add_filter('revslider_meta_generator','__return_false'); | |
//Désactive les scripts relatifs aux emoji's rajoutés par WP | |
add_action( 'init', 'disable_emojis' ); | |
// EditURI link | |
remove_action( 'wp_head', 'rsd_link' ); | |
// windows live writer | |
remove_action( 'wp_head', 'wlwmanifest_link' ); | |
// index link | |
remove_action( 'wp_head', 'index_rel_link' ); | |
// remove WP version from css | |
add_filter( 'style_loader_src', 'remove_wp_ver_css_js', 9999 ); | |
// remove Wp version from scripts | |
add_filter( 'script_loader_src', 'remove_wp_ver_css_js', 9999 ); | |
} | |
add_action( 'after_setup_theme', 'nettoyage_header', 20); | |
// retirer la version WP depuis le RSS | |
function laboiteare_rss_version() { return ''; } | |
// Retirer le P autour des IMG (http://css-tricks.com/snippets/wordpress/remove-paragraph-tags-from-around-images/) | |
function laboiteare_filter_ptags_on_images($content) | |
{ | |
return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content); | |
} | |
// remove WP version from scripts | |
function remove_wp_ver_css_js( $src ) { | |
if ( strpos( $src, 'ver=' ) ) | |
$src = remove_query_arg( 'ver', $src ); | |
return $src; | |
} | |
/** | |
* Disable the emoji's | |
*/ | |
function disable_emojis() { | |
remove_action( 'wp_head', 'print_emoji_detection_script', 7 ); | |
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); | |
remove_action( 'wp_print_styles', 'print_emoji_styles' ); | |
remove_action( 'admin_print_styles', 'print_emoji_styles' ); | |
remove_filter( 'the_content_feed', 'wp_staticize_emoji' ); | |
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' ); | |
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' ); | |
add_filter( 'tiny_mce_plugins', 'disable_emojis_tinymce' ); | |
} | |
/** | |
* Filter function used to remove the tinymce emoji plugin. | |
* | |
* @param array $plugins | |
* @return array Difference betwen the two arrays | |
*/ | |
function disable_emojis_tinymce( $plugins ) { | |
if ( is_array( $plugins ) ) { | |
return array_diff( $plugins, array( 'wpemoji' ) ); | |
} else { | |
return array(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment