Skip to content

Instantly share code, notes, and snippets.

View sewmyheadon's full-sized avatar

Eric Amundson sewmyheadon

View GitHub Profile
@sewmyheadon
sewmyheadon / pantheon-site-spinup.sh
Created July 2, 2018 19:47
Pantheon / Lando New Site Bash Script - run script locally to create Pantheon WordPress site and clone locally into new Lando environment
#!/bin/bash
# siteslug="SITE_SLUG"
read -p "Enter site slug: " siteslug
# sitename="SITE_NAME"
read -p "Enter site name: " sitename
read -p "Continue? (Y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1
@sewmyheadon
sewmyheadon / gist:1ccb6e7f5c6076a75620352cb538d5d5
Created June 1, 2018 18:11
WP-CLI search-replace on Pantheon
terminus wp mydomain.live -- search-replace 'dev-mydomain.pantheonsite.io' 'mydomain.com' --all-tables --dry-run
@sewmyheadon
sewmyheadon / pantheon-301-redirects.php
Last active January 17, 2018 00:36
how to redirect multiple urls at pantheon
// List of old urls and corresponding new target urls.
$redirects = array(
'/url_01' => '/new-url-01',
'/url_02' => '/new-url-02',
);
// Redirect multiple old to new urls.
// Note: make sure environment is set correctly
if ( isset( $_ENV['PANTHEON_ENVIRONMENT'] ) &&
( $_ENV['PANTHEON_ENVIRONMENT'] === 'dev' ) &&
@sewmyheadon
sewmyheadon / ee-jump-to-checkout-error.php
Created December 6, 2017 17:45
When a required field is missing upon checkout, this uses jQuery to scroll to the top.
/**
* Jump to error in EE checkout
*/
function ee_test_click_event_handler(){
wp_add_inline_script(
'ee_form_section_validation',
'jQuery( "#spco-go-to-step-finalize_registration-submit" ).click(function( event ) {
alert( "Handler for .click() called." );
});'
);
@sewmyheadon
sewmyheadon / event_espresso_load_custom_ticket_selector.php
Created August 3, 2017 23:03
Loads a custom ticket selector template. The original is at /event-espresso/modules/ticket-selector/templates/standard_ticket_selector.php
/**
* Add a custom ticket selector
*/
add_filter ('FHEE__EE_Ticket_Selector__display_ticket_selector__template_path', 'tip_custom_ticket_selector_template_location');
function tip_custom_ticket_selector_template_location(){
return get_stylesheet_directory() . '/tip_ticket_selector.template.php';
}
@sewmyheadon
sewmyheadon / gist:709d6d6e7de0bef366481d64202fd5bf
Created February 20, 2017 20:04
Inject new Administrator user into WordPress database via SQL / phpMyAdmin
INSERT INTO `wp_users` (`user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`)
VALUES ('myusername', MD5('mypass321'), 'FirstName LastName', 'me@myemailaddress.com', '0');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, (Select max(id) FROM wp_users), 'wp_user_level', '10');
@sewmyheadon
sewmyheadon / gist:988fbb1e367fb90d362058b2125399b6
Created February 7, 2017 01:37
Redirect all urls from an old domain to their corresponding location at a new domain.
# BEGIN HTTPS Redirect
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^old.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.old.com$
RewriteRule (.*)$ https://www.new.org/$1 [R=301,L]
</IfModule>
# END HTTPS Redirect
@sewmyheadon
sewmyheadon / gist:ac1e9f0a34ab2fa8f2624d9a78caf9b2
Created October 27, 2016 15:04 — forked from ChromeOrange/gist:8287925
Delete all tax rates from WooCommerce
/**
* Delete ALL WooCommerce tax rates
*
* Add to your theme functions.php then go to woocommerce -> system status -> tools and there will be a delete all tax rates button http://cld.wthms.co/tXvp
*/
add_filter( 'woocommerce_debug_tools', 'custom_woocommerce_debug_tools' );
function custom_woocommerce_debug_tools( $tools ) {
$tools['woocommerce_delete_tax_rates'] = array(
@sewmyheadon
sewmyheadon / gist:de6805d14367264bfdaf910f54c14cee
Created October 21, 2016 19:12
Add class to specific WordPress navigation menu link
/**
* Add class to specific WordPress navigation menu link
* Reference: https://codex.wordpress.org/Plugin_API/Filter_Reference/nav_menu_link_attributes
*/
add_filter('nav_menu_link_attributes', 'ivycat_account_secondary_menu_link_attributes', 10, 4);
function ivycat_account_secondary_menu_link_attributes($atts, $item, $args, $depth){
if ($args->menu->slug == 'utility' && $item->ID == 26){
$class = "account_button";
@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);