Skip to content

Instantly share code, notes, and snippets.

View sewmyheadon's full-sized avatar

Eric Amundson sewmyheadon

View GitHub Profile
@sewmyheadon
sewmyheadon / WP Query Order - Alpha
Created March 5, 2013 17:57
Modify WordPress query order - alphabetical
function smho_modify_query_order ( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'orderby', 'title' );
$query->set( 'order', 'ASC' );
}
}
add_action( 'pre_get_posts', 'smho_modify_query_order' );
@sewmyheadon
sewmyheadon / gist:6196739
Created August 9, 2013 20:04
Redirect all pages from one domain to their counterpart on a new domain via .htaccess
RewriteEngine on
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]
@sewmyheadon
sewmyheadon / .gitignore
Last active August 29, 2015 14:00 — forked from octocat/.gitignore
Basic .gitignore file
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@sewmyheadon
sewmyheadon / gist:9f587b6d0648a51a8c7b
Created October 2, 2014 08:27
Use shortcodes in WordPress widgets
<!-- use shortcodes in widgets -->
add_filter('widget_text', 'do_shortcode');
@sewmyheadon
sewmyheadon / bootstrap-gforms.php
Last active March 8, 2018 15:01
Add Bootstrap styles to Gravity Forms fields
/**
* Adding Bootstrap Styles to Gravity Forms
*/
add_filter("gform_field_content", "bootstrap_styles_for_gravityforms_fields", 10, 5);
function bootstrap_styles_for_gravityforms_fields($content, $field, $value, $lead_id, $form_id){
// Currently only applies to most common field types, but can be expanded.
if($field["type"] != 'hidden' && $field["type"] != 'list' && $field["type"] != 'multiselect' && $field["type"] != 'checkbox' && $field["type"] != 'fileupload' && $field["type"] != 'date' && $field["type"] != 'html' && $field["type"] != 'address') {
$content = str_replace('class=\'medium', 'class=\'form-control medium', $content);
@sewmyheadon
sewmyheadon / gist:bbf7c79c56628a54d22d
Created June 8, 2015 20:47
Fix Gravity Form Tabindex Conflicts
/**
* Fix Gravity Form Tabindex Conflicts
* http://gravitywiz.com/fix-gravity-form-tabindex-conflicts/
*/
add_filter( 'gform_tabindex', 'gform_tabindexer', 10, 2 );
function gform_tabindexer( $tab_index, $form = false ) {
$starting_index = 1000; // if you need a higher tabindex, update this number
if( $form )
add_filter( 'gform_tabindex_' . $form['id'], 'gform_tabindexer' );
return GFCommon::$tab_index >= $starting_index ? GFCommon::$tab_index : $starting_index;
@sewmyheadon
sewmyheadon / woocommerce-sage-template-part-overrides.md
Last active August 29, 2015 14:25 — forked from drawcard/woocommerce-sage-template-part-overrides.md
Woocommerce - Using template part overrides in Sage

So, you know how to override a template file in Woocommerce using Sage, but you're having trouble changing something within the deeper level of that template file. For example, you want to change the output HTML structure of a given part of the product page loop, or incorporate a Bootstrap class into a button element without using Jquery to inject it. Here's how you can override deeper level parts, the default WC theme elements.

Prerequisites

Now you're familiar with how to do Sage + Woocommerce templates, it's time to make it happen.

The template page override

@sewmyheadon
sewmyheadon / htaccess_https_redirect.txt
Last active October 16, 2016 20:13
.htaccess redirect all urls to load via https
# BEGIN HTTPS Redirect
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
# END HTTPS Redirect
@sewmyheadon
sewmyheadon / .gitignore
Last active October 18, 2016 21:14 — forked from salcode/.gitignore
.gitignore for WordPress
# -----------------------------------------------------------------
# .gitignore for WordPress ver 20161009
# -----------------------------------------------------------------
#
# This file:
# • is for WordPress sites using the default file/folder structure,
# • specifies which files are tracked/untracked by git.
#
# .gitignore docs:
# https://git-scm.com/docs/gitignore
@sewmyheadon
sewmyheadon / gist:326cd4138e23408992ac7874f095cf6f
Last active October 20, 2016 14:50
Hide gravity forms field labels on focus or input
**
* Remove labels from Gravity Forms form fields on focus and input
* Can easily be adapted to forms of any origin
*/
jQuery(function ($) {
jQuery.fn.labelOver = function(overClass) {
return this.each(function(){
var label = jQuery(this);