Skip to content

Instantly share code, notes, and snippets.

View linkdigitaluk's full-sized avatar

Link Digital UK linkdigitaluk

View GitHub Profile
@linkdigitaluk
linkdigitaluk / functions.php
Last active August 6, 2019 07:04
[Autopopulate image data (WP)] Autopopulate the Alt, Title and Description fields, using the image name, when uploading an image through WordPress #WordPress #A11y
/** Set alt, title and description for image uploads */
function set_image_meta_upload( $post_ID ) {
if ( wp_attachment_is_image( $post_ID ) ) {
$my_image_title = get_post( $post_ID )->post_title;
$my_image_title = preg_replace( '%\s*[-_\s]+\s*%', ' ',
$my_image_title );
$my_image_title = ucwords( strtolower( $my_image_title ) );
$my_image_meta = array(
'ID' => $post_ID,
'post_title' => $my_image_title,
@linkdigitaluk
linkdigitaluk / wp-config.php
Last active August 2, 2019 08:45
[WordPress debug constant] WP_DEBUG options to enable and log errors but not show on the front-end #wordpress #wpconfig #php
/** WP Debug Settings */
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define( 'WP_DEBUG_DISPLAY', false );
@linkdigitaluk
linkdigitaluk / .htaccess
Last active February 20, 2020 13:38
[Leverage Browser Caching / Expire Headers] Improve Page Speed Ranking #wordpress #pagespeed #htaccess
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/js "access plus 1 month"