Skip to content

Instantly share code, notes, and snippets.

@solepixel
solepixel / .htaccess
Created May 27, 2022 16:08
.htaccess Redirect All URLs from one domain to another
# Redirect Requests to Live Site.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^stagingsite.net$ [NC]
RewriteRule ^(.*)$ https://livesite.com/$1 [R=301,L]
</IfModule>
@solepixel
solepixel / folder-structure.txt
Last active January 30, 2020 01:43
This is my go-to package.json and gulpfile.js templates
PROJECTNAME/
| bin -- Can be excluded from project distribution.
| images/ -- Images added here will be optimized.
| sass/
| blocks/
| BLOCKNAME/ -- SCSS files for BLOCKNAME.
| BLOCKNAME.scss -- Repeat for all blocks needed.
| PROJECTNAME.scss
| PROJECTNAME-admin.scss
| editor-styles.scss -- Admin editor specific styles.
@solepixel
solepixel / gf-custom-validation.php
Last active February 25, 2020 04:19
Fixes Gravity Forms Custom Validation Message
<?php
add_filter( 'gform_field_validation', 'mytheme_fix_custom_validation', 10, 4 );
/**
* Fixes Gravity Forms Custom validation message.
*
* @link https://docs.gravityforms.com/gform_field_validation/
*
* @param array $result The result array.
@solepixel
solepixel / wp-config.php
Created December 20, 2018 14:38
Enable WP_DEBUG on production sites - Only do this temporarily to find problems. Disable and delete wp-content/debug.log when you've resolved your issue.
<?php
// ^^ Other config settings such as database credentials. ^^
/**
* WordPress debugging mode.
*
* For information on other constants that can be used for debugging,
* visit the Codex.
*
@solepixel
solepixel / serializeObject.js
Last active October 26, 2018 19:03
Serialize form inputs
$.fn.serializeObject = function() {
var arrayData = this.serializeArray(),
objectData = {};
$.each( arrayData, function() {
var value;
if ( this.value != null ) {
value = this.value;
} else {
@solepixel
solepixel / movie-calendar.md
Last active August 9, 2023 02:37
365 Days of Movies - A work in progress. Each day corresponds with a date mentioned or relevant in the movie.

365 Days of Movies

January 1 - Rocky

January 6 - Sherlock Holmes

January 11 - Goodfellas

January 20 - The Fugitive

@solepixel
solepixel / unzip.php
Created June 20, 2018 16:09
When load balancers have set timeouts at 30 seconds, this script will process requests that may take longer than 30 seconds (up to 15 minutes) without causing a timeout.
<?php
$cmd = "zip -9prv content_backup.zip .";
$pipe = popen($cmd, 'r');
if (empty($pipe)) {
throw new Exception("Unable to open pipe for command '$cmd'");
}
stream_set_blocking($pipe, false);
echo "\n";
@solepixel
solepixel / unzip.php
Last active June 20, 2018 16:10
When load balancers have set timeouts at 30 seconds, this script will process requests that may take longer than 30 seconds (up to 15 minutes) without causing a timeout.
<?php
/**
* Source:
* @link https://web.archive.org/web/20160403212324/http://cloudsitesrock.com/?ac=list&cat=6&m=0&y=0
*/
$cmd = "zip -9prv content_backup.zip .";
$pipe = popen($cmd, 'r');
if (empty($pipe)) {
@solepixel
solepixel / disable-tribe-select2-contextual.php
Created November 16, 2017 16:29
When ACF and The Events Calendar both register/enqueue the same script (select2), there are conflicts. This should resolve the issue.
<?php
/**
* Disable Tribe Select2 on non-tribe admin pages
*/
function _theme_disable_tribe_select2() {
$screen = get_current_screen();
if ( 'tribe_events' === $screen->id ) {
return;
}
<?php
add_filter( 'wc_add_to_cart_params', 'kingcotton_remove_query_strings' );
add_filter( 'woocommerce_params', 'kingcotton_remove_query_strings' );
function kingcotton_remove_query_strings( $params ) {
$params['wc_ajax_url'] = '/?wc-ajax=%%endpoint%%';
return $params;
}