Skip to content

Instantly share code, notes, and snippets.

View itsHall's full-sized avatar
💭
Living

Tyler Hall itsHall

💭
Living
View GitHub Profile
@itsHall
itsHall / functions.php
Last active November 2, 2021 21:33
Use CDN jQuery | WP
<?php
//----------------------------------------//
// Making jQuery load from Google Library //
//----------------------------------------//
add_filter( 'init', 'replace_default_jquery_with_fallback');
function replace_default_jquery_with_fallback() {
if (is_admin()) {
return;
@itsHall
itsHall / functions.php
Last active October 15, 2021 16:21
Replace Domain Name In Yoast SEO Canonical URL (Flywheel Local Bug Fix)
<?php
//------------------------------------------------//
// Replace Domain Name In Yoast SEO Canonical URL //
//------------------------------------------------//
$liveSiteURL = 'new-domain.com';
function replace_canonical_with_live_url($url) {
global $liveSiteURL;
$new_url = preg_replace("/(http|https):\/\/(?:.*?)\//i", "$1://" . $liveSiteURL . "/", $url);
@itsHall
itsHall / scripts.js
Last active October 14, 2021 20:51
Functions to handle localstorage object with expiration
function setWithExpiry(key, value, ttl) {
const now = new Date()
const item = {
value: value,
expiry: now.getTime() + ttl
}
localStorage.setItem(key, JSON.stringify(item))
}
@itsHall
itsHall / functions.php
Last active October 7, 2021 14:07
Make ACF WYSIWYG Fields Resizable With HTML Editor Syntax Highlighter Applied
<?php
//-------------------------------------------------------------------------------//
// Make ACF WYSIWYG Fields Resizable With HTML Editor Syntax Highlighter Applied //
//-------------------------------------------------------------------------------//
add_action('admin_head', 'my_custom_styles');
function my_custom_styles() {
echo '<style>
.CodeMirror {
resize: vertical;
@itsHall
itsHall / functions.php
Last active October 7, 2021 14:07
Removes WP Injected Jquery (jquery + migrate)
<?php
//------------------//
// Remove WP Jquery //
//------------------//
function change_default_jquery( ){
wp_dequeue_script( 'jquery');
wp_deregister_script( 'jquery');
}
add_filter( 'wp_enqueue_scripts', 'change_default_jquery', PHP_INT_MAX );
@itsHall
itsHall / functions.php
Last active October 7, 2021 14:07
Remove WP Injected Links/Scripts
<?php
//--------------------------------//
// Remove Unnecessary Header Code //
//--------------------------------//
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wp_shortlink_wp_head');
remove_action('wp_head', 'print_emoji_detection_script', 7 );
@itsHall
itsHall / functions.php
Last active October 7, 2021 14:06
Add HTML Editor Syntax Highlighter to ACF WYSIWYG
<?php
//---------------------------------------------------//
// Add HTML Editor Syntax Highlighter to ACF WYSIWYG //
//---------------------------------------------------//
/* ADD CODE MIRROR CSS */
function admin_style() {
wp_enqueue_style('admin-styles', 'https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.48.4/codemirror.css');
}
add_action('admin_enqueue_scripts', 'admin_style');
@itsHall
itsHall / functions.php
Last active October 7, 2021 14:06
Removes Comments | WP
<?php
//-------------------------------//
// Removes comment functionality //
//-------------------------------//
// Removes from admin menu
function my_remove_admin_menus() {
remove_menu_page( 'edit-comments.php' );
}
add_action( 'admin_menu', 'my_remove_admin_menus' );
@itsHall
itsHall / functions.php
Last active October 7, 2021 14:06
Redirect CPT Page to Home
<?php
//---------------------------//
// Redirect CPT Page to Home //
//---------------------------//
add_action( 'template_redirect', function() {
if ( is_singular('doctors') || is_singular('programs') ) {
global $post;
$redirectLink = get_home_url();
wp_redirect( $redirectLink, 302 );
@itsHall
itsHall / functions.php
Last active October 7, 2021 14:06
Removes noreferrer from href="_blank" links | WP
<?php
//---------------------------------------------------//
// Removes noreferrer from your new or updated posts //
//---------------------------------------------------//
add_filter( 'wp_targeted_link_rel', 'my_targeted_link_rel_remove_noreferrer',999);
function my_targeted_link_rel_remove_noreferrer( $rel_values ) {
return preg_replace( '/noreferrer\s*/i', '', $rel_values );
}