WordPress Typography Enhancement: Preventing Widows in Conten

/** * Avoid Typography Widows */ function kl_avoid_content_widows( $content ) { $pattern = ‘@(?:\s)([[:punct:][:word:]]+)(?:\s)(?!/>)([[:punct:][:word:]]+)(?:\s)([[:punct:][:word:]]+)@m’; $replacement = ‘ $1 $2 $3‘; $content = preg_replace( $pattern, $replacement, $content, -1 ); return $content; } add_filter( ‘the_content’, ‘kl_avoid_content_widows’ );Continue reading

Enable HTTP Strict Transport Security (HSTS) in WordPress

/** * Enables the HTTP Strict Transport Security (HSTS) header in WordPress. * Includes preloading with subdomain support. */ function tg_enable_strict_transport_security_hsts_header_wordpress() { header( ‘Strict-Transport-Security: max-age=31536000; includeSubDomains; preload’ ); } add_action( ‘send_headers’, ‘tg_enable_strict_transport_security_hsts_header_wordpress’ );Continue reading

Override strings

add_filter( ‘gettext’, function ( $translated_text, $text, $domain ) { if ( $text == ‘Birthday (optional)’ ) { $translated_text = __( ‘Birthday’, ‘rug’ ); } return $translated_text; }, 20, 3 );Continue reading

Smush – Original Images

/** * Plugin Name: [Smush] – Original Images * Plugin URI: https://premium.wpmudev.org/ * Description: Displays all original images so they can be deleted. Requires Smush * Author: Panos Lyrakis @ WPMUDEV * Author URI: https://premium.wpmudev.org/ * License: GPLv2 or later…Continue reading