Skip to content

Instantly share code, notes, and snippets.

View styledev's full-sized avatar

Dewey Bushaw styledev

  • Speak4
  • Arlington, VA
View GitHub Profile
@styledev
styledev / index.php
Created November 15, 2024 16:24
Fix issues between FacetWP with a custom (e.g. not main query) WP_Query and Theme My Login
<?php
add_filter('facetwp_is_main_query', filter_facetwp_is_main_query, 10, 2 );
function filter_facetwp_is_main_query( $is_main_query, $query ) {
if ( 'template' == $query->get('post_type') ) $is_main_query = FALSE;
return $is_main_query;
}
@styledev
styledev / magic-login-pro-time-expire-basedon-redirect.php
Last active November 6, 2024 00:35
Magic Login Pro - Change Time expiration based on redirect_to
<?php
add_filter('sanitize_user_meta_magic_login_token', 'filter_sanitize_user_meta_magic_login_token', 10, 1);
function filter_sanitize_user_meta_magic_login_token( $meta_value ) {
$redirect_to = $_POST['redirect_to'] ?? FALSE;
if ( $redirect_to && strpos($redirect_to, '/investor-resources/') > -1 ) {
$days = get_field('resource_token_ttl', 'options') ?? 3;
@styledev
styledev / godaddy-dns-change-nameservers.js
Created October 16, 2024 18:17
DevTools Snippet: GoDaddy DNS Change Nameservers
var buttonChange = document.querySelector('#dns-content-nameservers button');
buttonChange.click();
setTimeout(function() {
var radioCustom = document.querySelector('#nameserver-type-CUSTOM'),
list = ['new nameserver #1', 'new nameserver #2', 'new nameserver #3', 'new nameserver #4'];
radioCustom.click();
@styledev
styledev / gist:c3e65924cd55c85cd4d4b4e691cd880c
Created June 11, 2024 22:54
.htaccess load remote resources if not found locally
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteRule ^(.*\.(js|css|png|jpe?g|gif|ico)) https://domainname.com/$1 [QSA,L,C]
</IfModule>
@styledev
styledev / .tm_properties
Created November 21, 2018 00:49
Textmate Properties
# Basic Settings
#
fontName = "Monaco"
fontSize = 16
# Extra files to include
#
myExtraIncludes = ".tm_properties,.htaccess,.gitignore"
fileBrowserGlob = "{*,$myExtraIncludes}"
include = "{$include,$myExtraIncludes}"
@styledev
styledev / WP All Import - pmxi_saved_post
Created October 10, 2018 22:34
A WordPress Action to sideload images into your site from the imported post content.
function action_pmxi_saved_post( $id ) {
$dir = wp_upload_dir();
$img_array = [];
$media = get_attached_media('image', $id);
$thepost = get_post($id);
foreach($media as $media_id => $item) {
$metadata = wp_get_attachment_metadata($item->ID, true);
$directory = explode('/', $metadata['file']);
@styledev
styledev / .htaccess
Created June 21, 2018 17:50
Apache mod_rewrite.c code for WordPress to load images from a production server if not found locally. Replace https://www.example.com with your production URL.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteRule ^(.*\.(js|css|png|jpe?g|gif|ico)) https://www.example.com/$1 [QSA,L,C]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
@styledev
styledev / Apache2 User Conf
Last active August 26, 2023 00:42
A OS X Apache2 User Conf file to use with Dnsmasq
# Virtual Hosts
#
# Required modules: mod_log_config
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
@styledev
styledev / number.php
Created June 18, 2013 18:34
Updated create_field to set step to "any" if option is not specified.
function create_field( $field )
{
$o = array( 'id', 'class', 'min', 'max', 'step', 'name', 'value' );
$e = '<input type="number"';
foreach( $o as $k )
{
$val = $field[ $k ];
if ( $k == 'step' && empty($val) ) $val = 'any';
$e .= ' ' . $k . '="' . esc_attr( $val ) . '"';
@styledev
styledev / acf-location-field-acf_form.php
Created June 13, 2013 20:24
How to get the ACF Location Field to show the map when using acf_form().
add_action('wp_head', 'form_acf', 10 );
public function form_acf() {
if ( is_page('Add an Opportunity') ) {
echo '<script src="https://maps.googleapis.com/maps/api/js?sensor=false" type="text/javascript"></script>';
acf_form_head();
}
}