Skip to content

Instantly share code, notes, and snippets.

@brycejacobson
brycejacobson / gutenberg-color-pallet.php
Created August 10, 2018 14:32
Gutenberg Custom Color Pallet
<?php
/**
* Add support for custom color palettes in Gutenberg.
*/
function meta13_gutenberg_color_palette()
{
add_theme_support(
'editor-color-palette',
array(
array(
@brycejacobson
brycejacobson / navigation.js
Created May 22, 2018 18:01
Checking what-input and preventing dropdowns when input is touch
import $ from 'jquery';
import whatInput from 'what-input';
// Checking whatInput and stopping dropdowns on mobile
var html = document.querySelector('html');
var input = html.getAttribute('data-whatinput');
//console.log(input);
if(input == 'touch') {
$('.dropdown li:not(.no-mega-menu) a').click(function (e) {
@brycejacobson
brycejacobson / functions.php
Created May 11, 2018 21:56
Remove iPad from wp_is_mobile()
<?php
// Remove iPad from wp_is_mobile check
function my_wp_is_mobile()
{
static $is_mobile;
if (isset($is_mobile)) {
return $is_mobile;
}
@brycejacobson
brycejacobson / update_post_meta_acf.php
Created January 31, 2018 14:02
Update Post Meta on ACF Select Field
<?php
// Simple script used to touch/update post meta that was used in an Advanced Custom Fields select field that didn't have the reference field after an import of data thorugh a CSV. Running this script was enough to get the admin to dispaly the correct state that was already in the database.
require 'wp-config.php';
$things = get_posts(array('numberposts' => -1, 'post_type' => 'things')); // Change 'things' to the name of your post type
if (!$things) {
echo 'No Posts';
exit;
}
foreach ($things as $thing) {
update_post_meta($thing->ID, "state", 'MN'); // 'state' was the name of the custom post meta ACF field.
@brycejacobson
brycejacobson / wp-fix-curly-quotes.sql
Created December 19, 2017 22:50 — forked from chuckreynolds/wp-fix-curly-quotes.sql
SQL Statement Replace Smart Curly Quotes with Regular Quotes in WordPress. I was migrating an old wp site with a ton of content I noticed a lot of curly quotes / smart quotes and the curly single quotes. My OCD hates that and it's not proper and looks bad to bots so I wanted to batch change them all to regular ascii quotes. This statement handle…
UPDATE wp_posts SET post_content = replace(replace(replace(post_content, '“', '"'), '”', '"'), '’', '''');
@brycejacobson
brycejacobson / functions.php
Created August 15, 2017 19:28
Exclude page from BE Subpages Widget
<?php
add_filter('be_subpages_widget_args', 'bgcmn_subpages_widget_args');
/**
* Exclude page from Subpages Widget.
*
* @param array $args Array of arguments.
* @param array Modified array of arguments for get_pages().
*/
function bgcmn_subpages_widget_args($args)
{
@brycejacobson
brycejacobson / script.js
Created August 15, 2017 18:28
Gravity Forms Restrict Date Picker Date Range
<script type="text/javascript">
// Add the following to an HTML block on your form
gform.addFilter( 'gform_datepicker_options_pre_init', function( optionsObj, formId, fieldId ) {
if ( formId == 7 && fieldId == 220, 226, 243, 282, 290, 298, 348, 356, 364, 414, 422, 430 ) {
optionsObj.minDate = '+2'; // No letter for days
optionsObj.maxDate = '+1 Y'; // M for month, Y for years
}
return optionsObj;
} );
@brycejacobson
brycejacobson / functions.php
Created July 27, 2017 20:23
Testing passing info to auth.net from gravity forms.
<?php
add_filter('gform_authorizenet_transaction_pre_capture', 'bgcmn_kidstop_auth', 10, 5);
function bgcmn_kidstop_auth($transaction, $form_data, $config, $form, $entry)
{
// GFCommon::log_debug(__METHOD__ . "(): Entry => " . print_r($entry, true));
// error_log(print_r($transaction, true));
if ($form['id'] == 7) {
@brycejacobson
brycejacobson / functions.php
Last active July 26, 2017 14:03
Send extra info along to Authorize.net from Gravity Forms
<?php
// Functions for apending form name to authorize.net invoice
add_filter('gform_authorizenet_transaction_pre_capture', 'add_custom_field', 10, 5);
function add_custom_field($transaction, $form_data, $config, $form, $entry)
{
if ($form['id'] == 3) {
$donation_type = rgar($entry, '6');
$honor_memory = rgar($entry, '10');
@brycejacobson
brycejacobson / index.html
Last active July 19, 2017 15:33
Simple Page Load Transition
<div id="loader">
<div class="spinner"></div>
</div>