Skip to content

Instantly share code, notes, and snippets.

@stuntbox
stuntbox / gist:4557917
Last active March 23, 2023 03:32
Slightly smarter filtering to remove hard-coded width and height attributes from *all* images in WordPress (post thumbnails, images inserted into posts, and gravatars). Handy for responsive designs. Add the code below to the functions.php file in your theme's folder (/wp-content/themes/theme-name/ ). Remember to rename the function as needed to …
/**
* Filter out hard-coded width, height attributes on all images in WordPress.
* https://gist.github.com/4557917
*
* This version applies the function as a filter to the_content rather than send_to_editor.
* Changes made by filtering send_to_editor will be lost if you update the image or associated post
* and you will slowly lose your grip on sanity if you don't know to keep an eye out for it.
* the_content applies to the content of a post after it is retrieved from the database and is "theme-safe".
* (i.e., Your changes will not be stored permanently or impact the HTML output in other themes.)
*
@BronsonQuick
BronsonQuick / gravity_forms_validation.php
Created April 12, 2012 09:51
Change the default validation message and add validation on default values in Gravity Forms
<?php
//This is a filter to change the default validation message that Gravity Forms generates
add_filter('gform_validation_message', 'change_validation_message', 10, 2);
function change_validation_message($message, $form)
{
return "<div class='validation_error'><strong>Oops!</strong> Looks like there’s something wrong. Please review the form above.</div>";
}
// Often forms in Gravity Forms to need to start with default values and we need to check the form in case the user hasn't entered new data and give them a validation message back
@billerickson
billerickson / functions.php
Last active September 24, 2016 23:36
Hide Editor on Specific Template Page
<?php
/**
* Hide Editor
* @author Bill Erickson
* @link http://www.billerickson.net/code/hide-editor-on-specific-page-template/
*/
function be_hide_editor() {
// Get the Post ID
@billerickson
billerickson / gist:1320990
Created October 27, 2011 21:53
Limit Gallery Metabox to Amenities Page Template
<?php
/**
* Limit Gallery Metabox to Amenities Page Template
* @author Bill Erickson
* @link http://www.wordpress.org/extend/plugins/gallery-metabox
* @since 1.0
*
* @param bool display metabox
* @param string post ID