Product tabs (copy)

/** * Add a custom product data tab */ add_filter( ‘woocommerce_product_tabs’, ‘woo_new_product_tab’ ); function woo_new_product_tab( $tabs ) { // Adds the new tab $tabs[‘test_tab’] = array( ‘title’ => __( ‘Shipping Info’, ‘woocommerce’ ), ‘priority’ => 50, ‘callback’ => ‘woo_new_product_tab_content’ );…Continue reading

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

Add duplicate link to admin bar menu (copy)

add_action( ‘admin_bar_menu’, function ( $admin_bar ) { // Only show this when editing a post. $screen = get_current_screen(); if ( ! $screen || ‘post’ !== $screen->base ) { return; } $post = get_post(); $post_type_object = get_post_type_object( $post->post_type ); if (…Continue reading