Skip to content

Instantly share code, notes, and snippets.

@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 Jun 16, 2020
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

February 2 - Groundhog Day

@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;
}
@solepixel
solepixel / acf-convert-text-to-taxonomy-multi-select.php
Created Aug 23, 2017
This gist will provide legacy support for the instance when you need to convert an ACF field from a plain text field to a multi-select taxonomy field. It will convert existing values to the proper array format and pull in and convert original values to array. WARNING: It does not create new terms. This could be added pretty easily tho, however o…
View acf-convert-text-to-taxonomy-multi-select.php
<?php
# create your taxonomy
# In this example, I'm using "landing-section-class" as the taxonomy
# Remove the unneeded meta box
add_action( 'admin_menu', '_briand_remove_landing_section_class_metabox' );
function _briand_remove_landing_section_class_metabox() {
remove_meta_box( 'tagsdiv-landing-section-class', 'page', 'side' );