Skip to content

Instantly share code, notes, and snippets.

@jnicol
jnicol / functions.php
Last active January 7, 2019 10:31
Sanitize WordPress filenames on upload
/**
* WordPress allows UTF8 characters such as copyright symbol in filenames but these break in Safari
*
* @see https://wordpress.org/support/topic/uploaded-image-with-accents-in-name-image-dont-show-in-safari-6 for original function
* @see https://core.trac.wordpress.org/ticket/22363 for progress on fixing this bug
*
* #wordpress
*/
function sanitize_filename_on_upload($filename) {
$ext = end(explode('.',$filename));
@andrewspear
andrewspear / functions.php
Last active July 6, 2017 08:10
Wordpress function to force Facebook to refresh it's cache as a scheduled post
<?
// Ping Facebook with (via a POST request) to refresh the cache (scrape) for a scheduled post as it is published
// Relevant docs: https://developers.facebook.com/docs/opengraph/using-objects#selfhosted-update
// Place this in your Wordpress functions.php file
add_action('transition_post_status', 'purge_future_post', 10, 3);
function purge_future_post($new_status, $old_status, $post) {
if($new_status == 'publish') {
@JiveDig
JiveDig / add_genesis_content_class.php
Created September 8, 2014 20:49
Add class to .content in Genesis
<?php
//* Add class to .content
add_filter( 'genesis_attr_content', 'beatm_facetwp_class' );
function beatm_facetwp_class( $attributes ) {
$attributes['class'] = $attributes['class']. ' facetwp-template';
return $attributes;
}