Skip to content

Instantly share code, notes, and snippets.

@solepixel
solepixel / .htaccess
Created May 27, 2022
.htaccess Redirect All URLs from one domain to another
View .htaccess
# 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 Jan 30, 2020
This is my go-to package.json and gulpfile.js templates
View folder-structure.txt
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 Feb 25, 2020
Fixes Gravity Forms Custom Validation Message
View gf-custom-validation.php
<?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 Dec 20, 2018
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.
View wp-config.php
<?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 Oct 26, 2018
Serialize form inputs
View serializeObject.js
$.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 Jan 24, 2022
365 Days of Movies - A work in progress
View movie-calendar.md

365 Days of Movies

January 1 - Rocky

January 6 - Sherlock Holmes

January 11 - Goodfellas

January 20 - The Fugitive

@solepixel
solepixel / unzip.php
Created Jun 20, 2018
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.
View unzip.php
<?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 Jun 20, 2018
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.
View unzip.php
<?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 Nov 16, 2017
When ACF and The Events Calendar both register/enqueue the same script (select2), there are conflicts. This should resolve the issue.
View disable-tribe-select2-contextual.php
<?php
/**
* Disable Tribe Select2 on non-tribe admin pages
*/
function _theme_disable_tribe_select2() {
$screen = get_current_screen();
if ( 'tribe_events' === $screen->id ) {
return;
}
View functions.php
<?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;
}