Skip to content

Instantly share code, notes, and snippets.

View uxjw's full-sized avatar

James Wilcox uxjw

  • Primal Communications Ltd.
  • BC, Canada
View GitHub Profile
@BrendonKoz
BrendonKoz / leaflet-darkmode.md
Last active March 19, 2024 08:29
Automatic Dark Mode for Leaflet.js
// Leaflet JS - note the *className* attribute
// [...]

L.tileLayer('https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png', {
    attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',
    className: 'map-tiles'
}).addTo(map);

// [...]
@OopsieWoopsie
OopsieWoopsie / cloudflare.sh
Created October 23, 2020 23:43
Only allow CloudFlare connections to your web server
#!/bin/bash
# This script downloads the actual list of CloudFlare's IPv4/6 ranges
# and allows them to connect to the 443 port (HTTPS) and drops
# connections from other addresses.
# This is to prevent DDoS attacks and attackers from using the "Host"
# header to identify your server backend address.
# download the lists and remove the trailing newline
ranges4=$(curl -s https://www.cloudflare.com/ips-v4 | head -c -1)
ranges6=$(curl -s https://www.cloudflare.com/ips-v6 | head -c -1)
@courtneymyers
courtneymyers / acf_modifications.php
Created February 28, 2018 18:36
Reduces initial height of Advanced Custom Fields WYSIWYG fields to 100px, and enables autoresizing of WYSIWYG field, as text is entered. Best practice would be to include this function in a site-specific plugin.
<?php
/*
* -----------------------------------------------------------------------------
* Advanced Custom Fields Modifications
* -----------------------------------------------------------------------------
*/
function PREFIX_apply_acf_modifications() {
?>
<style>
@raquelmsmith
raquelmsmith / webfaction-wp-cli.md
Last active February 12, 2021 23:24
How to install WP-CLI on WebFaction

I had difficulty installing WP-CLI properly on my WebFaction server because of the inability to use the sudo command to move the .phar file to the proper wp directory. The WebFaction support team was helpful as usual with some good instructions.

  1. Log in to your WebFaction account via SSH: https://docs.webfaction.com/user-guide/access.html
  2. Run the following command on the root directory: curl -so ~/bin/wp https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar It's probably a good idea to check the download URL there with the official WP-CLI installation instructions to make sure it hasn't changed.
  3. Run the following command: chmod u+x ~/bin/wp
  4. Check to make sure it's installed correctly with wp --info.
@sjaved87
sjaved87 / change_theme_on_all_subsites.php
Last active July 12, 2016 06:22
This mu-plugin will switch theme on all subsites (except main site) at once. Just change the theme directory slug, save chagnes and move it to wp-content/mu-plugins folder (create if not exists). Be care full if you have hundreds of sites then its not the right approach (will take some time and needs some resources) but good for handsome sites, …
<?php
function wpmu_change_theme_on_all_subsites(){
global $switched;
$theme_directory_slug = 'twentyfourteen';
$sites = wp_get_sites( $args );
if($sites){
@codearachnid
codearachnid / filter_gf_select_optgroup.php
Last active November 10, 2023 10:46
Add the optgroup ability to Gravity Forms default select field.
/**
* Filter Gravity Forms select field display to wrap optgroups where defined
* USE:
* set the value of the select option to `optgroup` within the form editor. The
* filter will then automagically wrap the options following until the start of
* the next option group
*/
add_filter( 'gform_field_content', 'filter_gf_select_optgroup', 10, 2 );
function filter_gf_select_optgroup( $input, $field ) {
@wpchannel
wpchannel / mu-yoast-seo-disable-notifications.php
Last active April 16, 2023 08:33
Hide annoying notifications after each upgrade of Yoast SEO plugin and others admin notices
<?php if (!defined('ABSPATH')) die('Restricted Area');
/*
* Plugin Name: Disable Yoast SEO Notifications
* Description: Hide annoying notifications after each upgrade of Yoast SEO plugin and others admin notices.
* Version: 1.1
* Author: Aurélien Denis
* Author URI: https://wpchannel.com/
*/
@yratof
yratof / functions.php
Created March 25, 2015 16:43
Advanced Custom Fields - Update Gallery with Gravity Forms
$gravity_form_id = 6; // gravity form id, or replace {$gravity_form_id} below with this number
add_filter("gform_after_submission_{$gravity_form_id}", 'jdn_set_post_acf_gallery_field', 10, 2);
function jdn_set_post_acf_gallery_field($entry, $form)
{
$gf_images_field_id = 42; // the upload field id
$acf_field_id = 'field_54804833b3067'; // the acf gallery field id
// get post
@idleberg
idleberg / Install-Mcrypt.md
Last active May 31, 2023 17:13
Install Mcrypt on macOS

Setup php-mcrypt on macOS (and versions of Mac OS X)

These steps should have been mentioned in the prerequisites of the Laravel Installation Guide, since I'm surely not the only person trying to get Laravel running on macOS.

Install

Install Mcrypt using Homebrew and PECL (comes with PHP)

# PHP 7.3