Skip to content

Instantly share code, notes, and snippets.

@mjones129
mjones129 / fixdivi.html
Created July 28, 2024 11:42
Preload Divi Icons As Fonts (fix menu icons rendering as numbers or letters)
<!-- Include in Divi > Theme Options > Integrations > Add code to the <head> of your blog -->
<link rel="preload" href="wp-content/themes/Divi/core/admin/fonts/modules/all/modules.ttf" as="font" type="font/ttf" crossorigin= "anonymous">
@mjones129
mjones129 / gist:f16ee274a276a5bc21a11fd3cc321ca9
Last active July 26, 2024 23:55
Set Wordpress URL with WPCLI
#show siteurl
wp db query "SELECT * FROM wp_options WHERE option_name = 'siteurl';"
#show home
wp db query "SELECT * FROM wp_options WHERE option_name = 'home';"
#update siteurl
wp db query "UPDATE wp_options SET option_value = 'https://newsiteurl.com' WHERE option_name = 'siteurl';"
#update home
@mjones129
mjones129 / wordpress-backup.sh
Last active August 13, 2024 21:05
WordPress Backups
#!/bin/bash
## exit script on error
set -e
# Variables
WP_PATH="/var/www/html"
BACKUP_PATH="/opt/backups"
DATE=$(date +"%Y-%m-%d")
BACKUP_DIR="${BACKUP_PATH}/${DATE}-backup"
@mjones129
mjones129 / register-post-type.php
Created July 17, 2024 10:14 — forked from justintadlock/register-post-type.php
Help file when registering post types.
<?php
# Register custom post types on the 'init' hook.
add_action( 'init', 'my_register_post_types' );
/**
* Registers post types needed by the plugin.
*
* @since 1.0.0
* @access public
@mjones129
mjones129 / functions.php
Created June 12, 2024 17:20
Disable Additional CSS
//disable additional css
function remove_additional_css( $wp_customize ) {
$wp_customize->remove_section('custom_css');
}
add_action('customize_register', 'remove_additional_css');
@mjones129
mjones129 / add-key.sh
Created May 6, 2024 15:01
Add SSH public key to server
# Magically copy your public key to a remote server and add it to authorized_keys with this handy one-liner.
# -i flag accepts the path to the file that will be uploaded.
# final argument is the username@host-destination root directory.
ssh-copy-id -i ~/.ssh/some-key.pub user@host.com
# To confirm the copy was successful (supposing you can recognize your public key when you see it)
ssh user@host.com && cat /.ssh/authorized_keys
@mjones129
mjones129 / functions.php
Created April 25, 2024 18:13
Check File Mod Time On Page Load
add_action('wp', 'test');
function test() {
//get file modified time of style.css
$time = filemtime('./style.css');
$msg = "style.css was modified at: " . $time;
$log_file = fopen(ABSPATH . '/theme_file_edit_logs.txt', 'a');
fwrite($log_file, $msg);
fclose($log_file);
}
@mjones129
mjones129 / wpe_setup.sh
Created April 16, 2024 13:42
Git Set up for WP Engine
#!/bin/bash
# Install SSH and Git
sudo apt-get update
sudo apt-get install -y openssh-server git
# Prompt user for email
read -p "Enter your email for SSH key generation: " email
# Generate SSH keys with different names and ed25519 algorithm
@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 = 'newadmin@example.com' 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,