Skip to content

Instantly share code, notes, and snippets.

@mjones129
mjones129 / admin_email_update.sql
Created April 4, 2024 18:21
Update WordPress Admin Email
-- display the current admin email
select * from wp_options where option_name = 'admin_email';
--update admin email
update wp_options set option_value = '[email protected]' where option_name = 'admin_email';
@mjones129
mjones129 / functions.php
Last active March 29, 2024 14:37
Fix ACF Version 6.2.7 Security Release (add to functions.php)
<?php
add_filter('wp_kses_allowed_html', 'acf_add_allowed_iframe_tag', 10, 2);
function acf_add_allowed_iframe_tag($tags, $context) {
if($context === 'acf') {
$tags['iframe'] = array(
'src' => true,
'height' => true,
'width' => true,
'frameborder' => true,
@mjones129
mjones129 / functions.php
Created February 26, 2024 18:55
Filter URLs from Gravity Forms Comment Box or Text Area
<?
//prevent gravity forms submissions containing URLS
//filter hook 'gform_field_validation_1_12' identifies a Gravity Form with an ID of 1 and a Field ID of 12
//second argument for the filter can be anything, it's just referencing the name of the function to run
add_filter( 'gform_field_validation_1_12', 'validate_input_1_12', 10, 4 );
function validate_input_1_12( $result, $value, $form, $field ) {
$nourl_pattern = '(ftp|http|https|www|.com|.net|.org|.io|.biz|.info|.mil|.edu|.gov|.me|.int|FTP|HTTP|HTTPS|WWW|.COM|.NET|.ORG|.IO|.BIZ|.INFO|.MIL|.EDU|.GOV|.ME|.INT)';
if (preg_match( $nourl_pattern, $value ) ) {
@mjones129
mjones129 / installTerminus.sh
Last active April 16, 2024 21:01
Install Terminus
#!/bin/bash
#update all the things
sudo apt update &&
sudo apt upgrade -y &&
#install all the dependencies
@mjones129
mjones129 / functions.php
Created February 5, 2024 14:36
Load JS modules as ES6 in WordPress
<?
//load as ES6
function load_as_ES6($tag, $handle, $source) {
if('tagname' === $handle) {
$tag = '<script src="' . $source . '" type="module" ></script>';
}
return $tag;
}
add_filter('script_loader_tag', 'load_as_ES6', 10, 3);
@mjones129
mjones129 / some-page.php
Last active January 30, 2024 19:42
Exclude posts from WP_QUERY
<?
$args = [
'post_type' => 'any',
'post_status' => 'publish',
'order' => 'ASC',
'post__not_in' => [253, 236]
];
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) :
@mjones129
mjones129 / config
Created January 29, 2024 23:57
Example SSH config
#This is a fake config for demonstration purposes only. This hostname isn't real.
Host hostname-staging
User user-2flis9vgsdf
Hostname 9v0asdles.hostname.io
IdentityFile ~/.ssh/hostname
IdentitiesOnly yes
@mjones129
mjones129 / WP_Query_Args.php
Created January 29, 2024 19:19 — forked from fazlurr/WP_Query_Args.php
WP_Query arguments list
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@mjones129
mjones129 / functions.php
Created January 18, 2024 01:52
Enable ES6 Modules for WordPress Themes JS
//load as ES6
function load_as_ES6($tag, $handle, $source) {
if('some-script-handle' === $handle) {
$tag = '<script src="' . $source . '" type="module" ></script>';
}
return $tag;
}
add_filter('script_loader_tag', 'load_as_ES6', 10, 3);
@mjones129
mjones129 / turn-on-internet.sh
Created January 5, 2024 16:20
Enable (or re-enable) internet access in WSL2 after reboot
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf