WordPress Snippets - markhowellsmead/helpers GitHub Wiki

Backend

Frontend

Remove generated tags from HEAD

remove_action('wp_head', 'wp_shortlink_wp_head');
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
remove_action('wp_head', 'wp_oembed_add_discovery_links');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'rsd_link');

Strip inline style= and <style> tags

add_filter( 'the_content', [ $this, 'stripInlineStyles' ], 10, 1 );

and

public function stripInlineStyles( $content ) {
	$content = preg_replace( '/ style=("|\')(.*?)("|\')/', '', $content );
	$content = preg_replace( '/<style\\b[^>]*>(.*?)<\\/style>/s', '<!-- INLINE CSS BLOCK REMOVED BY THE CURRENT THEME -->', $content );
	return $content;
}
⚠️ **GitHub.com Fallback** ⚠️