Skip to content

Instantly share code, notes, and snippets.

@solepixel
solepixel / .htaccess
Last active February 13, 2024 15:00
This htaccess snippet (lines 4-12) will pull any missing images from another URL. Helpful when developing locally or on a staging site where media is present on production but is too much to migrate to staging or locally.
<IfModule mod_rewrite.c>
RewriteEngine On
# BEGIN Use uploads directory from Live Site
RewriteBase /wp-content/uploads/
RewriteCond %{HTTP_HOST} !^www\.livedomain\.com
RewriteCond %{HTTP_HOST} !^livedomain\.com
RewriteCond %{REQUEST_URI} ^/wp-content/uploads/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
@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 / index.html
Created June 3, 2013 20:53
Temporary index.html file for site launching.
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html" />
<meta name="author" content="Brian DiChiara" />
<title>Launching...</title>
<style type="text/css">
* { margin:0; padding:0; }
body, html, .container { background:#2f2f2f; }
p { margin:100px auto; text-align:center; font-size:0; width:373px; height:29px; background:url(http://assets.infomedia.net/launching.gif) no-repeat 50% 50%; }
@solepixel
solepixel / jquery.script.js
Last active June 15, 2022 02:24
Vertically and horizontally center Soliloquy slides while still keeping proportions. Emulating the "background-size: cover" with a standard slider. Slider configuration looks like this: Slider Dimensions: Full Width, Slider Position: Center, Use Adaptive Height: Yes, Crop Images in Slider: Yes
(function( $ ){
'use strict';
function auto_fit_soliloquy( parent_selector ){
// resize the slider container
var $soliloquy = $( parent_selector + ' .soliloquy-container'),
$all_items = $('.soliloquy-slider,.soliloquy-viewport,.soliloquy-item', $soliloquy ),
$container = $('.soliloquy-item', $soliloquy ),
window_height = $(window).height();
@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 / CPT-Letter-Anchors.php
Last active January 21, 2022 03:07
Generate Letter Anchors for your Custom Post Types in WordPress
<?php
$alphabet = range('A','Z');
$letters = array();
while( $the_query->have_posts() ) : $the_query->the_post();
$lname = get_post_meta(get_the_ID(), $prefix.'lname', true);
$first = strtoupper(substr(trim($lname), 0, 1));
if($first && !in_array($first, $letters)){
$letters[] = $first;
}
endwhile;
@solepixel
solepixel / acf-set-field-name.php
Created June 8, 2016 04:46
Differentiate Settings Page fields when using the same field groups. Requires "menu_slug" prefixed with something common and identifiable, in this case the Post Type of the Archive as well as a common naming convention, in this example it uses "-archive-settings".
<?php
add_filter( 'acf/load_field', 'mytheme_set_field_name' );
function mytheme_set_field_name( $field ){
if( is_admin() ){
$screen = get_current_screen();
if( $screen->id == 'acf-field-group' )
return $field;
@solepixel
solepixel / algolia-2.php
Last active October 27, 2020 04:35
Custom parameters for Algolia search in WordPress
<?php
add_filter( 'algolia_terms_index_settings', '__return_empty_array' );
add_filter( 'algolia_users_index_settings', '__return_empty_array' );
add_filter( 'algolia_posts_listing_index_settings', 'mytheme_algolia_listing_settings' );
function mytheme_algolia_listing_settings( $settings ){
$numeric_fields = array_keys( mytheme_algolia_faceted_fields( array( 'int', 'float' ) ) );
$string_fields = array_keys( mytheme_algolia_faceted_fields( 'string' ) );
@solepixel
solepixel / batch-download-images.sh
Created March 2, 2017 19:33
Use wget to batch download a list of image URLs
wget -i image-list.txt --force-directories
@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.