Skip to content

Instantly share code, notes, and snippets.

@solepixel
solepixel / activate-plugin.php
Created August 26, 2016 15:22
Originally design to activate Andrew Norcross's Airplane Mode plugin (https://github.com/norcross/airplane-mode), this little script will allow you to activate a plugin when the WordPress admin plugin screen cannot be loaded, for whatever reason.
<?php
/**
* This file will activate the Airplane Mode plugin if not already activated. This is helpful when you do not have internet connection and you're unable to reach the WP Admin Plugins page to activate the plugin.
*/
// get WP bootstrap
define('WP_USE_THEMES', false);
require(__DIR__ . '/wp/wp-blog-header.php');
@solepixel
solepixel / gravityform-shortcode-ui.php
Last active November 1, 2017 14:33
Enable Shortcode UI (Shortcake) for Gravity Forms
<?php
/**
* Registers Shortcode UI for gravityforms shortcode
*
* @package theme
*/
if ( ! function_exists( '_theme_gravityform_shortcode_ui' ) ) {
/**
@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;
<?php
public function sync_active() {
if( get_transient( 'rets_data_sync_active' ) )
return;
set_transient( 'rets_data_sync_active', 'PAUSE', HOUR_IN_SECONDS * 4 );
global $rets_sync_db;
$rets_sync_db->add_filter( 'field_L_Status', 'Active' );
$listings = $rets_sync_db->get_listings();
@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 / acf-sync-fields.php
Created December 30, 2015 10:20
Sync 2 relationship CPT fields in ACF that are connected. Example: Actors (Relationship Field) in a Movie (CPT), and Movies (Relationship field) an Actor (CPT) has been in.
<?php
function acf_sync_field( $sync_field, $value, $post_id, $field ){
// vars
$source_field = $field['name'];
$source_global_name = 'is_updating_' . $source_field;
$sync_global_name = 'is_updating_' . $sync_field;
// get this value early before anything is updated
@solepixel
solepixel / wave-drag-drop.js
Last active September 16, 2015 16:30
Drag and Drop Script for Wave
(function($) {
var waveDragDrop = {
init: function(){
this.setupInvoiceDragDrop();
this.setupEstimateDragDrop();
},
setupInvoiceDragDrop: function(){
jQuery(function($){
$('.gform_fields input[type="text"], .gform_fields input[type="email"], .gform_fields input[type="tel"], .gform_fields textarea').fadeLabel();
});
@solepixel
solepixel / sample.css
Created August 29, 2015 13:45
Sample CSS code (old blog post)
margin-bottom: 12px;
font: normal 1.1em "Lucida Sans Unicode", serif;
background: url(img/quote.gif) no-repeat;
padding-left: 28px;
color: #555;
@solepixel
solepixel / custom-sort.sql
Created August 29, 2015 13:43
Custom Sort Order in MySQL (order by case)
ORDER BY CASE
WHEN `col` = ‘item’ THEN 1
WHEN `col` = ‘thing’ THEN 2
WHEN `col` = ‘stuff’ THEN 3
WHEN `col` = ‘boom’ THEN 4
ELSE 5
END